From: RobinWang Date: Wed, 10 Dec 2014 02:46:05 +0000 (+0800) Subject: Mock up time.sleep to avoid unnecessary wait in test_ovs_tunnel X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5b0aa48ec1502b3522ff19eada74855d98ec25de;p=openstack-build%2Fneutron-build.git Mock up time.sleep to avoid unnecessary wait in test_ovs_tunnel Unnecessary wait in ovs tunnel UT introduces extra 6 seconds time cost, and makes 3 test_daemon_loop cases the slowest tests. Mock up time.sleep to reduce UT time, from around 6.272s to 0.135s. Closes-bug: #1401457 Change-Id: Ic0a968a400268af1f66c91e4c39e7d3acf492ef3 --- diff --git a/neutron/tests/unit/openvswitch/test_ovs_tunnel.py b/neutron/tests/unit/openvswitch/test_ovs_tunnel.py index ca3645058..ee020d8cb 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_tunnel.py +++ b/neutron/tests/unit/openvswitch/test_ovs_tunnel.py @@ -15,6 +15,7 @@ # import contextlib +import time import mock from oslo.config import cfg @@ -519,8 +520,10 @@ class TunnelTest(base.BaseTestCase): mock.patch.object(ovs_neutron_agent.OVSNeutronAgent, 'process_network_ports'), mock.patch.object(ovs_neutron_agent.OVSNeutronAgent, - 'tunnel_sync') - ) as (log_exception, scan_ports, process_network_ports, ts): + 'tunnel_sync'), + mock.patch.object(time, 'sleep') + ) as (log_exception, scan_ports, process_network_ports, + ts, time_sleep): log_exception.side_effect = Exception( 'Fake exception to get out of the loop') scan_ports.side_effect = [reply2, reply3]