Unit test failure "AssertionError: Expected to be called once. Called 2 times." in test_get_port_vnic_info_3

Bug #1381414 reported by Hans Lindgren
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Hans Lindgren
Juno
Fix Released
Undecided
Unassigned

Bug Description

This looks to be due to tests test_get_port_vnic_info_2 and 3 sharing some code and is easily reproduced by running these two tests alone with no concurrency.

./run_tests.sh --concurrency 1 test_get_port_vnic_info_2 test_get_port_vnic_info_3

The above always results in:

Traceback (most recent call last):
  File "/home/hans/nova/nova/tests/network/test_neutronv2.py", line 2615, in test_get_port_vnic_info_3
    self._test_get_port_vnic_info()
  File "/home/hans/nova/.venv/local/lib/python2.7/site-packages/mock.py", line 1201, in patched
    return func(*args, **keywargs)
  File "/home/hans/nova/nova/tests/network/test_neutronv2.py", line 2607, in _test_get_port_vnic_info
    fields=['binding:vnic_type', 'network_id'])
  File "/home/hans/nova/.venv/local/lib/python2.7/site-packages/mock.py", line 845, in assert_called_once_with
    raise AssertionError(msg)
AssertionError: Expected to be called once. Called 2 times.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/128589

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/128589
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=f91d4ebeac9181ff279158fe89a8d50b34184a89
Submitter: Jenkins
Branch: master

commit f91d4ebeac9181ff279158fe89a8d50b34184a89
Author: Hans Lindgren <email address hidden>
Date: Wed Oct 15 11:16:03 2014 +0200

    Fix unit test failure due to tests sharing mocks

    A recent refactor made test_get_port_vnic_info 2 and 3 share code
    in a private method _test_get_port_vnic_info(). A mock on this method
    is shared between the tests and can cause the following failure:

    AssertionError: Expected to be called once. Called 2 times.

    This is changed so that the two test methods create separate mocks and
    pass to the shared method.

    Change-Id: I3902b7b7cf4b4b3fdc2885bf2611a712d008c617
    Closes-Bug: #1381414

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Revision history for this message
Nikola Đipanov (ndipanov) wrote :

I am really surprised this is not hitting stable-juno gate as it seems like it will happen 100% of the time when these 2 tests are run in the same worker?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/146901

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/juno)

Reviewed: https://review.openstack.org/146901
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=4349015b26cc4df965595b6f1175be57ccc7eda2
Submitter: Jenkins
Branch: stable/juno

commit 4349015b26cc4df965595b6f1175be57ccc7eda2
Author: Hans Lindgren <email address hidden>
Date: Wed Oct 15 11:16:03 2014 +0200

    Fix unit test failure due to tests sharing mocks

    A recent refactor made test_get_port_vnic_info 2 and 3 share code
    in a private method _test_get_port_vnic_info(). A mock on this method
    is shared between the tests and can cause the following failure:

    AssertionError: Expected to be called once. Called 2 times.

    This is changed so that the two test methods create separate mocks and
    pass to the shared method.

    Change-Id: I3902b7b7cf4b4b3fdc2885bf2611a712d008c617
    Closes-Bug: #1381414
    (cherry picked from commit f91d4ebeac9181ff279158fe89a8d50b34184a89)

tags: added: in-stable-juno
Thierry Carrez (ttx)
Changed in nova:
milestone: kilo-1 → 2015.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.