Merge "Mock time.sleep in slow tests"
authorVolodymyr Mytnyk <volodymyrx.mytnyk@intel.com>
Wed, 6 Feb 2019 16:32:50 +0000 (16:32 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Wed, 6 Feb 2019 16:32:50 +0000 (16:32 +0000)
yardstick/tests/unit/network_services/traffic_profile/test_prox_irq.py
yardstick/tests/unit/network_services/traffic_profile/test_prox_profile.py
yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py

index 59f37be..1a99479 100644 (file)
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+import time
 
 import unittest
 import mock
@@ -28,7 +29,8 @@ class TestProxIrqProfile(unittest.TestCase):
     def _stop_mocks(self):
         self._mock_log_info.stop()
 
-    def test_execute_1(self):
+    @mock.patch.object(time, 'sleep')
+    def test_execute_1(self, *args):
         tp_config = {
             'traffic_profile': {
             },
index 11bee03..2660d41 100644 (file)
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+import time
 
 import unittest
 import mock
@@ -78,7 +79,8 @@ class TestProxProfile(unittest.TestCase):
         profile.init(queue)
         self.assertIs(profile.queue, queue)
 
-    def test_execute_traffic(self):
+    @mock.patch.object(time, 'sleep')
+    def test_execute_traffic(self, *args):
         packet_sizes = [
             10,
             100,
index 9a30fb9..742dbfe 100644 (file)
@@ -2400,6 +2400,7 @@ class TestProxProfileHelper(unittest.TestCase):
         with helper.traffic_context(64, 1):
             pass
 
+    @mock.patch.object(time, 'sleep')
     def test_run_test(self, *args):
         resource_helper = mock.MagicMock()
         resource_helper.step_delta = 0.4
@@ -2549,6 +2550,7 @@ class TestProxBngProfileHelper(unittest.TestCase):
         self.assertEqual(helper.arp_task_cores, expected_arp_task)
         self.assertEqual(helper._cores_tuple, expected_combined)
 
+    @mock.patch.object(time, 'sleep')
     def test_run_test(self, *args):
         resource_helper = mock.MagicMock()
         resource_helper.step_delta = 0.4
@@ -2675,6 +2677,7 @@ class TestProxVpeProfileHelper(unittest.TestCase):
         self.assertEqual(helper.inet_ports, expected_inet)
         self.assertEqual(helper._ports_tuple, expected_combined)
 
+    @mock.patch.object(time, 'sleep')
     def test_run_test(self, *args):
         resource_helper = mock.MagicMock()
         resource_helper.step_delta = 0.4
@@ -2792,6 +2795,7 @@ class TestProxlwAFTRProfileHelper(unittest.TestCase):
         self.assertEqual(helper.inet_ports, expected_inet)
         self.assertEqual(helper._ports_tuple, expected_combined)
 
+    @mock.patch.object(time, 'sleep')
     def test_run_test(self, *args):
         resource_helper = mock.MagicMock()
         resource_helper.step_delta = 0.4
index a9fa5f3..7ef94c3 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2016-2017 Intel Corporation
+# Copyright (c) 2016-2018 Intel Corporation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+import time
 
 import mock
 import unittest
@@ -24,7 +25,8 @@ from yardstick.network_services.vnf_generic.vnf import tg_rfc2544_trex
 
 class TestTrexRfcResouceHelper(unittest.TestCase):
 
-    def test__run_traffic_once(self):
+    @mock.patch.object(time, 'sleep')
+    def test__run_traffic_once(self, *args):
         mock_setup_helper = mock.Mock()
         mock_traffic_profile = mock.Mock()
         mock_traffic_profile.config.duration = 3