summaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/scenarios
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-09-06 22:49:47 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-09-06 22:49:47 +0000
commit3cce3bc588bef62e980cdcee3c9b7d6eac81bed2 (patch)
tree023ce0e41e1d5fc5a8d283c1507f715adce4ab85 /tests/unit/benchmark/scenarios
parent3a92ca2209b413622b17da29e246a5bbc5389fe9 (diff)
parentca12137494ee4edadd77e1e4e0fb86d297a37fe3 (diff)
Merge "test_vsperf_dpdk: mock time to speedup unitests"
Diffstat (limited to 'tests/unit/benchmark/scenarios')
-rw-r--r--tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py b/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
index de5bae2f3..5759f0a90 100644
--- a/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
+++ b/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py
@@ -118,7 +118,8 @@ class VsperfDPDKTestCase(unittest.TestCase):
result = p._is_dpdk_setup()
self.assertEqual(result, True)
- def test_vsperf_dpdk_dpdk_setup_first(self, mock_ssh, mock_subprocess):
+ @mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.time')
+ def test_vsperf_dpdk_dpdk_setup_first(self, mock_time, mock_ssh, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
@@ -135,42 +136,43 @@ class VsperfDPDKTestCase(unittest.TestCase):
self.assertEqual(p._is_dpdk_setup(), False)
self.assertEqual(p.dpdk_setup_done, True)
- def test_vsperf_dpdk_dpdk_setup_next(self, mock_ssh, mock_subprocess):
+ @mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.time')
+ def test_vsperf_dpdk_dpdk_setup_next(self, mock_time, mock_ssh, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
+ mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
self.assertIsNotNone(p.client)
self.assertEqual(p.setup_done, True)
- # dpdk_setup() specific mocks
- mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
-
p.dpdk_setup()
self.assertEqual(p._is_dpdk_setup(), True)
self.assertEqual(p.dpdk_setup_done, True)
- def test_vsperf_dpdk_dpdk_setup_fail(self, mock_ssh, mock_subprocess):
+ @mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.time')
+ def test_vsperf_dpdk_dpdk_setup_fail(self, mock_time, mock_ssh, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
+ mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
self.assertIsNotNone(p.client)
- self.assertEqual(p.setup_done, True)
-
- # dpdk_setup() specific mocks
mock_ssh.SSH.from_node().execute.return_value = (1, '', '')
+ self.assertEqual(p.setup_done, True)
self.assertRaises(RuntimeError, p.dpdk_setup)
- def test_vsperf_dpdk_run_ok(self, mock_ssh, mock_subprocess):
+ @mock.patch('yardstick.benchmark.scenarios.networking.vsperf_dpdk.time')
+ def test_vsperf_dpdk_run_ok(self, mock_time, mock_ssh, mock_subprocess):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
+ mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
@@ -179,7 +181,6 @@ class VsperfDPDKTestCase(unittest.TestCase):
# run() specific mocks
mock_subprocess.call().execute.return_value = None
- mock_subprocess.call().execute.return_value = None
mock_ssh.SSH.from_node().execute.return_value = (
0, 'throughput_rx_fps\r\n14797660.000\r\n', '')
@@ -193,6 +194,7 @@ class VsperfDPDKTestCase(unittest.TestCase):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
+ mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()
@@ -211,6 +213,7 @@ class VsperfDPDKTestCase(unittest.TestCase):
p = vsperf_dpdk.VsperfDPDK(self.args, self.ctx)
# setup() specific mocks
+ mock_ssh.SSH.from_node().execute.return_value = (0, '', '')
mock_subprocess.call().execute.return_value = None
p.setup()