Fix tests for logging connection info

While logging connection info in the glance cinder store driver, we
need to mask passwords for which we use oslo_utils's mask_dict_password
method.
Since this is not mocked in the glance functional tests, we encounter a failure
in cross-glance-tox-functional job in the change[1].
This patch adds the required mocking to pass the tests.

[1] https://review.opendev.org/c/openstack/glance_store/+/818722

Change-Id: Ibd9563fb854f888b4a2f5a5dcf6abce0cfab0f04
This commit is contained in:
whoami-rajat 2021-11-23 11:01:44 -05:00 committed by Rajat Dhasmana
parent 1db6e66f93
commit acc6f624cd

View File

@ -21,6 +21,7 @@ import glance_store
from glance_store._drivers import cinder
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import strutils
from glance.common import wsgi
from glance.tests import functional
@ -156,8 +157,9 @@ class TestLegacyUpdateCinderStore(functional.SynchronousAPIBase):
@mock.patch.object(cinder, 'connector')
@mock.patch.object(cinder, 'open')
@mock.patch('glance_store._drivers.cinder.Store._wait_volume_status')
def test_create_image(self, mock_wait, mock_open, mock_connector,
mock_chown, mocked_cc):
@mock.patch.object(strutils, 'mask_dict_password')
def test_create_image(self, mock_mask_pass, mock_wait, mock_open,
mock_connector, mock_chown, mocked_cc):
# setup multiple cinder stores
self.setup_multiple_stores()
self.start_server()
@ -183,9 +185,10 @@ class TestLegacyUpdateCinderStore(functional.SynchronousAPIBase):
@mock.patch.object(cinder, 'connector')
@mock.patch.object(cinder, 'open')
@mock.patch('glance_store._drivers.cinder.Store._wait_volume_status')
def test_migrate_image_after_upgrade(self, mock_wait, mock_open,
mock_connector, mock_chown,
mocked_cc):
@mock.patch.object(strutils, 'mask_dict_password')
def test_migrate_image_after_upgrade(self, mock_mask_pass, mock_wait,
mock_open, mock_connector,
mock_chown, mocked_cc):
"""Test to check if an image is successfully migrated when we
upgrade from a single cinder store to multiple cinder stores.
@ -228,9 +231,11 @@ class TestLegacyUpdateCinderStore(functional.SynchronousAPIBase):
@mock.patch.object(cinder, 'connector')
@mock.patch.object(cinder, 'open')
@mock.patch('glance_store._drivers.cinder.Store._wait_volume_status')
def test_migrate_image_after_upgrade_not_owner(self, mock_wait, mock_open,
mock_connector, mock_chown,
mocked_cc):
@mock.patch.object(strutils, 'mask_dict_password')
def test_migrate_image_after_upgrade_not_owner(self, mock_mask_pass,
mock_wait, mock_open,
mock_connector,
mock_chown, mocked_cc):
"""Test to check if an image is successfully migrated when we upgrade
from a single cinder store to multiple cinder stores, and that
GETs from non-owners in the meantime are not interrupted.