More state handling in volume transfer requests functional tests

Using addCleanup() for removing the pending volume transfer request
has no way to wait for the volume status to become available before
cleaning up the volume and gets racy when the tests are run with
slow performance in the volume backend.  So we pause at the end of
the test after either accepting the transfer request or explicitly
deleting it so the cleanup can delete the volume.

Change-Id: I04862069cab28bc76eeafd60ba32be646f478d86
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
This commit is contained in:
Dean Troyer 2019-02-04 12:48:20 -06:00
parent dcff1012fd
commit 1a0bef2b46
1 changed files with 19 additions and 8 deletions

View File

@ -49,17 +49,20 @@ class TransferRequestTests(common.BaseVolumeTests):
volume_name
))
self.assertEqual(xfer_name, cmd_output['name'])
xfer_id = cmd_output['id']
auth_key = cmd_output['auth_key']
self.assertTrue(auth_key)
self.wait_for_status("volume", volume_name, "awaiting-transfer")
# accept the volume transfer request
cmd_output = json.loads(self.openstack(
'--os-volume-api-version ' + self.API_VERSION + ' ' +
'volume transfer request accept -f json ' +
'--auth-key ' + auth_key + ' ' +
xfer_name
xfer_id
))
self.assertEqual(xfer_name, cmd_output['name'])
self.wait_for_status("volume", volume_name, "available")
def test_volume_transfer_request_list_show(self):
volume_name = uuid.uuid4().hex
@ -86,15 +89,11 @@ class TransferRequestTests(common.BaseVolumeTests):
' --name ' + xfer_name + ' ' +
volume_name
))
self.addCleanup(
self.openstack,
'--os-volume-api-version ' + self.API_VERSION + ' ' +
'volume transfer request delete ' +
xfer_name
)
self.assertEqual(xfer_name, cmd_output['name'])
xfer_id = cmd_output['id']
auth_key = cmd_output['auth_key']
self.assertTrue(auth_key)
self.wait_for_status("volume", volume_name, "awaiting-transfer")
cmd_output = json.loads(self.openstack(
'--os-volume-api-version ' + self.API_VERSION + ' ' +
@ -105,6 +104,18 @@ class TransferRequestTests(common.BaseVolumeTests):
cmd_output = json.loads(self.openstack(
'--os-volume-api-version ' + self.API_VERSION + ' ' +
'volume transfer request show -f json ' +
xfer_name
xfer_id
))
self.assertEqual(xfer_name, cmd_output['name'])
# NOTE(dtroyer): We need to delete the transfer request to allow the
# volume to be deleted. The addCleanup() route does
# not have a mechanism to wait for the volume status
# to become 'available' before attempting to delete
# the volume.
cmd_output = self.openstack(
'--os-volume-api-version ' + self.API_VERSION + ' ' +
'volume transfer request delete ' +
xfer_id
)
self.wait_for_status("volume", volume_name, "available")