Attributes of FakeBroker class changes while test execution

Bug #1180354 reported by Vladimir Vechkanov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
Undecided
Vladimir Vechkanov

Bug Description

In unit tests for db_replicator there is FakeBroker class. We use it instead of db_replicator.brokerclass function. So instead of call brokerclass function while using test will be called init method for FakeBroker class. That's why while creating new instance of replicator we set replicator.brokerclass attribute as FakeBroker (not as instance of FakeBroker, but as class). For each test we create new instance of replicator, but in all of them .brokerclass is a link to FakeBroker

In one of the tests attribute of replicator.brokerclass is changing, so all tests which are called after that will be use not expected value of the FaleBroker attribute.

More than that, changed attribute caused calling qarantine_db function which deleting all "test/unit/common" directory. Tests in nosetests are calling in alphabetical order (not in order how they are written) so understanding why directory was deleted is too hard.

I suggest to create function which will give new FakeBroker class for each test case.

Changed in swift:
assignee: nobody → Vladimir Vechkanov (vvechkanov)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (master)

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

Changed in swift:
status: New → In Progress
Revision history for this message
Samuel Merritt (torgomatic) wrote :

Ah yes, the old mock leakage problem.

In past cases where I've noticed a leaked mock, I've found that changing from a manual mock installation to using 'mock.patch' as a context manager ensures the leak does not return. (Of course, this is just a suggestion. I haven't seen the code in question.)

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

Reviewed: https://review.openstack.org/29228
Committed: http://github.com/openstack/swift/commit/fd3b64bb16df5617cdc429130e8325eeda6b45c6
Submitter: Jenkins
Branch: master

commit fd3b64bb16df5617cdc429130e8325eeda6b45c6
Author: Vladimir Vechkanov <email address hidden>
Date: Tue May 21 18:57:17 2013 +0400

    Fix problem with changing class attribute

    Attribute get_repl_missing_table in FakeBroker class was changed in
    test_replicate_object_quarantine function and not returned back. That's
    why next test cases takes not expexted values from FakeBroker.

    fixes bug 1180354
    Change-Id: Iba55255771e6483832c7782fcbe331e20e818f4e

Changed in swift:
status: In Progress → Fix Committed
Changed in swift:
milestone: none → 1.9.0
Thierry Carrez (ttx)
Changed in swift:
status: Fix Committed → Fix Released
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.