Correct monkey patching in GuestAgentBackupTest
This change addresses some intermittent failures in tests that we've been seeing recently. The failure would typically manifest itself in test_prepare_from_backup test in test_mongodb_manager.py but in theory it could occur elsewhere. The good thing about this change is that it will make the intermittent failures persistent. But, thanks to the fix for bug 1353570 (change I22d839f) the failures won't happen any longer. This change, without the earlier change for bug 1353570 did in fact serve to make the intermittent failures permanent. The issue is that GuestAgentBackupTest didn't unpatch execute_with_timeout when it was done. This meant that tests running after it were running in an environment where execute_with_timeout was patched. But, just in case you had a test which didn't itself patch execute_with_timeout and it happened to run on a thread that hadn't run GuestAgentBackupTest, you'd get a bad result. The fix is to include code to save and restore execute_with_timeout in setUp and tearDown. Change-Id: I60187145d25524b4e7614d5d8cce9027521db44c Closes-Bug: #1347337
This commit is contained in:
parent
fd39eec2d4
commit
f2efdcc29b
|
@ -81,10 +81,12 @@ class GuestAgentBackupTest(testtools.TestCase):
|
|||
self.orig = mysql_impl.get_auth_password
|
||||
mysql_impl.get_auth_password = mock.Mock(
|
||||
return_value='password')
|
||||
self.orig_exec_with_to = utils.execute_with_timeout
|
||||
|
||||
def tearDown(self):
|
||||
super(GuestAgentBackupTest, self).tearDown()
|
||||
mysql_impl.get_auth_password = self.orig
|
||||
utils.execute_with_timeout = self.orig_exec_with_to
|
||||
|
||||
def test_backup_decrypted_xtrabackup_command(self):
|
||||
backupBase.BackupRunner.is_zipped = True
|
||||
|
|
|
@ -39,6 +39,7 @@ class GuestAgentMongoDBManagerTest(testtools.TestCase):
|
|||
self.origin_mount_points = volume.VolumeDevice.mount_points
|
||||
self.origin_stop_db = mongo_service.MongoDBApp.stop_db
|
||||
self.origin_start_db = mongo_service.MongoDBApp.start_db
|
||||
self.orig_exec_with_to = utils.execute_with_timeout
|
||||
|
||||
def tearDown(self):
|
||||
super(GuestAgentMongoDBManagerTest, self).tearDown()
|
||||
|
@ -50,6 +51,7 @@ class GuestAgentMongoDBManagerTest(testtools.TestCase):
|
|||
volume.VolumeDevice.mount_points = self.origin_mount_points
|
||||
mongo_service.MongoDBApp.stop_db = self.origin_stop_db
|
||||
mongo_service.MongoDBApp.start_db = self.origin_start_db
|
||||
utils.execute_with_timeout = self.orig_exec_with_to
|
||||
|
||||
def test_update_status(self):
|
||||
self.manager.status = MagicMock()
|
||||
|
|
Loading…
Reference in New Issue