diff options
Diffstat (limited to 'resources/libraries/python/TrafficGenerator.py')
-rw-r--r-- | resources/libraries/python/TrafficGenerator.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index 936cb3a06d..ae01f8d3a6 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Cisco and/or its affiliates. +# Copyright (c) 2024 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -284,13 +284,13 @@ class TrafficGenerator(AbstractMeasurer): def initialize_traffic_generator(self, osi_layer, pfs=2): """TG initialization. - :param osi_layer: 'L2', 'L3' or 'L7' - OSI Layer testing type. + :param osi_layer: OSI Layer testing type. :param pfs: Number of physical interfaces to configure. :type osi_layer: str :type pfs: int :raises ValueError: If OSI layer is unknown. """ - if osi_layer not in ("L2", "L3", "L7"): + if osi_layer not in ("L2", "L3", "L3_1", "L7"): raise ValueError("Unknown OSI layer!") topology = BuiltIn().get_variable_value("&{topology_info}") @@ -304,7 +304,9 @@ class TrafficGenerator(AbstractMeasurer): for link in range(1, pfs, 2): tg_if1_adj_addr = topology[f"TG_pf{link+1}_mac"][0] tg_if2_adj_addr = topology[f"TG_pf{link}_mac"][0] - if osi_layer in ("L3", "L7") and "DUT1" in topology.keys(): + skip = 0 if osi_layer in ("L3_1",) else 1 + if osi_layer in ("L3", "L3_1", "L7") and "DUT1" \ + in topology.keys(): ifl = BuiltIn().get_variable_value("${int}") last = topology["duts_count"] tg_if1_adj_addr = Topology().get_interface_mac( @@ -316,7 +318,7 @@ class TrafficGenerator(AbstractMeasurer): tg_if2_adj_addr = Topology().get_interface_mac( topology[f"DUT{last}"], BuiltIn().get_variable_value( - f"${{DUT{last}_{ifl}{link+1}}}[0]" + f"${{DUT{last}_{ifl}{link+skip}}}[0]" ) ) @@ -365,7 +367,7 @@ class TrafficGenerator(AbstractMeasurer): """Startup sequence for the TRex traffic generator. :param tg_node: Traffic generator node. - :param osi_layer: 'L2', 'L3' or 'L7' - OSI Layer testing type. + :param osi_layer: OSI Layer testing type. :param subtype: Traffic generator sub-type. :type tg_node: dict :type osi_layer: str @@ -429,7 +431,7 @@ class TrafficGenerator(AbstractMeasurer): # Test T-Rex API responsiveness. cmd = f"python3 {Constants.REMOTE_FW_DIR}/GPL/tools/trex/" - if osi_layer in ("L2", "L3"): + if osi_layer in ("L2", "L3", "L3_1"): cmd += "trex_stl_assert.py" elif osi_layer == "L7": cmd += "trex_astf_assert.py" @@ -524,7 +526,7 @@ class TrafficGenerator(AbstractMeasurer): command_line.add(f"'{value}'") stdout, _ = exec_cmd_no_error( node, command_line, - message="T-Rex STL runtime error!" + message="T-Rex STL runtime error!", include_reason=True ) self._parse_traffic_results(stdout) @@ -763,7 +765,7 @@ class TrafficGenerator(AbstractMeasurer): self._rate = float(rate[:-3]) if "pps" in rate else float(rate) stdout, _ = exec_cmd_no_error( self._node, command_line, timeout=int(duration) + 60, - message="T-Rex STL runtime error" + message="T-Rex STL runtime error", include_reason=True ) if async_call: |