aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/test_ssh.py
diff options
context:
space:
mode:
authorMiikka Koistinen <miikka.koistinen@nokia.com>2018-05-09 17:25:51 +0300
committerMiikka Koistinen <miikka.koistinen@nokia.com>2018-06-19 09:30:49 +0300
commit724e49770c517782e269ccdb2320f4a7eb5d87d5 (patch)
treed3e74e54e3df2f0114c14b9723aaaae1ce7a20db /yardstick/tests/unit/test_ssh.py
parent772d13797e7c84cbc0f8b7ac9005c97b8111cfa8 (diff)
Refactor remote command execution in pktgen
Some remote commands in Pktgen are executed without checking the exit status. This patch makes all remote commands check exit value, and removes unused variables that are captured from remote command executions. JIRA: YARDSTICK-1166 Change-Id: I42a667ebd22d086887d61e1671bc569b03c59d33 Signed-off-by: Miikka Koistinen <miikka.koistinen@nokia.com>
Diffstat (limited to 'yardstick/tests/unit/test_ssh.py')
-rw-r--r--yardstick/tests/unit/test_ssh.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/yardstick/tests/unit/test_ssh.py b/yardstick/tests/unit/test_ssh.py
index 5cf1e50a0..b727e821d 100644
--- a/yardstick/tests/unit/test_ssh.py
+++ b/yardstick/tests/unit/test_ssh.py
@@ -238,6 +238,25 @@ class SSHTestCase(unittest.TestCase):
self.assertEqual("stdout fake data", stdout)
self.assertEqual("stderr fake data", stderr)
+ @mock.patch("yardstick.ssh.six.moves.StringIO")
+ def test_execute_raise_on_error_passed(self, mock_string_io):
+ mock_string_io.side_effect = stdio = [mock.Mock(), mock.Mock()]
+ stdio[0].read.return_value = "stdout fake data"
+ stdio[1].read.return_value = "stderr fake data"
+ with mock.patch.object(self.test_client, "run", return_value=0) \
+ as mock_run:
+ status, stdout, stderr = self.test_client.execute(
+ "cmd",
+ stdin="fake_stdin",
+ timeout=43,
+ raise_on_error=True)
+ mock_run.assert_called_once_with(
+ "cmd", stdin="fake_stdin", stdout=stdio[0],
+ stderr=stdio[1], timeout=43, raise_on_error=True)
+ self.assertEqual(0, status)
+ self.assertEqual("stdout fake data", stdout)
+ self.assertEqual("stderr fake data", stderr)
+
@mock.patch("yardstick.ssh.time")
def test_wait_timeout(self, mock_time):
mock_time.time.side_effect = [1, 50, 150]