Merge "Add send socket commands function"
[yardstick.git] / yardstick / tests / unit / benchmark / scenarios / networking / test_pktgen_dpdk.py
index 99399ab..bcd4178 100644 (file)
@@ -12,6 +12,7 @@ import unittest
 
 import yardstick.common.utils as utils
 from yardstick.benchmark.scenarios.networking import pktgen_dpdk
+from yardstick.common import exceptions as y_exc
 
 
 class PktgenDPDKLatencyTestCase(unittest.TestCase):
@@ -162,9 +163,9 @@ class PktgenDPDKLatencyTestCase(unittest.TestCase):
 
         sample_output = '100\n110\n112\n130\n149\n150\n90\n150\n200\n162\n'
         self.mock_ssh.SSH.from_node().execute.return_value = (0, sample_output, '')
-        self.assertRaises(AssertionError, p.run, result)
+        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,10 +178,18 @@ 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}
+        }
 
-def main():
-    unittest.main()
-
+        p = pktgen_dpdk.PktgenDPDKLatency(args, self.ctx)
 
-if __name__ == '__main__':
-    main()
+        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)