From 5b0aa48ec1502b3522ff19eada74855d98ec25de Mon Sep 17 00:00:00 2001 From: RobinWang Date: Wed, 10 Dec 2014 10:46:05 +0800 Subject: [PATCH] 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 --- neutron/tests/unit/openvswitch/test_ovs_tunnel.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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] -- 2.45.2