Merge "Add "render-only" option to "task" command"
[yardstick.git] / tests / unit / network_services / vnf_generic / vnf / test_prox_vnf.py
index 7692790..46786a3 100644 (file)
@@ -131,6 +131,8 @@ class TestProxApproxVnf(unittest.TestCase):
                 'packets_in',
                 'packets_fwd',
                 'packets_dropped',
+                'curr_packets_fwd',
+                'curr_packets_in'
             ],
         },
         'connection-point': [
@@ -329,7 +331,7 @@ class TestProxApproxVnf(unittest.TestCase):
             'packets_in': 0,
             'packets_dropped': 0,
             'packets_fwd': 0,
-            'collect_stats': {'core': {}},
+            'collect_stats': {'core': {}}
         }
         result = prox_approx_vnf.collect_kpi()
         self.assertEqual(result, expected)
@@ -352,7 +354,11 @@ class TestProxApproxVnf(unittest.TestCase):
             'collect_stats': {'core': {'result': 234}},
         }
         result = prox_approx_vnf.collect_kpi()
-        self.assertEqual(result, expected)
+        self.assertEqual(result['packets_in'], expected['packets_in'])
+        self.assertEqual(result['packets_dropped'], expected['packets_dropped'])
+        self.assertEqual(result['packets_fwd'], expected['packets_fwd'])
+        self.assertNotEqual(result['packets_fwd'], 0)
+        self.assertNotEqual(result['packets_fwd'], 0)
 
     @mock.patch(SSH_HELPER)
     def test_collect_kpi_error(self, ssh, *args):
@@ -373,6 +379,25 @@ class TestProxApproxVnf(unittest.TestCase):
         file_path = os.path.join(curr_path, filename)
         return file_path
 
+    @mock.patch('yardstick.common.utils.open', create=True)
+    @mock.patch('yardstick.benchmark.scenarios.networking.vnf_generic.open', create=True)
+    @mock.patch('yardstick.network_services.helpers.iniparser.open', create=True)
+    @mock.patch(SSH_HELPER)
+    def test_run_prox(self, ssh, *_):
+        mock_ssh(ssh)
+
+        prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)
+        prox_approx_vnf.scenario_helper.scenario_cfg = self.SCENARIO_CFG
+        prox_approx_vnf.ssh_helper.join_bin_path.return_value = '/tool_path12/tool_file34'
+        prox_approx_vnf.setup_helper.remote_path = 'configs/file56.cfg'
+
+        expected = "sudo bash -c 'cd /tool_path12; " \
+                   "/tool_path12/tool_file34 -o cli -t  -f /tmp/l3-swap-2.cfg '"
+
+        prox_approx_vnf._run()
+        result = prox_approx_vnf.ssh_helper.run.call_args[0][0]
+        self.assertEqual(result, expected)
+
     @mock.patch(SSH_HELPER)
     def bad_test_instantiate(self, *args):
         prox_approx_vnf = ProxApproxVnf(NAME, self.VNFD0)