aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmma Foley <emma.l.foley@intel.com>2019-01-29 18:15:23 +0000
committerEmma Foley <emma.l.foley@intel.com>2019-01-31 12:09:32 +0000
commit1342ab2acfbdeb39fd7aaeda7455ba6c16ad9095 (patch)
tree26570e7114080402d76bbf666c59817b2cf9c068
parentdfb534bbd7ab1454c1ad3b63d0b785e3050c1962 (diff)
Mock time.sleep in slow tests
time.sleep was called in a number of classes which wasn't mocked in the tests. This accounted for 2.5 minutes of UT execution time. The calls to time.sleep() have been mocked, and the test execution time has been reduced. JIRA: YARDSTICK-1595 Change-Id: I0a4f4962513cf8845471b074347601e33b35ef25 Signed-off-by: Emma Foley <emma.l.foley@intel.com>
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_prox_irq.py4
-rw-r--r--yardstick/tests/unit/network_services/traffic_profile/test_prox_profile.py4
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py4
-rw-r--r--yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py6
4 files changed, 14 insertions, 4 deletions
diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_prox_irq.py b/yardstick/tests/unit/network_services/traffic_profile/test_prox_irq.py
index 59f37befa..1a9947984 100644
--- a/yardstick/tests/unit/network_services/traffic_profile/test_prox_irq.py
+++ b/yardstick/tests/unit/network_services/traffic_profile/test_prox_irq.py
@@ -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': {
},
diff --git a/yardstick/tests/unit/network_services/traffic_profile/test_prox_profile.py b/yardstick/tests/unit/network_services/traffic_profile/test_prox_profile.py
index 11bee03a4..2660d4134 100644
--- a/yardstick/tests/unit/network_services/traffic_profile/test_prox_profile.py
+++ b/yardstick/tests/unit/network_services/traffic_profile/test_prox_profile.py
@@ -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,
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
index 9a30fb9e9..742dbfe24 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_prox_helpers.py
@@ -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
diff --git a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
index a5b9f258e..a390ed09a 100644
--- a/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
+++ b/yardstick/tests/unit/network_services/vnf_generic/vnf/test_tg_rfc2544_trex.py
@@ -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