From ed930ec5123a618fea3a6e6e64bf2d6bfccf7312 Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Thu, 18 Feb 2021 07:43:06 +0000 Subject: [PATCH] Fix: cinder store test With change[1], the validation check for volume type during service startup happens for single store also. (previously only for multi store). This introduced an additional call to get_cinderclient failing assert in test_migrate_image_after_upgrade. Similar code changes can cause future failures on glance gate and the code changes doesn't exist in glance. To address this, this patch loosens up the strict checking on call count for every method and just verifies it was called. [1] https://review.opendev.org/c/openstack/glance_store/+/774703 Closes-Bug: #1916011 Change-Id: I8852bb02732845c145cca9483b0b33e0a9d73d9e --- .../v2/test_legacy_update_cinder_store.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/glance/tests/functional/v2/test_legacy_update_cinder_store.py b/glance/tests/functional/v2/test_legacy_update_cinder_store.py index 2d02922c6a..d24f5700af 100644 --- a/glance/tests/functional/v2/test_legacy_update_cinder_store.py +++ b/glance/tests/functional/v2/test_legacy_update_cinder_store.py @@ -205,10 +205,12 @@ class TestLegacyUpdateCinderStore(functional.SynchronousAPIBase): self.assertEqual('cinder://store1/%s' % self.vol_id, image['locations'][0]['url']) self.assertEqual('store1', image['locations'][0]['metadata']['store']) - mocked_cc.assert_called_once() - mock_open.assert_called_once() - mock_chown.assert_called_once() - mock_connector.get_connector_properties.assert_called_once() + # NOTE(whoami-rajat): These are internals called by glance_store, so + # we want to make sure they got hit, but not be too strict about how. + mocked_cc.assert_called() + mock_open.assert_called() + mock_chown.assert_called() + mock_connector.get_connector_properties.assert_called() @mock.patch.object(cinderclient, 'Client') @mock.patch.object(cinder.Store, 'temporary_chown') @@ -245,10 +247,9 @@ class TestLegacyUpdateCinderStore(functional.SynchronousAPIBase): # verify the image location url is consistent self.assertEqual('cinder://store1/%s' % self.vol_id, image['locations'][0]['url']) - mock_open.assert_called_once() - mock_chown.assert_called_once() - mock_connector.get_connector_properties.assert_called_once() + # NOTE(whoami-rajat): These are internals called by glance_store, so + # we want to make sure they got hit, but not be too strict about how. mocked_cc.assert_called() - # first call when creating volume and second call when migrating - # the image (setting up multiple stores) - self.assertEqual(2, mocked_cc.call_count) + mock_open.assert_called() + mock_chown.assert_called() + mock_connector.get_connector_properties.assert_called()