Several unit tests don't tear down utils.execute mock

Bug #1363192 reported by Greg Lucas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack DBaaS (Trove)
Fix Released
High
Greg Lucas

Bug Description

The unit tests are failing intermittently due to mocks that are not properly torn down.

For example:

FAIL: common.test_utils.TestTroveExecuteWithTimeout.test_log_error_when_log_output_on_error_is_true
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/stack/trove/trove/tests/unittests/common/test_utils.py", line 52, in test_log_error_when_log_output_on_error_is_true
    '/usr/bin/foo', log_output_on_error=True)
  File "/opt/stack/trove/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py", line 906, in __exit__
    raise AssertionError(error_msg)
AssertionError: ProcessExecutionError not raised.

This issue is caused by another test mocking utils.execute_with_timeout but not removing the mock afterwards.

Revision history for this message
Greg Lucas (glucas-q) wrote :

Found this mock without cleanup issue in two places:

trove/tests/unittests/backup/test_backupagent.py
trove/tests/unittests/common/test_utils.py

Changed in trove:
assignee: nobody → Greg Lucas (glucas-q)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to trove (master)

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

Changed in trove:
status: New → In Progress
Changed in trove:
importance: Undecided → High
milestone: none → juno-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to trove (master)

Reviewed: https://review.openstack.org/117856
Committed: https://git.openstack.org/cgit/openstack/trove/commit/?id=0e47809b81cc444e6995a9690c7d78488e8b6703
Submitter: Jenkins
Branch: master

commit 0e47809b81cc444e6995a9690c7d78488e8b6703
Author: Greg Lucas <email address hidden>
Date: Fri Aug 29 14:18:23 2014 -0400

    Avoid leaking mocks across unit tests

    In several unit tests, add setUp and tearDown logic to make sure that
    mocked functions are restored to their default implementation. Otherwise
    a leaked mock can cause another test to fail intermittently.

    Change-Id: I849a88cab45398592379c54210df2e3a97197c8c
    Closes-Bug: 1363192

Changed in trove:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in trove:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in trove:
milestone: juno-3 → 2014.2
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.