An alternate way to fix retype notifier test case

When we do backup for a volume, the backup notification is called
periodically, but if we do other operations (like retype operation)
in parallel, there is a possible to record the "volume.retype" and
"backup.createprogress".

This patch try to mock the send notification methods to ensure this
doesn't happen.

Cloeses-Bug: #1803648

Co-Authored-By: Rajat Dhasmana <rajatdhasmana@gmail.com>

Change-Id: I4c44cdd6a4a11a3b7b5c57ff5aac19a8d01ef124
This commit is contained in:
Yikun Jiang 2018-11-16 17:42:41 +08:00
parent 18d0576bb5
commit 593d8dfa79
2 changed files with 12 additions and 0 deletions

View File

@ -177,6 +177,12 @@ class GoogleBackupDriverTestCase(test.TestCase):
for _i in range(0, 64):
self.volume_file.write(os.urandom(units.Ki))
self.size_volume_file += 1024
# Note(yikun): It mocks out the backup notifier to avoid to leak
# notifications into other test.
notify_patcher = mock.patch(
'cinder.volume.utils.notify_about_backup_usage')
notify_patcher.start()
self.addCleanup(notify_patcher.stop)
@gcs_client
def test_backup(self):

View File

@ -67,6 +67,12 @@ class BackupNFSShareTestCase(test.TestCase):
super(BackupNFSShareTestCase, self).setUp()
self.ctxt = context.get_admin_context()
self.mock_object(nfs, 'LOG')
# Note(yikun): It mocks out the backup notifier to avoid to leak
# notifications into other test.
notify_patcher = mock.patch(
'cinder.volume.utils.notify_about_backup_usage')
notify_patcher.start()
self.addCleanup(notify_patcher.stop)
def test_check_configuration_no_backup_share(self):
self.override_config('backup_share', None)