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))
def test_collect_kpi(self, ssh, mock_process): 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) cgnapt_approx_vnf.resource = mock.Mock(autospec=ResourceProfile) result = {'packets_dropped': 0, 'packets_fwd': 0, 'packets_in': 0} self.assertEqual(result, cgnapt_approx_vnf.collect_kpi())
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()))
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))
def test_collect_kpi(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) cgnapt_approx_vnf.resource = mock.Mock(autospec=ResourceProfile) result = {'packets_dropped': 0, 'packets_fwd': 0, 'packets_in': 0} self.assertEqual(result, cgnapt_approx_vnf.collect_kpi())
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()))