def test_clear(self): queue_file_wrapper = \ QueueFileWrapper(self.q_in, self.q_out, self.prompt) queue_file_wrapper.bufsize = 5 queue_file_wrapper.write("pipeline>") queue_file_wrapper.close() self.assertIsNotNone(queue_file_wrapper.q_out.empty())
def instantiate(self, scenario_cfg, context_cfg): vnf_cfg = scenario_cfg['vnf_options']['vpe']['cfg'] mgmt_interface = self.vnfd["mgmt-interface"] self.connection = ssh.SSH.from_node(mgmt_interface) self.tc_file_name = '{0}.yaml'.format(scenario_cfg['tc']) self.setup_vnf_environment(self.connection) cores = self._get_cpu_sibling_list() self.resource = ResourceProfile(self.vnfd, cores) self.connection.execute("pkill vPE_vnf") dpdk_nic_bind = \ provision_tool(self.connection, os.path.join(self.bin_path, "dpdk_nic_bind.py")) interfaces = self.vnfd["vdu"][0]['external-interface'] self.socket = \ next((0 for v in interfaces if v['virtual-interface']["vpci"][5] == "0"), 1) bound_pci = [v['virtual-interface']["vpci"] for v in interfaces] for vpci in bound_pci: self.connection.execute("%s --force -b igb_uio %s" % (dpdk_nic_bind, vpci)) queue_wrapper = \ QueueFileWrapper(self.q_in, self.q_out, "pipeline>") self._vnf_process = multiprocessing.Process(target=self._run_vpe, args=( queue_wrapper, vnf_cfg, )) self._vnf_process.start() buf = [] time.sleep(WAIT_TIME) # Give some time for config to load while True: message = '' while self.q_out.qsize() > 0: buf.append(self.q_out.get()) message = ''.join(buf) if "pipeline>" in message: LOG.info("VPE VNF is up and running.") queue_wrapper.clear() self._resource_collect_start() return self._vnf_process.exitcode if "PANIC" in message: raise RuntimeError("Error starting vPE VNF.") LOG.info("Waiting for VNF to start.. ") time.sleep(3) if not self._vnf_process.is_alive(): raise RuntimeError("vPE VNF process died.")
def test_run_vpe(self): with mock.patch("yardstick.ssh.SSH") as ssh: ssh_mock = mock.Mock(autospec=ssh.SSH) ssh_mock.execute = \ mock.Mock(return_value=(0, "", "")) ssh_mock.run = \ mock.Mock(return_value=(0, "", "")) ssh.from_node.return_value = ssh_mock vnfd = self.VNFD['vnfd:vnfd-catalog']['vnfd'][0] vpe_approx_vnf = VpeApproxVnf(vnfd) curr_path = os.path.dirname(os.path.abspath(__file__)) vpe_vnf = os.path.join(curr_path, "vpe_config") queue_wrapper = \ QueueFileWrapper(vpe_approx_vnf.q_in, vpe_approx_vnf.q_out, "pipeline>") self.assertEqual(None, vpe_approx_vnf._run_vpe(queue_wrapper, vpe_vnf))
def instantiate(self, scenario_cfg, context_cfg): LOG.info("printing .........prox instantiate ") self.scenario_helper.scenario_cfg = scenario_cfg # this won't work we need 1GB hugepages at boot self.setup_helper.setup_vnf_environment() # self.connection.run("cat /proc/cpuinfo") prox_args, prox_path, remote_path = self.resource_helper.get_process_args( ) self.q_in = multiprocessing.Queue() self.q_out = multiprocessing.Queue() self.queue_wrapper = QueueFileWrapper(self.q_in, self.q_out, "PROX started") self._vnf_process = multiprocessing.Process(target=self._run_prox, args=(remote_path, prox_path, prox_args)) self._vnf_process.start()
def _start_vnf(self): self.queue_wrapper = QueueFileWrapper(self.q_in, self.q_out, self.VNF_PROMPT) name = "{}-{}-{}".format(self.name, self.APP_NAME, os.getpid()) self._vnf_process = Process(name=name, target=self._run) self._vnf_process.start()
def test_read(self): queue_file_wrapper = \ QueueFileWrapper(self.q_in, self.q_out, self.prompt) queue_file_wrapper.q_in.put("pipeline>") self.assertEqual("pipeline>", queue_file_wrapper.read(20))
def test_close(self): queue_file_wrapper = \ QueueFileWrapper(self.q_in, self.q_out, self.prompt) self.assertEqual(None, queue_file_wrapper.close())
def test___init__(self): queue_file_wrapper = \ QueueFileWrapper(self.q_in, self.q_out, self.prompt) self.assertEqual(queue_file_wrapper.prompt, self.prompt)
def test_write(self): queue_file_wrapper = \ QueueFileWrapper(self.q_in, self.q_out, self.prompt) queue_file_wrapper.write("pipeline>") self.assertIsNotNone(queue_file_wrapper.q_out.empty())
def _start_vnf(self): self.queue_wrapper = QueueFileWrapper(self.q_in, self.q_out, self.VNF_PROMPT) self._vnf_process = Process(target=self._run) self._vnf_process.start()