From c84cc7000a5f4159d3eb905bf6cf2a8e438bab6f Mon Sep 17 00:00:00 2001 From: Miikka Koistinen Date: Mon, 2 Jul 2018 13:50:59 +0300 Subject: Refactor remote command execution in vsperf_dpdk * Remove unneeded variables * Do not raise RuntimeError when a remote command fails, instead leave it for the yardstick ssh module to handle. * Prevent CsvReader from raising StopIteration if csv output cannot be parsed. The SLA validation will take care of errors in that case. JIRA: YARDSTICK-1166 Change-Id: I9e353d39dfd3bd27407dde32744ce71b5762e84e Signed-off-by: Miikka Koistinen --- .../scenarios/networking/test_vsperf_dpdk.py | 34 +++++++++------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'yardstick/tests/unit/benchmark/scenarios/networking') diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py index b305fc93b..8bbe6911e 100644 --- a/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py +++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_vsperf_dpdk.py @@ -116,15 +116,6 @@ class VsperfDPDKTestCase(unittest.TestCase): self.assertTrue(self.scenario._is_dpdk_setup()) self.assertTrue(self.scenario.dpdk_setup_done) - @mock.patch.object(time, 'sleep') - def test_dpdk_setup_runtime_error(self, *args): - self.assertIsNotNone(self.scenario.client) - self.mock_ssh.from_node().execute.return_value = (1, '', '') - self.assertTrue(self.scenario.setup_done) - - self.assertRaises(RuntimeError, self.scenario.dpdk_setup) - - @mock.patch.object(time, 'sleep') @mock.patch.object(subprocess, 'check_output') def test_run_ok(self, *args): # run() specific mocks @@ -135,17 +126,6 @@ class VsperfDPDKTestCase(unittest.TestCase): self.scenario.run(result) self.assertEqual(result['throughput_rx_fps'], '14797660.000') - def test_run_failed_vsperf_execution(self): - self.mock_ssh.from_node().execute.return_value = (1, '', '') - - self.assertRaises(RuntimeError, self.scenario.run, {}) - - def test_run_falied_csv_report(self): - # run() specific mocks - self.mock_ssh.from_node().execute.return_value = (1, '', '') - - self.assertRaises(RuntimeError, self.scenario.run, {}) - @mock.patch.object(time, 'sleep') @mock.patch.object(subprocess, 'check_output') def test_vsperf_run_sla_fail(self, *args): @@ -171,6 +151,20 @@ class VsperfDPDKTestCase(unittest.TestCase): self.assertIn('throughput_rx_fps was not collected by VSPERF', str(raised.exception)) + @mock.patch.object(time, 'sleep') + @mock.patch.object(subprocess, 'check_output') + def test_vsperf_run_sla_fail_metric_not_collected_faulty_csv(self, *args): + self.scenario.setup() + + self.mock_ssh.from_node().execute.return_value = ( + 0, 'faulty output not csv', '') + + with self.assertRaises(y_exc.SLAValidationError) as raised: + self.scenario.run({}) + + self.assertIn('throughput_rx_fps was not collected by VSPERF', + str(raised.exception)) + @mock.patch.object(time, 'sleep') @mock.patch.object(subprocess, 'check_output') def test_vsperf_run_sla_fail_sla_not_defined(self, *args): -- cgit 1.2.3-korg