From acc6f624cdb1b2e4a3900e7d226bbc5156e8fa17 Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Tue, 23 Nov 2021 11:01:44 -0500 Subject: [PATCH] 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 --- .../v2/test_legacy_update_cinder_store.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 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 64c544fed9..28a3b6605b 100644 --- a/glance/tests/functional/v2/test_legacy_update_cinder_store.py +++ b/glance/tests/functional/v2/test_legacy_update_cinder_store.py @@ -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.