Misuse of nova.objects.base.obj_equal_prims in tests

Bug #1839853 reported by Matt Riedemann on 2019-08-12
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Medium
Takashi NATSUME
Ocata
Medium
Takashi NATSUME
Pike
Medium
Takashi NATSUME
Queens
Medium
Takashi NATSUME
Rocky
Medium
Takashi NATSUME
Stein
Medium
Takashi NATSUME

Bug Description

There are some tests, mostly related to BuildRequest objects, that are calling nova.objects.base.obj_equal_prims which does not assert anything, it only returns True or False - the test code itself must assert the expected result of the obj_equal_prims method.

https://github.com/openstack/nova/blob/ab34c941be28f3486cd2699af8d9237e9edac351/nova/tests/functional/db/test_build_request.py

https://github.com/openstack/nova/blob/d89579a66ac38fd1e30cea55306e6e7b69bab5b9/nova/tests/unit/objects/test_build_request.py

Matt Riedemann (mriedem) wrote :

I'm assuming all of the calls to that method should be wrapped in an assertTrue statement.

Changed in nova:
status: New → Confirmed
tags: added: testing
Changed in nova:
importance: Undecided → Medium
tags: added: low-hanging-fruit
Changed in nova:
assignee: nobody → Takashi NATSUME (natsume-takashi)
status: Confirmed → In Progress

Reviewed: https://review.opendev.org/676030
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=5c1d9dcbb29f5a84d56c4e496b3111b4040cad13
Submitter: Zuul
Branch: master

commit 5c1d9dcbb29f5a84d56c4e496b3111b4040cad13
Author: Takashi NATSUME <email address hidden>
Date: Tue Aug 13 09:31:32 2019 +0900

    Fix misuse of nova.objects.base.obj_equal_prims

    The nova.objects.base.obj_equal_prims returns True or False.
    It does not assert anything.
    So the return value should be asserted in tests.

    Add assertTrue where the nova.objects.base.obj_equal_prims is called.

    Change-Id: I49460ec3b572ee14b32229e771a5499ff91e8722
    Closes-Bug: #1839853

Changed in nova:
status: In Progress → Fix Released

Reviewed: https://review.opendev.org/676289
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=a8e19afb3d4889412ee6f539bb63865eb8ef5bb5
Submitter: Zuul
Branch: stable/stein

commit a8e19afb3d4889412ee6f539bb63865eb8ef5bb5
Author: Takashi NATSUME <email address hidden>
Date: Tue Aug 13 09:31:32 2019 +0900

    Fix misuse of nova.objects.base.obj_equal_prims

    The nova.objects.base.obj_equal_prims returns True or False.
    It does not assert anything.
    So the return value should be asserted in tests.

    Add assertTrue where the nova.objects.base.obj_equal_prims is called.

    Change-Id: I49460ec3b572ee14b32229e771a5499ff91e8722
    Closes-Bug: #1839853
    (cherry picked from commit 5c1d9dcbb29f5a84d56c4e496b3111b4040cad13)

Reviewed: https://review.opendev.org/676290
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=a17bb97b2eb1f8657423f2ecbbfbfb9b1b629ae7
Submitter: Zuul
Branch: stable/rocky

commit a17bb97b2eb1f8657423f2ecbbfbfb9b1b629ae7
Author: Takashi NATSUME <email address hidden>
Date: Tue Aug 13 09:31:32 2019 +0900

    Fix misuse of nova.objects.base.obj_equal_prims

    The nova.objects.base.obj_equal_prims returns True or False.
    It does not assert anything.
    So the return value should be asserted in tests.

    Add assertTrue where the nova.objects.base.obj_equal_prims is called.

    Change-Id: I49460ec3b572ee14b32229e771a5499ff91e8722
    Closes-Bug: #1839853
    (cherry picked from commit 5c1d9dcbb29f5a84d56c4e496b3111b4040cad13)
    (cherry picked from commit a8e19afb3d4889412ee6f539bb63865eb8ef5bb5)

Reviewed: https://review.opendev.org/676291
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=151c828b1f498d44342d9265e575e5fdcb0783c1
Submitter: Zuul
Branch: stable/queens

commit 151c828b1f498d44342d9265e575e5fdcb0783c1
Author: Takashi NATSUME <email address hidden>
Date: Tue Aug 13 09:31:32 2019 +0900

    Fix misuse of nova.objects.base.obj_equal_prims

    The nova.objects.base.obj_equal_prims returns True or False.
    It does not assert anything.
    So the return value should be asserted in tests.

    Add assertTrue where the nova.objects.base.obj_equal_prims is called.

    Change-Id: I49460ec3b572ee14b32229e771a5499ff91e8722
    Closes-Bug: #1839853
    (cherry picked from commit 5c1d9dcbb29f5a84d56c4e496b3111b4040cad13)
    (cherry picked from commit a8e19afb3d4889412ee6f539bb63865eb8ef5bb5)
    (cherry picked from commit a17bb97b2eb1f8657423f2ecbbfbfb9b1b629ae7)

Reviewed: https://review.opendev.org/676292
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=a926d356d08ad4b00c0e810053b20bfd9c46ac41
Submitter: Zuul
Branch: stable/pike

commit a926d356d08ad4b00c0e810053b20bfd9c46ac41
Author: Takashi NATSUME <email address hidden>
Date: Tue Aug 13 09:31:32 2019 +0900

    Fix misuse of nova.objects.base.obj_equal_prims

    The nova.objects.base.obj_equal_prims returns True or False.
    It does not assert anything.
    So the return value should be asserted in tests.

    Add assertTrue where the nova.objects.base.obj_equal_prims is called.

    Change-Id: I49460ec3b572ee14b32229e771a5499ff91e8722
    Closes-Bug: #1839853
    (cherry picked from commit 5c1d9dcbb29f5a84d56c4e496b3111b4040cad13)
    (cherry picked from commit a8e19afb3d4889412ee6f539bb63865eb8ef5bb5)
    (cherry picked from commit a17bb97b2eb1f8657423f2ecbbfbfb9b1b629ae7)
    (cherry picked from commit 151c828b1f498d44342d9265e575e5fdcb0783c1)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers