Skip to content

Commit e39ef4e

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix cinder tests for refactoring effort"
2 parents 907c562 + 0e70f66 commit e39ef4e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

glance/tests/functional/v2/test_legacy_update_cinder_store.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,23 @@
1919

2020
from cinderclient.v3 import client as cinderclient
2121
import glance_store
22-
from glance_store._drivers import cinder
2322
from oslo_config import cfg
2423
from oslo_log import log as logging
2524
from oslo_utils import strutils
2625

2726
from glance.common import wsgi
2827
from glance.tests import functional
2928

29+
# Keeping backward compatibility to support importing from old
30+
# path
31+
try:
32+
from glance_store._drivers.cinder import base
33+
from glance_store._drivers.cinder import store as cinder
34+
except ImportError:
35+
from glance_store._drivers import cinder
36+
base = mock.Mock()
37+
38+
3039
LOG = logging.getLogger(__name__)
3140

3241
CONF = cfg.CONF
@@ -135,6 +144,7 @@ def _mock_wait_volume_status(self, volume, status_transition,
135144
volume.status = status_expected
136145
return volume
137146

147+
@mock.patch.object(base, 'connector')
138148
@mock.patch.object(cinderclient, 'Client')
139149
@mock.patch.object(cinder.Store, 'temporary_chown')
140150
@mock.patch.object(cinder, 'connector')
@@ -143,7 +153,8 @@ def _mock_wait_volume_status(self, volume, status_transition,
143153
@mock.patch.object(strutils, 'mask_dict_password')
144154
@mock.patch.object(socket, 'getaddrinfo')
145155
def test_create_image(self, mock_host_addr, mock_mask_pass, mock_wait,
146-
mock_open, mock_connector, mock_chown, mocked_cc):
156+
mock_open, mock_connector, mock_chown, mocked_cc,
157+
mock_base):
147158
# setup multiple cinder stores
148159
self.setup_multiple_stores()
149160
self.start_server()
@@ -165,6 +176,7 @@ def test_create_image(self, mock_host_addr, mock_mask_pass, mock_wait,
165176
mock_chown.assert_called()
166177
mock_connector.get_connector_properties.assert_called()
167178

179+
@mock.patch.object(base, 'connector')
168180
@mock.patch.object(cinderclient, 'Client')
169181
@mock.patch.object(cinder.Store, 'temporary_chown')
170182
@mock.patch.object(cinder, 'connector')
@@ -174,7 +186,7 @@ def test_create_image(self, mock_host_addr, mock_mask_pass, mock_wait,
174186
@mock.patch.object(socket, 'getaddrinfo')
175187
def test_migrate_image_after_upgrade(self, mock_host_addr, mock_mask_pass,
176188
mock_wait, mock_open, mock_connector,
177-
mock_chown, mocked_cc):
189+
mock_chown, mocked_cc, mock_base):
178190
"""Test to check if an image is successfully migrated when we
179191
180192
upgrade from a single cinder store to multiple cinder stores.
@@ -213,6 +225,7 @@ def test_migrate_image_after_upgrade(self, mock_host_addr, mock_mask_pass,
213225
mock_chown.assert_called()
214226
mock_connector.get_connector_properties.assert_called()
215227

228+
@mock.patch.object(base, 'connector')
216229
@mock.patch.object(cinderclient, 'Client')
217230
@mock.patch.object(cinder.Store, 'temporary_chown')
218231
@mock.patch.object(cinder, 'connector')
@@ -224,7 +237,8 @@ def test_migrate_image_after_upgrade_not_owner(self, mock_host_addr,
224237
mock_mask_pass,
225238
mock_wait, mock_open,
226239
mock_connector,
227-
mock_chown, mocked_cc):
240+
mock_chown, mocked_cc,
241+
mock_base):
228242
"""Test to check if an image is successfully migrated when we upgrade
229243
from a single cinder store to multiple cinder stores, and that
230244
GETs from non-owners in the meantime are not interrupted.

0 commit comments

Comments
 (0)