From 593d8dfa79980db651b88957f766604240e64e76 Mon Sep 17 00:00:00 2001 From: Yikun Jiang Date: Fri, 16 Nov 2018 17:42:41 +0800 Subject: [PATCH] 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 Change-Id: I4c44cdd6a4a11a3b7b5c57ff5aac19a8d01ef124 --- cinder/tests/unit/backup/drivers/test_backup_google.py | 6 ++++++ cinder/tests/unit/backup/drivers/test_backup_nfs.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/cinder/tests/unit/backup/drivers/test_backup_google.py b/cinder/tests/unit/backup/drivers/test_backup_google.py index e39369d6719..61e9fd51817 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_google.py +++ b/cinder/tests/unit/backup/drivers/test_backup_google.py @@ -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): diff --git a/cinder/tests/unit/backup/drivers/test_backup_nfs.py b/cinder/tests/unit/backup/drivers/test_backup_nfs.py index c65d0131fcc..eeafc9809ce 100644 --- a/cinder/tests/unit/backup/drivers/test_backup_nfs.py +++ b/cinder/tests/unit/backup/drivers/test_backup_nfs.py @@ -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)