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
This commit is contained in:
whoami-rajat 2021-02-18 07:43:06 +00:00
parent 7922092e4a
commit ed930ec512

View File

@ -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()