openstack: nova_utils_tests: Use API timeout argument instead of sleep() 15/51415/1
authorMarkos Chandras <mchandras@suse.de>
Wed, 31 Jan 2018 19:03:43 +0000 (19:03 +0000)
committerMarkos Chandras <mchandras@suse.de>
Wed, 31 Jan 2018 19:08:38 +0000 (19:08 +0000)
On slow environments, time.sleep(10) is not enough for attach/detach API
calls to propage properly leading to failures like the following one
(reduced api_check test)

2018-01-31 18:53:19,297 - functest.ci.run_tests - INFO - Running test case 'api_check'...
2018-01-31 18:54:27,434 - functest.ci.run_tests - INFO - Test result:

+-------------------+------------------+------------------+----------------+
|     TEST CASE     |     PROJECT      |     DURATION     |     RESULT     |
+-------------------+------------------+------------------+----------------+
|     api_check     |     functest     |      01:07       |      FAIL      |
+-------------------+------------------+------------------+----------------+

We can workaround this by using the nova_utils.{de,at}tach_volume}
'timeout' argument to wait up to 2 minutes for the attach/detach call to
complete. This doesn't affect normal exception whilst it helps get the
test going on slow systems. WIth this change, the api_check (reduced
test) passes as follows:

2018-01-31 18:48:35,469 - functest.ci.run_tests - INFO - Running test case 'api_check'...
2018-01-31 18:50:56,705 - functest.ci.run_tests - INFO - Test result:

+-------------------+------------------+------------------+----------------+
|     TEST CASE     |     PROJECT      |     DURATION     |     RESULT     |
+-------------------+------------------+------------------+----------------+
|     api_check     |     functest     |      02:20       |      PASS      |
+-------------------+------------------+------------------+----------------+

Change-Id: I2245adb84d0e6d4e3350d17d0c2e44baf5202d51
Signed-off-by: Markos Chandras <mchandras@suse.de>
snaps/openstack/utils/tests/nova_utils_tests.py

index 8cb0812..77dc5dd 100644 (file)
@@ -451,9 +451,7 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
         neutron = neutron_utils.neutron_client(self.os_creds)
         nova_utils.attach_volume(
             self.nova, neutron, self.instance_creator.get_vm_inst(),
-            self.volume_creator.get_volume())
-
-        time.sleep(10)
+            self.volume_creator.get_volume(), 120)
 
         vol_attach = cinder_utils.get_volume_by_id(
             self.cinder, self.volume_creator.get_volume().id)
@@ -463,9 +461,7 @@ class NovaUtilsInstanceVolumeTests(OSComponentTestCase):
         # Detach volume to VM
         nova_utils.detach_volume(
             self.nova, neutron, self.instance_creator.get_vm_inst(),
-            self.volume_creator.get_volume())
-
-        time.sleep(10)
+            self.volume_creator.get_volume(), 120)
 
         vol_detach = cinder_utils.get_volume_by_id(
             self.cinder, self.volume_creator.get_volume().id)