def run_protocols(self): LOG.info('PPPoE Scenario - Start Protocols') self.client.start_protocols() utils.wait_until_true( lambda: self.client.is_protocols_running(self.protocols), timeout=WAIT_PROTOCOLS_STARTED, sleep=2)
def run_traffic(self, traffic_profile): if self._terminated.value: return min_tol = self.rfc_helper.tolerance_low max_tol = self.rfc_helper.tolerance_high precision = self.rfc_helper.tolerance_precision resolution = self.rfc_helper.resolution default = "00:00:00:00:00:00" self._build_ports() traffic_profile.update_traffic_profile(self) self._initialize_client(traffic_profile) mac = {} for port_name in self.vnfd_helper.port_pairs.all_ports: intf = self.vnfd_helper.find_interface(name=port_name) virt_intf = intf["virtual-interface"] # we only know static traffic id by reading the json # this is used by _get_ixia_trafficrofile port_num = self.vnfd_helper.port_num(intf) mac["src_mac_{}".format(port_num)] = virt_intf.get( "local_mac", default) mac["dst_mac_{}".format(port_num)] = virt_intf.get( "dst_mac", default) self._ix_scenario.run_protocols() try: while not self._terminated.value: first_run = traffic_profile.execute_traffic( self, self.client, mac) self.client_started.value = 1 # pylint: disable=unnecessary-lambda utils.wait_until_true(lambda: self.client.is_traffic_stopped(), timeout=traffic_profile.config.duration * 2) rfc2544_opts = self._ix_scenario.get_tc_rfc2544_options() samples = self.generate_samples( traffic_profile.ports, traffic_profile.config.duration) completed, samples = traffic_profile.get_drop_percentage( samples, min_tol, max_tol, precision, resolution, first_run=first_run, tc_rfc2544_opts=rfc2544_opts) self._queue.put(samples) if completed: self._terminated.value = 1 except Exception: # pylint: disable=broad-except LOG.exception('Run Traffic terminated') self._ix_scenario.stop_protocols() self.client_started.value = 0 self._terminated.value = 1
def run_traffic(self, traffic_profile): if self._terminated.value: return min_tol = self.rfc_helper.tolerance_low max_tol = self.rfc_helper.tolerance_high default = "00:00:00:00:00:00" self._build_ports() self._initialize_client() mac = {} for port_name in self.vnfd_helper.port_pairs.all_ports: intf = self.vnfd_helper.find_interface(name=port_name) virt_intf = intf["virtual-interface"] # we only know static traffic id by reading the json # this is used by _get_ixia_trafficrofile port_num = self.vnfd_helper.port_num(intf) mac["src_mac_{}".format(port_num)] = virt_intf.get( "local_mac", default) mac["dst_mac_{}".format(port_num)] = virt_intf.get( "dst_mac", default) try: while not self._terminated.value: first_run = traffic_profile.execute_traffic( self, self.client, mac) self.client_started.value = 1 # pylint: disable=unnecessary-lambda utils.wait_until_true(lambda: self.client.is_traffic_stopped()) samples = self.generate_samples(traffic_profile.ports) # NOTE(ralonsoh): the traffic injection duration is fixed to 30 # seconds. This parameter is configurable and must be retrieved # from the traffic_profile.full_profile information. # Every flow must have the same duration. completed, samples = traffic_profile.get_drop_percentage( samples, min_tol, max_tol, first_run=first_run) self._queue.put(samples) if completed: self._terminated.value = 1 except Exception: # pylint: disable=broad-except LOG.exception('Run Traffic terminated') self._terminated.value = 1
def start_traffic(self): """Start the traffic injection in the traffic item By configuration, there is only one traffic item. This function returns when the traffic state is TRAFFIC_STATUS_STARTED. """ traffic_items = self.ixnet.getList('/traffic', 'trafficItem') if self.is_traffic_running(): self.ixnet.execute('stop', '/traffic') # pylint: disable=unnecessary-lambda utils.wait_until_true(lambda: self.is_traffic_stopped()) self.ixnet.execute('generate', traffic_items) self.ixnet.execute('apply', '/traffic') self.ixnet.execute('start', '/traffic') # pylint: disable=unnecessary-lambda utils.wait_until_true(lambda: self.is_traffic_running())
def run_traffic(self, traffic_profile): self._traffic_profile = traffic_profile self._traffic_profile.init(self._node_ip, self._lua_node_port) utils.wait_until_true(self._is_running, timeout=self.TIMEOUT, sleep=2)
def _worker_process(queue, cls, method_name, scenario_cfg, context_cfg, aborted, output_queue): # pragma: no cover runner_cfg = scenario_cfg['runner'] timeout = runner_cfg.get('timeout', ITERATION_TIMEOUT) iterations = runner_cfg.get('iterations', 1) run_step = runner_cfg.get('run_step', 'setup,run,teardown') LOG.info('Worker START. Iterations %d times, class %s', iterations, cls) runner_cfg['runner_id'] = os.getpid() benchmark = cls(scenario_cfg, context_cfg) method = getattr(benchmark, method_name) if 'setup' not in run_step: raise exceptions.RunnerIterationIPCSetupActionNeeded() benchmark.setup() producer_ctxs = benchmark.get_mq_ids() if not producer_ctxs: raise exceptions.RunnerIterationIPCNoCtxs() mq_consumer = RunnerIterationIPCConsumer(os.getpid(), producer_ctxs) mq_consumer.start_rpc_server() mq_producer = base_runner.RunnerProducer(scenario_cfg['task_id']) iteration_index = 1 while 'run' in run_step: LOG.debug('runner=%(runner)s seq=%(sequence)s START', { 'runner': runner_cfg['runner_id'], 'sequence': iteration_index }) data = {} result = None errors = '' mq_consumer.iteration_index = iteration_index mq_producer.start_iteration() try: utils.wait_until_true( mq_consumer.is_all_kpis_received_in_iteration, timeout=timeout, sleep=2) result = method(data) except Exception: # pylint: disable=broad-except errors = traceback.format_exc() LOG.exception(errors) mq_producer.stop_iteration() if result: output_queue.put(result, True, QUEUE_PUT_TIMEOUT) benchmark_output = { 'timestamp': time.time(), 'sequence': iteration_index, 'data': data, 'errors': errors } queue.put(benchmark_output, True, QUEUE_PUT_TIMEOUT) LOG.debug('runner=%(runner)s seq=%(sequence)s END', { 'runner': runner_cfg['runner_id'], 'sequence': iteration_index }) iteration_index += 1 if iteration_index > iterations or aborted.is_set(): LOG.info('"IterationIPC" worker END') break if 'teardown' in run_step: try: benchmark.teardown() except Exception: LOG.exception('Exception during teardown process') mq_consumer.stop_rpc_server() raise SystemExit(1) LOG.debug('Data queue size = %s', queue.qsize()) LOG.debug('Output queue size = %s', output_queue.qsize()) mq_consumer.stop_rpc_server()
def run_test(self, traffic_profile, tasks_queue, results_queue, *args): # pragma: no cover LOG.info("Ixia resource_helper run_test") if self._terminated.value: return min_tol = self.rfc_helper.tolerance_low max_tol = self.rfc_helper.tolerance_high precision = self.rfc_helper.tolerance_precision resolution = self.rfc_helper.resolution default = "00:00:00:00:00:00" self._build_ports() traffic_profile.update_traffic_profile(self) self._initialize_client(traffic_profile) mac = {} for port_name in self.vnfd_helper.port_pairs.all_ports: intf = self.vnfd_helper.find_interface(name=port_name) virt_intf = intf["virtual-interface"] # we only know static traffic id by reading the json # this is used by _get_ixia_trafficrofile port_num = self.vnfd_helper.port_num(intf) mac["src_mac_{}".format(port_num)] = virt_intf.get( "local_mac", default) mac["dst_mac_{}".format(port_num)] = virt_intf.get( "dst_mac", default) self._ix_scenario.run_protocols() try: completed = False self.rfc_helper.iteration.value = 0 self.client_started.value = 1 while completed is False and not self._terminated.value: LOG.info("Wait for task ...") try: task = tasks_queue.get(True, 5) except moves.queue.Empty: continue else: if task != 'RUN_TRAFFIC': continue self.rfc_helper.iteration.value += 1 LOG.info("Got %s task, start iteration %d", task, self.rfc_helper.iteration.value) first_run = traffic_profile.execute_traffic( self, self.client, mac) # pylint: disable=unnecessary-lambda utils.wait_until_true(lambda: self.client.is_traffic_stopped(), timeout=traffic_profile.config.duration * 2) samples = self.generate_samples( traffic_profile.ports, traffic_profile.config.duration) completed, samples = traffic_profile.get_drop_percentage( samples, min_tol, max_tol, precision, resolution, first_run=first_run) self._queue.put(samples) if completed: LOG.debug("IxiaResourceHelper::run_test - test completed") results_queue.put('COMPLETE') else: results_queue.put('CONTINUE') tasks_queue.task_done() except Exception: # pylint: disable=broad-except LOG.exception('Run Traffic terminated') self._ix_scenario.stop_protocols() self.client_started.value = 0 LOG.debug("IxiaResourceHelper::run_test done")