From 04ecbc54655938241a5e753bdc770d20e1ec5289 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Tue, 3 Jan 2017 15:17:58 +0200 Subject: Stateless API: increase delay in remove rx filters to 100ms in case of virtual NICs. Regression: increase delay in remove rx filters in trex07 to 100ms in test_all_profiles test. Change-Id: Ia7dda25c94aeadcaae0b16023f6ea2957a99906f Signed-off-by: Yaroslav Brustinov --- .../automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py') diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py index 07587b9f..8b6b2e2e 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py @@ -930,7 +930,10 @@ class Port(object): def get_rx_filter_mode (self): return self.__attr['rx_filter_mode'] - + + def is_virtual(self): + return self.info.get('is_virtual') + def is_l3_mode (self): return self.get_layer_cfg()['ipv4']['state'] != 'none' -- cgit 1.2.3-korg From 83861b490b5ce17212830a425d7c8cfd00090c40 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Thu, 12 Jan 2017 16:24:03 +0200 Subject: Add help message for --no-scapy-server flag Python API: fix arp resolve console message Python API: retry ZMQ send/recv only for push_pcap Console: portattr fix for readonly mode Change-Id: I69587987deb4edfbe192ee422ce6aad74b1ecaf3 Signed-off-by: Yaroslav Brustinov --- .../stl/trex_stl_lib/trex_stl_client.py | 31 ++++++++++++---------- .../stl/trex_stl_lib/trex_stl_jsonrpc_client.py | 28 +++++++++---------- .../stl/trex_stl_lib/trex_stl_port.py | 6 ++--- src/main_dpdk.cpp | 1 + 4 files changed, 35 insertions(+), 31 deletions(-) (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py') diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py index e20de3da..21ae42f1 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py @@ -449,16 +449,16 @@ class CCommLink(object): if not self.virtual: return self.rpc_link.disconnect() - def transmit(self, method_name, params = None, api_class = 'core'): + def transmit(self, method_name, params = None, api_class = 'core', retry = 0): if self.virtual: self._prompt_virtual_tx_msg() _, msg = self.rpc_link.create_jsonrpc_v2(method_name, params, api_class) print(msg) return else: - return self.rpc_link.invoke_rpc_method(method_name, params, api_class) + return self.rpc_link.invoke_rpc_method(method_name, params, api_class, retry = retry) - def transmit_batch(self, batch_list): + def transmit_batch(self, batch_list, retry = 0): if self.virtual: self._prompt_virtual_tx_msg() print([msg @@ -469,7 +469,7 @@ class CCommLink(object): for command in batch_list: batch.add(command.method, command.params, command.api_class) # invoke the batch - return batch.invoke() + return batch.invoke(retry = retry) def _prompt_virtual_tx_msg(self): print("Transmitting virtually over tcp://{server}:{port}".format(server=self.server, @@ -2997,7 +2997,7 @@ class STLClient(object): :parameters: ports - for which ports to apply a unique sniffer (each port gets a unique file) - retires - how many times to retry on each port (intervals of 100 milliseconds) + retries - how many times to retry on each port (intervals of 100 milliseconds) verbose - log for each request the response :raises: + :exe:'STLError' @@ -3015,7 +3015,7 @@ class STLClient(object): self.logger.post_cmd(rc) if verbose: - for x in filter(bool, rc.data()): + for x in filter(bool, listify(rc.data())): self.logger.log(format_text("{0}".format(x), 'bold')) if not rc: @@ -3757,7 +3757,7 @@ class STLClient(object): parsing_opts.SUPPORTED, ) - opts = parser.parse_args(line.split(), default_ports = self.get_acquired_ports(), verify_acquired = True) + opts = parser.parse_args(line.split(), default_ports = self.get_acquired_ports()) if not opts: return opts @@ -3767,8 +3767,9 @@ class STLClient(object): opts.flow_ctrl = parsing_opts.FLOW_CTRL_DICT.get(opts.flow_ctrl) # if no attributes - fall back to printing the status - if not list(filter(lambda x:x is not None, [opts.prom, opts.link, opts.led, opts.flow_ctrl, opts.supp])): - self.show_stats_line("--ps --port {0}".format(' '.join(str(port) for port in opts.ports))) + if not list(filter(lambda opt:opt[0] not in ('all_ports', 'ports') and opt[1] is not None, opts._get_kwargs())): + ports = opts.ports if opts.ports else self.get_all_ports() + self.show_stats_line("--ps --port {0}".format(' '.join(str(port) for port in ports))) return if opts.supp: @@ -3781,11 +3782,13 @@ class STLClient(object): print(' Flow control: %s' % info['fc_supported']) print('') else: - self.set_port_attr(opts.ports, - opts.prom, - opts.link, - opts.led, - opts.flow_ctrl) + if not opts.ports: + raise STLError('No acquired ports!') + self.set_port_attr(opts.ports, + opts.prom, + opts.link, + opts.led, + opts.flow_ctrl) diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py index 72c9317a..db216532 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py @@ -32,7 +32,7 @@ class BatchMessage(object): id, msg = self.rpc_client.create_jsonrpc_v2(method_name, params, api_class, encode = False) self.batch_list.append(msg) - def invoke(self, block = False, chunk_size = 500000): + def invoke(self, block = False, chunk_size = 500000, retry = 0): if not self.rpc_client.connected: return RC_ERR("Not connected to server") @@ -54,7 +54,7 @@ class BatchMessage(object): return response_batch else: batch_json = json.dumps(self.batch_list) - return self.rpc_client.send_msg(batch_json) + return self.rpc_client.send_msg(batch_json, retry = retry) # JSON RPC v2.0 client @@ -127,16 +127,16 @@ class JsonRpcClient(object): return id, msg - def invoke_rpc_method (self, method_name, params = None, api_class = 'core'): + def invoke_rpc_method (self, method_name, params = None, api_class = 'core', retry = 0): if not self.connected: return RC_ERR("Not connected to server") id, msg = self.create_jsonrpc_v2(method_name, params, api_class) - return self.send_msg(msg) + return self.send_msg(msg, retry = retry) - def send_msg (self, msg): + def send_msg (self, msg, retry = 0): # print before if self.logger.check_verbose(self.logger.VERBOSE_HIGH): self.verbose_msg("Sending Request To Server:\n\n" + self.pretty_json(msg) + "\n") @@ -145,9 +145,9 @@ class JsonRpcClient(object): buffer = msg.encode() if self.zipper.check_threshold(buffer): - response = self.send_raw_msg(self.zipper.compress(buffer)) + response = self.send_raw_msg(self.zipper.compress(buffer), retry = retry) else: - response = self.send_raw_msg(buffer) + response = self.send_raw_msg(buffer, retry = retry) if not response: return response @@ -175,16 +175,16 @@ class JsonRpcClient(object): # low level send of string message - def send_raw_msg (self, msg): + def send_raw_msg (self, msg, retry = 0): - tries = 0 + retry_left = retry while True: try: self.socket.send(msg) break except zmq.Again: - tries += 1 - if tries > 5: + retry_left -= 1 + if retry_left < 0: self.disconnect() return RC_ERR("*** [RPC] - Failed to send message to server") @@ -193,14 +193,14 @@ class JsonRpcClient(object): self.reconnect() raise e - tries = 0 + retry_left = retry while True: try: response = self.socket.recv() break except zmq.Again: - tries += 1 - if tries > 5: + retry_left -= 1 + if retry_left < 0: self.disconnect() return RC_ERR("*** [RPC] - Failed to get server response from {0}".format(self.transport)) diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py index 8b6b2e2e..a9509ee9 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py @@ -264,7 +264,7 @@ class Port(object): def add_streams (self, streams_list): # listify - streams_list = streams_list if isinstance(streams_list, list) else [streams_list] + streams_list = listify(streams_list) lookup = {} @@ -338,7 +338,7 @@ class Port(object): def remove_streams (self, stream_id_list): # single element to list - stream_id_list = stream_id_list if isinstance(stream_id_list, list) else [stream_id_list] + stream_id_list = listify(stream_id_list) # verify existance if not all([stream_id in self.streams for stream_id in stream_id_list]): @@ -751,7 +751,7 @@ class Port(object): "slave_handler": slave_handler, "min_ipg_usec": min_ipg_usec if min_ipg_usec else 0} - rc = self.transmit("push_remote", params) + rc = self.transmit("push_remote", params, retry = 4) if rc.bad(): return self.err(rc.err()) diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 3149bdb3..aa31cf0b 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -826,6 +826,7 @@ static int usage(){ printf(" --no-flow-control-change : By default TRex disables flow-control. If this option is given, it does not touch it \n"); printf(" --no-key : Daemon mode, don't get input from keyboard \n"); printf(" --no-ofed-check : Disable the check of OFED version \n"); + printf(" --no-scapy-server : Disable Scapy server implicit start at stateless \n"); printf(" --no-watchdog : Disable watchdog \n"); printf(" -p : Send all flow packets from the same interface (choosed randomly between client ad server ports) without changing their src/dst IP \n"); printf(" -pm : Platform factor. If you have splitter in the setup, you can multiply the total results by this factor \n"); -- cgit 1.2.3-korg