Skip to content

Commit a991980

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Improve CinderFixtureNewAttachFlow"
2 parents b1a1090 + 576a4e5 commit a991980

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

nova/tests/fixtures.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from oslo_concurrency import lockutils
3333
from oslo_config import cfg
3434
from oslo_db import exception as db_exc
35+
from oslo_log import log as logging
3536
import oslo_messaging as messaging
3637
from oslo_messaging import conffixture as messaging_conffixture
3738
from oslo_privsep import daemon as privsep_daemon
@@ -69,6 +70,8 @@
6970
DB_SCHEMA = {'main': "", 'api': ""}
7071
SESSION_CONFIGURED = False
7172

73+
LOG = logging.getLogger(__name__)
74+
7275

7376
class ServiceFixture(fixtures.Fixture):
7477
"""Run a service as a test fixture."""
@@ -1947,18 +1950,26 @@ def fake_attachment_create(_self, context, volume_id, instance_uuid,
19471950
attachment = {'id': attachment_id, 'connection_info': {'data': {}}}
19481951
self.volume_to_attachment[volume_id].append(
19491952
(attachment_id, instance_uuid))
1953+
LOG.info('Created attachment %s for volume %s. Total '
1954+
'attachments for volume: %d', attachment_id, volume_id,
1955+
len(self.volume_to_attachment[volume_id]))
19501956

19511957
return attachment
19521958

19531959
def fake_attachment_delete(_self, context, attachment_id):
19541960
# 'attachment' is a tuple defining a attachment-instance mapping
1955-
_, attachment, attachments = _find_attachment(attachment_id)
1961+
volume_id, attachment, attachments = (
1962+
_find_attachment(attachment_id))
19561963
attachments.remove(attachment)
1964+
LOG.info('Deleted attachment %s for volume %s. Total attachments '
1965+
'for volume: %d', attachment_id, volume_id,
1966+
len(attachments))
19571967

19581968
def fake_attachment_update(_self, context, attachment_id, connector,
19591969
mountpoint=None):
19601970
# Ensure the attachment exists
19611971
_find_attachment(attachment_id)
1972+
LOG.info('Updating volume attachment: %s', attachment_id)
19621973
attachment_ref = {'driver_volume_type': 'fake_type',
19631974
'id': attachment_id,
19641975
'connection_info': {'data':
@@ -1987,14 +1998,19 @@ def fake_get_all_volume_types(*args, **kwargs):
19871998
'name': 'lvm-1'
19881999
}]
19892000

2001+
def fake_attachment_complete(_self, _context, attachment_id):
2002+
# Ensure the attachment exists
2003+
_find_attachment(attachment_id)
2004+
LOG.info('Completing volume attachment: %s', attachment_id)
2005+
19902006
self.test.stub_out('nova.volume.cinder.API.attachment_create',
19912007
fake_attachment_create)
19922008
self.test.stub_out('nova.volume.cinder.API.attachment_delete',
19932009
fake_attachment_delete)
19942010
self.test.stub_out('nova.volume.cinder.API.attachment_update',
19952011
fake_attachment_update)
19962012
self.test.stub_out('nova.volume.cinder.API.attachment_complete',
1997-
lambda *args, **kwargs: None)
2013+
fake_attachment_complete)
19982014
self.test.stub_out('nova.volume.cinder.API.attachment_get',
19992015
fake_attachment_get)
20002016
self.test.stub_out('nova.volume.cinder.API.begin_detaching',
@@ -2007,7 +2023,7 @@ def fake_get_all_volume_types(*args, **kwargs):
20072023
self.test.stub_out('nova.volume.cinder.API.roll_detaching',
20082024
lambda *args, **kwargs: None)
20092025
self.test.stub_out('nova.volume.cinder.is_microversion_supported',
2010-
lambda *args, **kwargs: None)
2026+
lambda ctxt, microversion: None)
20112027
self.test.stub_out('nova.volume.cinder.API.check_attached',
20122028
lambda *args, **kwargs: None)
20132029
self.test.stub_out('nova.volume.cinder.API.get_all_volume_types',

0 commit comments

Comments
 (0)