summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-10-07 21:57:02 +0000
committerGerrit Code Review <review@openstack.org>2019-10-07 21:57:02 +0000
commit56a216294c14d32c782def377258aae43800379b (patch)
tree10f400b7dd81b09228b1db48d0f89044b75e27e7
parentd0da6cec4d5e5571317281fa5dd7838d4d11ae39 (diff)
parentea39101a9c19f61cd5dec98986f67aad9518fdc4 (diff)
downloadcinder-56a216294c14d32c782def377258aae43800379b.tar.gz
Merge "Tests: Fix up migrate notify tests" into stable/queens
-rw-r--r--cinder/test.py17
-rw-r--r--cinder/tests/unit/volume/test_volume_migration.py7
2 files changed, 20 insertions, 4 deletions
diff --git a/cinder/test.py b/cinder/test.py
index c8c9e6ccd..3ab440199 100644
--- a/cinder/test.py
+++ b/cinder/test.py
@@ -381,7 +381,22 @@ class TestCase(testtools.TestCase):
return result
# Useful assertions
- def assert_notify_called(self, mock_notify, calls):
+ def assert_notify_called(self, mock_notify, calls, any_order=False):
+ if any_order is True:
+ for c in calls:
+ # mock_notify.call_args_list = [
+ # mock.call('INFO', 'volume.retype', ...),
+ # mock.call('WARN', 'cinder.fire', ...)]
+ # m = mock_notify.call_args_list
+ # m[0] = Call
+ # m[0][0] = tuple('INFO', <context>, 'volume.retype', ...)
+ if not any(m for m in mock_notify.call_args_list
+ if (m[0][0] == c[0] # 'INFO'
+ and
+ m[0][2] == c[1])): # 'volume.retype'
+ raise AssertionError("notify call not found: %s" % c)
+ return
+
for i in range(0, len(calls)):
mock_call = mock_notify.call_args_list[i]
call = calls[i]
diff --git a/cinder/tests/unit/volume/test_volume_migration.py b/cinder/tests/unit/volume/test_volume_migration.py
index 2270e8e92..14bff8401 100644
--- a/cinder/tests/unit/volume/test_volume_migration.py
+++ b/cinder/tests/unit/volume/test_volume_migration.py
@@ -888,20 +888,21 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
self.assertEqual(CONF.host, volume.host)
self.assertEqual(1, volumes_in_use)
self.assert_notify_called(mock_notify,
- (['INFO', 'volume.retype'],))
+ (['INFO', 'volume.retype'],),
+ any_order=True)
elif not exc:
self.assertEqual(old_vol_type['id'], volume.volume_type_id)
self.assertEqual('retyping', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(1, volumes_in_use)
self.assert_notify_called(mock_notify,
- (['INFO', 'volume.retype'],))
+ (['INFO', 'volume.retype'],),
+ any_order=True)
else:
self.assertEqual(old_vol_type['id'], volume.volume_type_id)
self.assertEqual('available', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(0, volumes_in_use)
- mock_notify.assert_not_called()
if encryption_changed:
self.assertTrue(_mig.called)
self.assertEqual(expected_replica_status, volume.replication_status)