summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-09-04 22:04:05 +0000
committerGerrit Code Review <review@openstack.org>2020-09-04 22:04:06 +0000
commiteb44ee3670c4bd3e5d3e80a60056310ca9c9b376 (patch)
treebfbda72634f3d30506665a56711a30a67f789acb
parent334a479ae2f4ce3d48dcc4c1b9e14d0cb9822272 (diff)
parentf81d1a5ce400e756836497d26ea5bd5f7c7c14a9 (diff)
downloadnova-eb44ee3670c4bd3e5d3e80a60056310ca9c9b376.tar.gz
Merge "Improve CinderFixtureNewAttachFlow" into stable/stein
-rw-r--r--nova/tests/fixtures.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py
index a6a7f0fef9..e056d0ece5 100644
--- a/nova/tests/fixtures.py
+++ b/nova/tests/fixtures.py
@@ -32,6 +32,7 @@ import os_resource_classes as orc
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_db import exception as db_exc
+from oslo_log import log as logging
import oslo_messaging as messaging
from oslo_messaging import conffixture as messaging_conffixture
from oslo_privsep import daemon as privsep_daemon
@@ -68,6 +69,8 @@ CONF = cfg.CONF
DB_SCHEMA = {'main': "", 'api': ""}
SESSION_CONFIGURED = False
+LOG = logging.getLogger(__name__)
+
class ServiceFixture(fixtures.Fixture):
"""Run a service as a test fixture."""
@@ -1973,18 +1976,26 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
attachment = {'id': attachment_id, 'connection_info': {'data': {}}}
self.volume_to_attachment[volume_id].append(
(attachment_id, instance_uuid))
+ LOG.info('Created attachment %s for volume %s. Total '
+ 'attachments for volume: %d', attachment_id, volume_id,
+ len(self.volume_to_attachment[volume_id]))
return attachment
def fake_attachment_delete(_self, context, attachment_id):
# 'attachment' is a tuple defining a attachment-instance mapping
- _, attachment, attachments = _find_attachment(attachment_id)
+ volume_id, attachment, attachments = (
+ _find_attachment(attachment_id))
attachments.remove(attachment)
+ LOG.info('Deleted attachment %s for volume %s. Total attachments '
+ 'for volume: %d', attachment_id, volume_id,
+ len(attachments))
def fake_attachment_update(_self, context, attachment_id, connector,
mountpoint=None):
# Ensure the attachment exists
_find_attachment(attachment_id)
+ LOG.info('Updating volume attachment: %s', attachment_id)
attachment_ref = {'driver_volume_type': 'fake_type',
'id': attachment_id,
'connection_info': {'data':
@@ -2013,6 +2024,11 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
'name': 'lvm-1'
}]
+ def fake_attachment_complete(_self, _context, attachment_id):
+ # Ensure the attachment exists
+ _find_attachment(attachment_id)
+ LOG.info('Completing volume attachment: %s', attachment_id)
+
self.test.stub_out('nova.volume.cinder.API.attachment_create',
fake_attachment_create)
self.test.stub_out('nova.volume.cinder.API.attachment_delete',
@@ -2020,7 +2036,7 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
self.test.stub_out('nova.volume.cinder.API.attachment_update',
fake_attachment_update)
self.test.stub_out('nova.volume.cinder.API.attachment_complete',
- lambda *args, **kwargs: None)
+ fake_attachment_complete)
self.test.stub_out('nova.volume.cinder.API.attachment_get',
fake_attachment_get)
self.test.stub_out('nova.volume.cinder.API.begin_detaching',
@@ -2033,7 +2049,7 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
self.test.stub_out('nova.volume.cinder.API.roll_detaching',
lambda *args, **kwargs: None)
self.test.stub_out('nova.volume.cinder.is_microversion_supported',
- lambda *args, **kwargs: None)
+ lambda ctxt, microversion: None)
self.test.stub_out('nova.volume.cinder.API.check_attached',
lambda *args, **kwargs: None)
self.test.stub_out('nova.volume.cinder.API.get_all_volume_types',