From: Tom Barron Date: Thu, 21 Jan 2016 03:44:48 +0000 (-0500) Subject: Fix laggard cisco FC zone client unit tests X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=54ea31a80be047a7145553203ef8231f8c36df5d;p=openstack-build%2Fcinder-build.git Fix laggard cisco FC zone client unit tests The test_cisco_fc_zone_client_cli.py unit module tests methods decorated by utils.retry, which does retries with exponential backoffs, without mocking out time.sleep(). One test in this suite takes about 10% of the total time to run all cinder unit tests. This commit mocks time.sleep() in two critical tests in this module, yielding a 30x speedup in run-time for the module. Closes-Bug: #1536457 Change-Id: I3a686b760e2049a1f0ae4f8ee5ccbb4fa974aa1f --- diff --git a/cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py b/cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py index c5c057c32..b3e155ed5 100644 --- a/cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py +++ b/cinder/tests/unit/zonemanager/test_cisco_fc_zone_client_cli.py @@ -17,6 +17,8 @@ """Unit tests for Cisco fc zone client cli.""" +import time + import mock from oslo_concurrency import processutils from six.moves import range @@ -196,7 +198,8 @@ class TestCiscoFCZoneClientCLI(cli.CiscoFCZoneClientCLI, test.TestCase): run_ssh_mock.assert_called_once_with(cmd_list, True) @mock.patch.object(cli.CiscoFCZoneClientCLI, '_run_ssh') - def test__cfg_save_with_retry(self, run_ssh_mock): + @mock.patch.object(time, 'sleep') + def test__cfg_save_with_retry(self, mock_sleep, run_ssh_mock): cmd_list = ['copy', 'running-config', 'startup-config'] run_ssh_mock.side_effect = [ processutils.ProcessExecutionError, @@ -212,7 +215,8 @@ class TestCiscoFCZoneClientCLI(cli.CiscoFCZoneClientCLI, test.TestCase): ]) @mock.patch.object(cli.CiscoFCZoneClientCLI, '_run_ssh') - def test__cfg_save_with_error(self, run_ssh_mock): + @mock.patch.object(time, 'sleep') + def test__cfg_save_with_error(self, mock_sleep, run_ssh_mock): cmd_list = ['copy', 'running-config', 'startup-config'] run_ssh_mock.side_effect = processutils.ProcessExecutionError