Skip to content

Commit 1a0bef2

Browse files
author
Dean Troyer
committed
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>
1 parent dcff101 commit 1a0bef2

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

openstackclient/tests/functional/volume/v2/test_transfer_request.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,20 @@ def test_volume_transfer_request_accept(self):
4949
volume_name
5050
))
5151
self.assertEqual(xfer_name, cmd_output['name'])
52+
xfer_id = cmd_output['id']
5253
auth_key = cmd_output['auth_key']
5354
self.assertTrue(auth_key)
55+
self.wait_for_status("volume", volume_name, "awaiting-transfer")
5456

5557
# accept the volume transfer request
5658
cmd_output = json.loads(self.openstack(
5759
'--os-volume-api-version ' + self.API_VERSION + ' ' +
5860
'volume transfer request accept -f json ' +
5961
'--auth-key ' + auth_key + ' ' +
60-
xfer_name
62+
xfer_id
6163
))
6264
self.assertEqual(xfer_name, cmd_output['name'])
65+
self.wait_for_status("volume", volume_name, "available")
6366

6467
def test_volume_transfer_request_list_show(self):
6568
volume_name = uuid.uuid4().hex
@@ -86,15 +89,11 @@ def test_volume_transfer_request_list_show(self):
8689
' --name ' + xfer_name + ' ' +
8790
volume_name
8891
))
89-
self.addCleanup(
90-
self.openstack,
91-
'--os-volume-api-version ' + self.API_VERSION + ' ' +
92-
'volume transfer request delete ' +
93-
xfer_name
94-
)
9592
self.assertEqual(xfer_name, cmd_output['name'])
93+
xfer_id = cmd_output['id']
9694
auth_key = cmd_output['auth_key']
9795
self.assertTrue(auth_key)
96+
self.wait_for_status("volume", volume_name, "awaiting-transfer")
9897

9998
cmd_output = json.loads(self.openstack(
10099
'--os-volume-api-version ' + self.API_VERSION + ' ' +
@@ -105,6 +104,18 @@ def test_volume_transfer_request_list_show(self):
105104
cmd_output = json.loads(self.openstack(
106105
'--os-volume-api-version ' + self.API_VERSION + ' ' +
107106
'volume transfer request show -f json ' +
108-
xfer_name
107+
xfer_id
109108
))
110109
self.assertEqual(xfer_name, cmd_output['name'])
110+
111+
# NOTE(dtroyer): We need to delete the transfer request to allow the
112+
# volume to be deleted. The addCleanup() route does
113+
# not have a mechanism to wait for the volume status
114+
# to become 'available' before attempting to delete
115+
# the volume.
116+
cmd_output = self.openstack(
117+
'--os-volume-api-version ' + self.API_VERSION + ' ' +
118+
'volume transfer request delete ' +
119+
xfer_id
120+
)
121+
self.wait_for_status("volume", volume_name, "available")

0 commit comments

Comments
 (0)