diff options
author | Markos Chandras <mchandras@suse.de> | 2018-02-20 17:19:13 +0000 |
---|---|---|
committer | Markos Chandras <mchandras@suse.de> | 2018-02-20 17:21:12 +0000 |
commit | f3553913925b8ee5869c8e06047d6e4161a968c7 (patch) | |
tree | 8933965db7ec546a6b926bbce47aa5b990cc402f | |
parent | 91b3bcb7ad2dda9479d2f97b080d8665d83968dd (diff) |
openstack: nova_utils_tests: Wait for volume detachment
The 'test_add_remove_volum' is supposed to wait for volume attachment
and detachments. However, the code for the latter was missing. Moreover,
we remove some code that checks for attached volumes since that should
never happen when detaching the volume.
Change-Id: I9ed54a467062d0ddc4efeddf03af7ebe6173e789
Signed-off-by: Markos Chandras <mchandras@suse.de>
-rw-r--r-- | snaps/openstack/utils/tests/nova_utils_tests.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/snaps/openstack/utils/tests/nova_utils_tests.py b/snaps/openstack/utils/tests/nova_utils_tests.py index 494c96c..ee9c5d1 100644 --- a/snaps/openstack/utils/tests/nova_utils_tests.py +++ b/snaps/openstack/utils/tests/nova_utils_tests.py @@ -456,6 +456,7 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase): self.volume_creator.get_volume(), self.project_id)) vol_attach = None + vol_detach = None attached = False start_time = time.time() while time.time() < start_time + 120: @@ -487,8 +488,19 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase): self.nova, neutron, self.instance_creator.get_vm_inst(), self.volume_creator.get_volume(), self.project_id)) - vol_detach = cinder_utils.get_volume_by_id( - self.cinder, self.volume_creator.get_volume().id) + start_time = time.time() + while time.time() < start_time + 120: + vol_detach = cinder_utils.get_volume_by_id( + self.cinder, self.volume_creator.get_volume().id) + if len(vol_detach.attachments) == 0: + attached = False + break + + time.sleep(3) + + self.assertFalse(attached) + self.assertIsNotNone(vol_detach) + vm_detach = nova_utils.get_server_object_by_id( self.nova, neutron, self.instance_creator.get_vm_inst().id, self.project_id) @@ -497,10 +509,6 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase): self.assertIsNotNone(vol_detach) self.assertEqual(self.volume_creator.get_volume().id, vol_detach.id) - if len(vol_detach.attachments) > 0: - vol_detach = cinder_utils.get_volume_by_id( - self.cinder, self.volume_creator.get_volume().id) - self.assertEqual(0, len(vol_detach.attachments)) self.assertEqual(0, len(vm_detach.volume_ids)) |