def test_terminate(self, ssh, _): mock_ssh(ssh) vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock.MagicMock() vpe_approx_vnf._resource_collect_stop = mock.Mock() vpe_approx_vnf.resource_helper = mock.MagicMock() self.assertIsNone(vpe_approx_vnf.terminate())
def test_wait_for_instantiate_crash(self, ssh, _): mock_ssh(ssh, exec_result=(1, "", "")) mock_process = mock.Mock(autospec=Process) mock_process.is_alive.return_value = False mock_process.exitcode = 432 mock_resource = mock.MagicMock() vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.resource_helper.resource = mock_resource with self.assertRaises(RuntimeError) as raised: vpe_approx_vnf.wait_for_instantiate() self.assertIn('VNF process died', str(raised.exception))
def test_wait_for_instantiate_panic(self, ssh): mock_ssh(ssh, exec_result=(1, "", "")) mock_process = mock.Mock(autospec=Process) mock_process.is_alive.return_value = True mock_process.exitcode = 432 mock_resource = mock.MagicMock() vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.resource_helper.resource = mock_resource vpe_approx_vnf.q_out.put("PANIC") with self.assertRaises(RuntimeError) as raised: vpe_approx_vnf.wait_for_instantiate() self.assertIn('Error starting', str(raised.exception))
def test_wait_for_instantiate_fragmented(self, ssh, _): mock_ssh(ssh) mock_process = mock.Mock(autospec=Process) mock_process.is_alive.return_value = True mock_process.exitcode = 432 # test that fragmented pipeline prompt is recognized mock_q_out = mock.Mock(autospec=Queue) mock_q_out.get.side_effect = iter(["wow pipel", "ine>"]) mock_q_out.qsize.side_effect = range(2, -1, -1) mock_resource = mock.MagicMock() vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.q_out = mock_q_out vpe_approx_vnf.queue_wrapper = mock.Mock(autospec=QueueFileWrapper) vpe_approx_vnf.resource_helper.resource = mock_resource self.assertEqual(vpe_approx_vnf.wait_for_instantiate(), 432)
def test_wait_for_instantiate(self, ssh): mock_ssh(ssh) mock_process = mock.Mock(autospec=Process) mock_process.is_alive.return_value = True mock_process.exitcode = 432 mock_q_out = mock.Mock(autospec=Queue) mock_q_out.get.side_effect = iter(["pipeline>"]) mock_q_out.qsize.side_effect = range(1, -1, -1) mock_resource = mock.MagicMock() vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.q_out = mock_q_out vpe_approx_vnf.queue_wrapper = mock.Mock(autospec=QueueFileWrapper) vpe_approx_vnf.resource_helper.resource = mock_resource vpe_approx_vnf.q_out.put("pipeline>") self.assertEqual(vpe_approx_vnf.wait_for_instantiate(), 432)
def test_wait_for_instantiate_panic_fragmented(self, ssh, _): mock_ssh(ssh, exec_result=(1, "", "")) mock_process = mock.Mock(autospec=Process) mock_process.is_alive.return_value = True mock_process.exitcode = 432 # test that fragmented PANIC is recognized mock_q_out = mock.Mock(autospec=Queue) mock_q_out.get.side_effect = iter(["omg PA", "NIC this is bad"]) mock_q_out.qsize.side_effect = range(2, -1, -1) mock_resource = mock.MagicMock() vpe_approx_vnf = VpeApproxVnf(NAME, self.VNFD_0) vpe_approx_vnf._vnf_process = mock_process vpe_approx_vnf.q_out = mock_q_out vpe_approx_vnf.resource_helper.resource = mock_resource with self.assertRaises(RuntimeError) as raised: vpe_approx_vnf.wait_for_instantiate() self.assertIn('Error starting', str(raised.exception))