aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick
diff options
context:
space:
mode:
authorMiikka Koistinen <miikka.koistinen@nokia.com>2018-06-12 16:19:16 +0300
committerMiikka Koistinen <miikka.koistinen@nokia.com>2018-06-19 09:32:22 +0300
commit66c5efdd1705281abb57dcb14fff502ad125c0c1 (patch)
tree0b2fe980db993b057c15f2ee522acc85d83afc0c /yardstick
parent724e49770c517782e269ccdb2320f4a7eb5d87d5 (diff)
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 <miikka.koistinen@nokia.com>
Diffstat (limited to 'yardstick')
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen_dpdk.py5
-rw-r--r--yardstick/tests/unit/benchmark/scenarios/networking/test_pktgen_dpdk.py18
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)