Exemplo n.º 1
0
    def test_vnf_execute_command(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
        cgnapt_approx_vnf.q_in = mock.MagicMock()
        cgnapt_approx_vnf.q_out = mock.MagicMock()
        cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        cmd = "quit"
        self.assertEqual("", cgnapt_approx_vnf.vnf_execute(cmd))
Exemplo n.º 2
0
    def test__vnf_up_post_short(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
        cgnapt_approx_vnf._vnf_process = mock.MagicMock()
        cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
        cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
        cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
        cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
        cgnapt_approx_vnf._vnf_up_post()
Exemplo n.º 3
0
    def test_terminate(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
        cgnapt_approx_vnf._vnf_process = mock.MagicMock()
        cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
        cgnapt_approx_vnf.used_drivers = {"01:01.0": "i40e", "01:01.1": "i40e"}
        cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
        cgnapt_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
        cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
        self.assertEqual(None, cgnapt_approx_vnf.terminate())
Exemplo n.º 4
0
    def test_get_stats(self, ssh, *args):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
        cgnapt_approx_vnf.q_in = mock.MagicMock()
        cgnapt_approx_vnf.q_out = mock.MagicMock()
        cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
        result = \
            "CG-NAPT(.*\n)*Received 100, Missed 0, Dropped 0,Translated 100,ingress"
        cgnapt_approx_vnf.vnf_execute = mock.Mock(return_value=result)
        self.assertListEqual(list(result), list(cgnapt_approx_vnf.get_stats()))
Exemplo n.º 5
0
 def test_vnf_execute_command(self, mock_time, mock_process):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, "", ""))
         ssh.from_node.return_value = ssh_mock
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
         cgnapt_approx_vnf.q_in = mock.MagicMock()
         cgnapt_approx_vnf.q_out = mock.MagicMock()
         cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
         cmd = "quit"
         self.assertEqual("", cgnapt_approx_vnf.vnf_execute(cmd))
Exemplo n.º 6
0
    def test__vnf_up_post(self, ssh, mock_time, mock_process):
        mock_ssh(ssh)

        vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
        self.scenario_cfg['options'][name]['napt'] = 'static'

        cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
        cgnapt_approx_vnf._vnf_process = mock.MagicMock()
        cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
        cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
        cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
        cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
        cgnapt_approx_vnf._vnf_up_post()
Exemplo n.º 7
0
 def test_get_stats(self, mock_process):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, "", ""))
         ssh.from_node.return_value = ssh_mock
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
         cgnapt_approx_vnf.q_in = mock.MagicMock()
         cgnapt_approx_vnf.q_out = mock.MagicMock()
         cgnapt_approx_vnf.q_out.qsize = mock.Mock(return_value=0)
         mock_result = \
             "CG-NAPT(.*\n)*Received 100, Missed 0, Dropped 0,Translated 100,ingress"
         cgnapt_approx_vnf.vnf_execute = mock.Mock(return_value=mock_result)
         self.assertListEqual(list(mock_result), list(cgnapt_approx_vnf.get_stats()))
Exemplo n.º 8
0
 def test__vnf_up_post(self, mock_time, mock_cgnapt_time, mock_process):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, "", ""))
         ssh.from_node.return_value = ssh_mock
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
         cgnapt_approx_vnf._vnf_process = mock.MagicMock()
         cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
         cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
         cgnapt_approx_vnf.ssh_helper = ssh_mock
         cgnapt_approx_vnf.scenario_helper.scenario_cfg = self.scenario_cfg
         cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
         cgnapt_approx_vnf._vnf_up_post()
         cgnapt_approx_vnf.vnf_execute.assert_called_once()
Exemplo n.º 9
0
 def test_terminate(self, mock_time, mock_process):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(0, "", ""))
         ssh.from_node.return_value = ssh_mock
         vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0]
         cgnapt_approx_vnf = CgnaptApproxVnf(name, vnfd)
         cgnapt_approx_vnf._vnf_process = mock.MagicMock()
         cgnapt_approx_vnf._vnf_process.terminate = mock.Mock()
         cgnapt_approx_vnf.used_drivers = {"01:01.0": "i40e",
                                           "01:01.1": "i40e"}
         cgnapt_approx_vnf.vnf_execute = mock.MagicMock()
         cgnapt_approx_vnf.ssh_helper = ssh_mock
         cgnapt_approx_vnf.dpdk_nic_bind = "dpdk_nic_bind.py"
         cgnapt_approx_vnf._resource_collect_stop = mock.Mock()
         self.assertEqual(None, cgnapt_approx_vnf.terminate())