From 66c5efdd1705281abb57dcb14fff502ad125c0c1 Mon Sep 17 00:00:00 2001 From: Miikka Koistinen Date: Tue, 12 Jun 2018 16:19:16 +0300 Subject: Refactor remote command execution in pktgen_dpdk PktgenDPDKLatency.run will raise a RuntimeError if a remote command fails. This commit makes it use the already existing exception raising mechanism in yardstick's ssh client. JIRA: YARDSTICK-1166 Change-Id: I3a3c7691399044b174f5d040c015c9b907b2fe5d Signed-off-by: Miikka Koistinen --- .../benchmark/scenarios/networking/pktgen_dpdk.py | 5 +---- .../benchmark/scenarios/networking/test_pktgen_dpdk.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py index 1b018f52a..efb7d8b5d 100644 --- a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py +++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py @@ -113,10 +113,7 @@ cat ~/result.log -vT \ {print substr($0,RSTART,RLENGTH)}' \ |grep -v ^$ |awk '{if ($2 != 0) print $2}'\ """ - client_status, client_stdout, client_stderr = self.client.execute(cmd) - - if client_status: - raise RuntimeError(client_stderr) + _, client_stdout, _ = self.client.execute(cmd, raise_on_error=True) avg_latency = 0 if client_stdout: diff --git a/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py b/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py index b141591f7..bcd417830 100644 --- a/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py +++ b/yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py @@ -165,7 +165,7 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase): self.mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '') self.assertRaises(y_exc.SLAValidationError, p.run, result) - def test_pktgen_dpdk_unsuccessful_script_error(self): + def test_pktgen_dpdk_run_unsuccessful_get_port_mac(self): args = { 'options': {'packetsize': 60}, @@ -177,3 +177,19 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase): self.mock_ssh.SSH.from_node().execute.return_value = (1, '', 'FOOBAR') self.assertRaises(RuntimeError, p.run, result) + + def test_pktgen_dpdk_run_unsuccessful_script_error(self): + args = { + 'options': {'packetsize': 60} + } + + p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx) + + self.mock_ssh.SSH.from_node().execute.side_effect = ((0, '', ''), + (0, '', ''), + (0, '', ''), + (0, '', ''), + (0, '', ''), + y_exc.SSHError) + self.assertRaises(y_exc.SSHError, p.run, {}) + self.assertEqual(self.mock_ssh.SSH.from_node().execute.call_count, 6) -- cgit 1.2.3-korg