Merge "Fix race in test_volume_swap_server_with_error"

This commit is contained in:
Zuul
2019-02-23 06:33:06 +00:00
committed by Gerrit Code Review
2 changed files with 4 additions and 23 deletions

View File

@@ -1505,7 +1505,6 @@ class CinderFixture(fixtures.Fixture):
def __init__(self, test):
super(CinderFixture, self).__init__()
self.test = test
self.swap_error = False
self.swap_volume_instance_uuid = None
self.swap_volume_instance_error_uuid = None
self.reserved_volumes = list()
@@ -1614,11 +1613,6 @@ class CinderFixture(fixtures.Fixture):
if volume_id in self.reserved_volumes:
self.reserved_volumes.remove(volume_id)
# Signaling that swap_volume has encountered the error
# from initialize_connection and is working on rolling back
# the reservation on SWAP_ERR_NEW_VOL.
self.swap_error = True
def fake_attach(_self, context, volume_id, instance_uuid,
mountpoint, mode='rw'):
# Check to see if the volume is already attached to any server.
@@ -1701,7 +1695,6 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
def __init__(self, test):
super(CinderFixtureNewAttachFlow, self).__init__()
self.test = test
self.swap_error = False
self.swap_volume_instance_uuid = None
self.swap_volume_instance_error_uuid = None
self.attachment_error_id = None
@@ -1845,9 +1838,6 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
_, attachment, attachments = _find_attachment(attachment_id)
attachments.remove(attachment)
if attachment_id == CinderFixtureNewAttachFlow.SWAP_ERR_ATTACH_ID:
self.swap_error = True
def fake_attachment_update(_self, context, attachment_id, connector,
mountpoint=None):
# Ensure the attachment exists
@@ -1858,6 +1848,8 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture):
{'foo': 'bar',
'target_lun': '1'}}}
if attachment_id == CinderFixtureNewAttachFlow.SWAP_ERR_ATTACH_ID:
# This intentionally triggers a TypeError for the
# instance.volume_swap.error versioned notification tests.
attachment_ref = {'connection_info': ()}
return attachment_ref

View File

@@ -365,13 +365,6 @@ class TestInstanceNotificationSample(
time.sleep(0.5)
self.fail('Volume swap operation failed.')
def _wait_until_swap_volume_error(self):
for i in range(50):
if self.cinder.swap_error:
return
time.sleep(0.5)
self.fail("Timed out waiting for volume swap error to occur.")
def test_instance_action(self):
# A single test case is used to test most of the instance action
# notifications to avoid booting up an instance for every action
@@ -1563,13 +1556,9 @@ class TestInstanceNotificationSample(
self._volume_swap_server(server, self.cinder.SWAP_ERR_OLD_VOL,
self.cinder.SWAP_ERR_NEW_VOL)
self._wait_until_swap_volume_error()
self._wait_for_notification('compute.exception')
# Seven versioned notifications are generated. We only rely on the
# first six because _wait_until_swap_volume_error will return True
# after volume_api.unreserve is called on the cinder fixture, and that
# happens before the instance fault is handled in the compute manager
# which generates the last notification (compute.exception).
# Eight versioned notifications are generated.
# 0. instance-create-start
# 1. instance-create-end
# 2. instance-update