From e8ba3c33321765eaccea0b346a1603dfaca58d81 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Wed, 12 Jul 2017 21:05:56 -0700 Subject: test_pktgen_dpdk_throughput: speedup unittest, mock time.sleep() Change-Id: I74bbdee1a503ef9bad32db7d4444921f6730f465 Signed-off-by: Ross Brattain --- .../scenarios/networking/test_pktgen_dpdk_throughput.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py index 0178165f8..d34097008 100644 --- a/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py +++ b/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk_throughput.py @@ -20,6 +20,7 @@ from yardstick.benchmark.scenarios.networking import pktgen_dpdk_throughput @mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.ssh') +@mock.patch('yardstick.benchmark.scenarios.networking.pktgen_dpdk_throughput.time') class PktgenDPDKTestCase(unittest.TestCase): def setUp(self): @@ -36,7 +37,7 @@ class PktgenDPDKTestCase(unittest.TestCase): } } - def test_pktgen_dpdk_throughput_successful_setup(self, mock_ssh): + def test_pktgen_dpdk_throughput_successful_setup(self, mock__time, mock_ssh): args = { 'options': {'packetsize': 60}, } @@ -48,7 +49,7 @@ class PktgenDPDKTestCase(unittest.TestCase): self.assertIsNotNone(p.client) self.assertEqual(p.setup_done, True) - def test_pktgen_dpdk_throughput_successful_no_sla(self, mock_ssh): + def test_pktgen_dpdk_throughput_successful_no_sla(self, mock__time, mock_ssh): args = { 'options': {'packetsize': 60, 'number_of_ports': 10}, } @@ -74,7 +75,7 @@ class PktgenDPDKTestCase(unittest.TestCase): expected_result["packetsize"] = 60 self.assertEqual(result, expected_result) - def test_pktgen_dpdk_throughput_successful_sla(self, mock_ssh): + def test_pktgen_dpdk_throughput_successful_sla(self, mock__time, mock_ssh): args = { 'options': {'packetsize': 60, 'number_of_ports': 10}, 'sla': {'max_ppm': 10000} @@ -100,7 +101,7 @@ class PktgenDPDKTestCase(unittest.TestCase): expected_result["packetsize"] = 60 self.assertEqual(result, expected_result) - def test_pktgen_dpdk_throughput_unsuccessful_sla(self, mock_ssh): + def test_pktgen_dpdk_throughput_unsuccessful_sla(self, mock__time, mock_ssh): args = { 'options': {'packetsize': 60, 'number_of_ports': 10}, 'sla': {'max_ppm': 1000} @@ -121,7 +122,7 @@ class PktgenDPDKTestCase(unittest.TestCase): mock_ssh.SSH().execute.return_value = (0, sample_output, '') self.assertRaises(AssertionError, p.run, result) - def test_pktgen_dpdk_throughput_unsuccessful_script_error(self, mock_ssh): + def test_pktgen_dpdk_throughput_unsuccessful_script_error(self, mock__time, mock_ssh): args = { 'options': {'packetsize': 60, 'number_of_ports': 10}, 'sla': {'max_ppm': 1000} @@ -136,7 +137,7 @@ class PktgenDPDKTestCase(unittest.TestCase): mock_ssh.SSH().execute.return_value = (1, '', 'FOOBAR') self.assertRaises(RuntimeError, p.run, result) - def test_pktgen_dpdk_throughput_is_dpdk_setup(self, mock_ssh): + def test_pktgen_dpdk_throughput_is_dpdk_setup(self, mock__time, mock_ssh): args = { 'options': {'packetsize': 60}, } @@ -150,7 +151,7 @@ class PktgenDPDKTestCase(unittest.TestCase): mock_ssh.SSH().execute.assert_called_with( "ip a | grep eth1 2>/dev/null") - def test_pktgen_dpdk_throughput_dpdk_setup(self, mock_ssh): + def test_pktgen_dpdk_throughput_dpdk_setup(self, mock__time, mock_ssh): args = { 'options': {'packetsize': 60}, } @@ -164,7 +165,7 @@ class PktgenDPDKTestCase(unittest.TestCase): self.assertEqual(p.dpdk_setup_done, True) - def test_pktgen_dpdk_throughput_dpdk_get_result(self, mock_ssh): + def test_pktgen_dpdk_throughput_dpdk_get_result(self, mock__time, mock_ssh): args = { 'options': {'packetsize': 60}, } -- cgit 1.2.3-korg