From 011c8254e9f9c6f586d8416aaf8be6f807e77e15 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 31 Jan 2018 19:03:43 +0000 Subject: openstack: nova_utils_tests: Use API timeout argument instead of sleep() 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 --- snaps/openstack/utils/tests/nova_utils_tests.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/snaps/openstack/utils/tests/nova_utils_tests.py b/snaps/openstack/utils/tests/nova_utils_tests.py index 8cb0812..77dc5dd 100644 --- a/snaps/openstack/utils/tests/nova_utils_tests.py +++ b/snaps/openstack/utils/tests/nova_utils_tests.py @@ -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) -- cgit 1.2.3-korg