aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/bash/entry/check/tc_naming.sh4
-rw-r--r--resources/libraries/python/TrafficGenerator.py195
-rw-r--r--resources/libraries/python/autogen/Regenerator.py44
-rw-r--r--resources/libraries/robot/l2/l2_bridge_domain.robot8
-rw-r--r--resources/libraries/robot/performance/performance_limits.robot5
-rw-r--r--resources/libraries/robot/performance/performance_utils.robot143
-rw-r--r--resources/libraries/robot/shared/interfaces.robot127
-rwxr-xr-xresources/tools/trex/trex_stateless_stop.py39
8 files changed, 416 insertions, 149 deletions
diff --git a/resources/libraries/bash/entry/check/tc_naming.sh b/resources/libraries/bash/entry/check/tc_naming.sh
index b8a2775035..b193cfad5e 100644
--- a/resources/libraries/bash/entry/check/tc_naming.sh
+++ b/resources/libraries/bash/entry/check/tc_naming.sh
@@ -66,7 +66,7 @@ r_testc_rules=(
#'(ipsec[[:digit:]]+tnlhw|ipsec[[:digit:]]+tnlsw|'
#'srhip6|tcp|udp|lispip6|lispip4|vxlan){0,1}'
#'(http){0,1}-'
- '(.*)-(dev|ndrpdr|cps|rps)$'
+ '(.*)-(dev|ndrpdr|cps|rps|reconf)$'
)
s_suite_rules=(
'number of SUT nodes'
@@ -85,7 +85,7 @@ r_suite_rules=(
#'(ipsec[[:digit:]]+tnlhw|ipsec[[:digit:]]+tnlsw|'
#'srhip6|tcp|udp|lispip6|lispip4|vxlan){0,1}'
#'(http){0,1}-'
- '(.*)-(dev|ndrpdr|cps|rps)$'
+ '(.*)-(dev|ndrpdr|cps|rps|reconf)$'
)
rm -f "tc_naming.log" || die
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py
index cc968f8e09..2e9b787321 100644
--- a/resources/libraries/python/TrafficGenerator.py
+++ b/resources/libraries/python/TrafficGenerator.py
@@ -13,6 +13,8 @@
"""Performance testing traffic generator library."""
+import time
+
from robot.api import logger
from robot.libraries.BuiltIn import BuiltIn
@@ -30,6 +32,31 @@ from .PLRsearch.PLRsearch import PLRsearch
__all__ = ['TGDropRateSearchImpl', 'TrafficGenerator', 'OptimizedSearch']
+def check_subtype(node):
+ """Return supported subtype of given node, or raise an exception.
+
+ Currently only one subtype is supported,
+ but we want our code to be ready for other ones.
+
+ :param node: Topology node to check. Can be None.
+ :type node: dict or NoneType
+ :returns: Subtype detected.
+ :rtype: NodeSubTypeTG
+ :raises RuntimeError: If node is not supported, message explains how.
+ """
+ if node.get('type') is None:
+ raise RuntimeError('Node type is not defined')
+ elif node['type'] != NodeType.TG:
+ raise RuntimeError('Node type is {typ!r}, not a TG'.format(
+ typ=node['type']))
+ elif node.get('subtype') is None:
+ raise RuntimeError('TG subtype is not defined')
+ elif node['subtype'] == NodeSubTypeTG.TREX:
+ return NodeSubTypeTG.TREX
+ raise RuntimeError('TG subtype {sub!r} is not supported'.format(
+ sub=node['subtype']))
+
+
class TGDropRateSearchImpl(DropRateSearch):
"""Drop Rate Search implementation."""
@@ -62,34 +89,23 @@ class TGDropRateSearchImpl(DropRateSearch):
# to be able to use trex_stl-*()
tg_instance = BuiltIn().get_library_instance(
'resources.libraries.python.TrafficGenerator')
-
- if tg_instance.node['subtype'] is None:
- raise RuntimeError('TG subtype not defined')
- elif tg_instance.node['subtype'] == NodeSubTypeTG.TREX:
+ subtype = check_subtype(tg_instance.node)
+ if subtype == NodeSubTypeTG.TREX:
unit_rate = str(rate) + self.get_rate_type_str()
if skip_warmup:
- tg_instance.trex_stl_start_remote_exec(self.get_duration(),
- unit_rate, frame_size,
- traffic_profile,
- warmup_time=0.0)
+ tg_instance.trex_stl_start_remote_exec(
+ self.get_duration(), unit_rate, frame_size, traffic_profile,
+ warmup_time=0.0)
else:
- tg_instance.trex_stl_start_remote_exec(self.get_duration(),
- unit_rate, frame_size,
- traffic_profile)
+ tg_instance.trex_stl_start_remote_exec(
+ self.get_duration(), unit_rate, frame_size, traffic_profile)
loss = tg_instance.get_loss()
sent = tg_instance.get_sent()
if self.loss_acceptance_type_is_percentage():
loss = (float(loss) / float(sent)) * 100
-
- logger.trace("comparing: {} < {} {}".format(loss,
- loss_acceptance,
- loss_acceptance_type))
- if float(loss) > float(loss_acceptance):
- return False
- else:
- return True
- else:
- raise NotImplementedError("TG subtype not supported")
+ logger.trace("comparing: {los} < {acc} {typ}".format(
+ los=loss, acc=loss_acceptance, typ=loss_acceptance_type))
+ return float(loss) <= float(loss_acceptance)
def get_latency(self):
"""Returns min/avg/max latency.
@@ -114,15 +130,20 @@ class TrafficGenerator(AbstractMeasurer):
ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
def __init__(self):
+ # TODO: Number of fields will be reduced with CSIT-1378.
+ self._node = None
+ # T-REX interface order mapping
+ self._ifaces_reordered = False
+ # Result holding fields, to be removed.
self._result = None
self._loss = None
self._sent = None
self._latency = None
self._received = None
- self._node = None
- # T-REX interface order mapping
- self._ifaces_reordered = False
- # Parameters not given by measure().
+ # Measurement input fields, needed for async stop result.
+ self._start_time = None
+ self._rate = None
+ # Other input parameters, not knowable from measure() signature.
self.frame_size = None
self.traffic_profile = None
self.warmup_time = None
@@ -199,11 +220,10 @@ class TrafficGenerator(AbstractMeasurer):
:returns: nothing
:raises RuntimeError: In case of issue during initialization.
"""
- if tg_node['type'] != NodeType.TG:
- raise RuntimeError('Node type is not a TG')
- self._node = tg_node
+ subtype = check_subtype(tg_node)
+ if subtype == NodeSubTypeTG.TREX:
+ self._node = tg_node
- if self._node['subtype'] == NodeSubTypeTG.TREX:
ssh = SSH()
ssh.connect(self._node)
@@ -293,9 +313,7 @@ class TrafficGenerator(AbstractMeasurer):
:type osi_layer: str
:raises RuntimeError: If node subtype is not a TREX or startup failed.
"""
- if self._node['subtype'] != NodeSubTypeTG.TREX:
- raise RuntimeError('Node subtype is not a TREX!')
-
+ # No need to check subtype, we know it is TREX.
for _ in range(0, 3):
# Kill TRex only if it is already running.
cmd = "sh -c 'pgrep t-rex && pkill t-rex && sleep 3 || true'"
@@ -357,8 +375,7 @@ class TrafficGenerator(AbstractMeasurer):
:rtype: bool
:raises RuntimeError: If node type is not a TG.
"""
- if node['type'] != NodeType.TG:
- raise RuntimeError('Node type is not a TG')
+ # No need to check subtype, we know it is TREX.
ssh = SSH()
ssh.connect(node)
@@ -375,9 +392,8 @@ class TrafficGenerator(AbstractMeasurer):
:raises RuntimeError: If node type is not a TG,
or if TRex teardown fails.
"""
- if node['type'] != NodeType.TG:
- raise RuntimeError('Node type is not a TG')
- if node['subtype'] == NodeSubTypeTG.TREX:
+ subtype = check_subtype(node)
+ if subtype == NodeSubTypeTG.TREX:
ssh = SSH()
ssh.connect(node)
(ret, _, _) = ssh.exec_command(
@@ -385,25 +401,49 @@ class TrafficGenerator(AbstractMeasurer):
if int(ret) != 0:
raise RuntimeError('pkill t-rex failed')
- @staticmethod
- def trex_stl_stop_remote_exec(node):
+ def _parse_traffic_results(self, stdout):
+ """Parse stdout of scripts into fieds of self.
+
+ Block of code to reuse, by sync start, or stop after async.
+ TODO: Is the output TG subtype dependent?
+
+ :param stdout: Text containing the standard output.
+ :type stdout: str
+ """
+ # last line from console output
+ line = stdout.splitlines()[-1]
+ self._result = line
+ logger.info('TrafficGen result: {0}'.format(self._result))
+ self._received = self._result.split(', ')[1].split('=')[1]
+ self._sent = self._result.split(', ')[2].split('=')[1]
+ self._loss = self._result.split(', ')[3].split('=')[1]
+ self._latency = []
+ self._latency.append(self._result.split(', ')[4].split('=')[1])
+ self._latency.append(self._result.split(', ')[5].split('=')[1])
+
+ def trex_stl_stop_remote_exec(self, node):
"""Execute script on remote node over ssh to stop running traffic.
+ Internal state is updated with results.
+
:param node: TRex generator node.
:type node: dict
:returns: Nothing
:raises RuntimeError: If stop traffic script fails.
"""
+ # No need to check subtype, we know it is TREX.
ssh = SSH()
ssh.connect(node)
- (ret, _, _) = ssh.exec_command(
+ (ret, stdout, _) = ssh.exec_command(
"sh -c '{}/resources/tools/trex/"
"trex_stateless_stop.py'".format(Constants.REMOTE_FW_DIR))
if int(ret) != 0:
raise RuntimeError('TRex stateless runtime error')
+ self._parse_traffic_results(stdout)
+
def trex_stl_start_remote_exec(
self, duration, rate, frame_size, traffic_profile, async_call=False,
latency=True, warmup_time=5.0, unidirection=False, tx_port=0,
@@ -435,6 +475,7 @@ class TrafficGenerator(AbstractMeasurer):
:type rx_port: int
:raises RuntimeError: In case of TG driver issue.
"""
+ # No need to check subtype, we know it is TREX.
ssh = SSH()
ssh.connect(self._node)
reorder = self._ifaces_reordered # Just to make the next line fit.
@@ -471,21 +512,16 @@ class TrafficGenerator(AbstractMeasurer):
raise RuntimeError('TRex stateless runtime error')
elif async_call:
#no result
+ self._start_time = time.time()
+ self._rate = float(rate[:-3]) if "pps" in rate else rate
self._received = None
self._sent = None
self._loss = None
self._latency = None
else:
- # last line from console output
- line = stdout.splitlines()[-1]
- self._result = line
- logger.info('TrafficGen result: {0}'.format(self._result))
- self._received = self._result.split(', ')[1].split('=')[1]
- self._sent = self._result.split(', ')[2].split('=')[1]
- self._loss = self._result.split(', ')[3].split('=')[1]
- self._latency = []
- self._latency.append(self._result.split(', ')[4].split('=')[1])
- self._latency.append(self._result.split(', ')[5].split('=')[1])
+ self._parse_traffic_results(stdout)
+ self._start_time = None
+ self._rate = None
def stop_traffic_on_tg(self):
"""Stop all traffic on TG.
@@ -493,9 +529,8 @@ class TrafficGenerator(AbstractMeasurer):
:returns: Nothing
:raises RuntimeError: If TG is not set.
"""
- if self._node is None:
- raise RuntimeError("TG is not set")
- if self._node['subtype'] == NodeSubTypeTG.TREX:
+ subtype = check_subtype(self._node)
+ if subtype == NodeSubTypeTG.TREX:
self.trex_stl_stop_remote_exec(self._node)
def send_traffic_on_tg(
@@ -547,22 +582,11 @@ class TrafficGenerator(AbstractMeasurer):
or if subtype is not specified.
:raises NotImplementedError: If TG is not supported.
"""
-
- node = self._node
- if node is None:
- raise RuntimeError("TG is not set")
-
- if node['type'] != NodeType.TG:
- raise RuntimeError('Node type is not a TG')
-
- if node['subtype'] is None:
- raise RuntimeError('TG subtype not defined')
- elif node['subtype'] == NodeSubTypeTG.TREX:
+ subtype = check_subtype(self._node)
+ if subtype == NodeSubTypeTG.TREX:
self.trex_stl_start_remote_exec(
duration, rate, frame_size, traffic_profile, async_call,
latency, warmup_time, unidirection, tx_port, rx_port)
- else:
- raise NotImplementedError("TG subtype not supported")
return self._result
@@ -629,6 +653,36 @@ class TrafficGenerator(AbstractMeasurer):
self.traffic_profile = str(traffic_profile)
self.warmup_time = float(warmup_time)
+ def get_measurement_result(self, duration=None, transmit_rate=None):
+ """Return the result of last measurement as ReceiveRateMeasurement.
+
+ Separate function, as measurements can end either by time
+ or by explicit call, this is the common block at the end.
+
+ TODO: Fail on running or already reported measurement.
+
+ :param duration: Measurement duration [s] if known beforehand.
+ For explicitly stopped measurement it is estimated.
+ :param transmit_rate: Target aggregate transmit rate [pps].
+ If not given, computed assuming it was bidirectional.
+ :type duration: float or NoneType
+ :type transmit_rate: float or NoneType
+ :returns: Structure containing the result of the measurement.
+ :rtype: ReceiveRateMeasurement
+ """
+ if duration is None:
+ duration = time.time() - self._start_time
+ self._start_time = None
+ if transmit_rate is None:
+ # Assuming bi-directional traffic here.
+ transmit_rate = self._rate * 2.0
+ transmit_count = int(self.get_sent())
+ loss_count = int(self.get_loss())
+ measurement = ReceiveRateMeasurement(
+ duration, transmit_rate, transmit_count, loss_count)
+ measurement.latency = self.get_latency_int()
+ return measurement
+
def measure(self, duration, transmit_rate):
"""Run bi-directional measurement, parse and return results.
@@ -644,17 +698,12 @@ class TrafficGenerator(AbstractMeasurer):
"""
duration = float(duration)
transmit_rate = float(transmit_rate)
- # Trex needs target Tr per stream, but reports aggregate Tx and Dx.
+ # TG needs target Tr per stream, but reports aggregate Tx and Dx.
unit_rate = str(transmit_rate / 2.0) + "pps"
self.send_traffic_on_tg(
duration, unit_rate, self.frame_size, self.traffic_profile,
warmup_time=self.warmup_time, latency=True)
- transmit_count = int(self.get_sent())
- loss_count = int(self.get_loss())
- measurement = ReceiveRateMeasurement(
- duration, transmit_rate, transmit_count, loss_count)
- measurement.latency = self.get_latency_int()
- return measurement
+ return self.get_measurement_result(duration, transmit_rate)
class OptimizedSearch(object):
diff --git a/resources/libraries/python/autogen/Regenerator.py b/resources/libraries/python/autogen/Regenerator.py
index a9f3ef433d..778ced76c9 100644
--- a/resources/libraries/python/autogen/Regenerator.py
+++ b/resources/libraries/python/autogen/Regenerator.py
@@ -207,8 +207,48 @@ def write_default_files(in_filename, in_prolog, kwargs_list):
testcase, iface, suite_id, file_out, kwargs_list)
+def write_reconf_files(in_filename, in_prolog, kwargs_list):
+ """Using given filename and prolog, write all generated reconf suites.
+
+ Use this for suite type reconf, as its local template
+ is incompatible with mrr/ndrpdr/soak local template,
+ while test cases are compatible.
+
+ :param in_filename: Template filename to derive real filenames from.
+ :param in_prolog: Template content to derive real content from.
+ :param kwargs_list: List of kwargs for add_testcase.
+ :type in_filename: str
+ :type in_prolog: str
+ :type kwargs_list: list of dict
+ """
+ _, suite_id = get_iface_and_suite_id(in_filename)
+ testcase = Testcase.default(suite_id)
+ for nic_name in Constants.NIC_NAME_TO_CODE:
+ out_filename = replace_defensively(
+ in_filename, "10ge2p1x710",
+ Constants.NIC_NAME_TO_CODE[nic_name], 1,
+ "File name should contain NIC code once.", in_filename)
+ out_prolog = replace_defensively(
+ in_prolog, "Intel-X710", nic_name, 2,
+ "NIC name should appear twice (tag and variable).",
+ in_filename)
+ if out_prolog.count("HW_") == 2:
+ # TODO CSIT-1481: Crypto HW should be read
+ # from topology file instead.
+ if nic_name in Constants.NIC_NAME_TO_CRYPTO_HW.keys():
+ out_prolog = replace_defensively(
+ out_prolog, "HW_DH895xcc",
+ Constants.NIC_NAME_TO_CRYPTO_HW[nic_name], 1,
+ "HW crypto name should appear.", in_filename)
+ iface, suite_id = get_iface_and_suite_id(out_filename)
+ with open(out_filename, "w") as file_out:
+ file_out.write(out_prolog)
+ add_default_testcases(
+ testcase, iface, suite_id, file_out, kwargs_list)
+
+
def write_tcp_files(in_filename, in_prolog, kwargs_list):
- """Using given filename and prolog, write all generated suites.
+ """Using given filename and prolog, write all generated tcp suites.
:param in_filename: Template filename to derive real filenames from.
:param in_prolog: Template content to derive real content from.
@@ -293,6 +333,8 @@ class Regenerator(object):
file_in.read().partition("*** Test Cases ***")[:-1])
if in_filename.endswith("-ndrpdr.robot"):
write_default_files(in_filename, in_prolog, default_kwargs_list)
+ elif in_filename.endswith("-reconf.robot"):
+ write_reconf_files(in_filename, in_prolog, default_kwargs_list)
elif in_filename[-10:] in ("-cps.robot", "-rps.robot"):
write_tcp_files(in_filename, in_prolog, tcp_kwargs_list)
else:
diff --git a/resources/libraries/robot/l2/l2_bridge_domain.robot b/resources/libraries/robot/l2/l2_bridge_domain.robot
index e15f8b4338..6c16ed447f 100644
--- a/resources/libraries/robot/l2/l2_bridge_domain.robot
+++ b/resources/libraries/robot/l2/l2_bridge_domain.robot
@@ -186,16 +186,18 @@
| | ... | *Arguments:*
| | ... | - nf_chains - Number of chains of NFs. Type: integer
| | ... | - nf_nodes - Number of NFs nodes per chain. Type: integer
+| | ... | - start - Id of first chain, allows to add chains during test.
+| | ... | Type: integer
| | ...
| | ... | *Example:*
| | ...
| | ... | \| Initialize L2 bridge domains for multiple chains with Vhost-User \
-| | ... | \| 1 \| 1 \|
+| | ... | \| 3 \| 1 \| 2 \|
| | ...
-| | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1}
+| | [Arguments] | ${nf_chains}=${1} | ${nf_nodes}=${1} | ${start}=${1}
| | ...
| | Set interfaces in path up
-| | :FOR | ${nf_chain} | IN RANGE | 1 | ${nf_chains} + 1
+| | :FOR | ${nf_chain} | IN RANGE | ${start} | ${nf_chains} + 1
| | | Initialize L2 bridge domains with Vhost-User
| | | ... | nf_chain=${nf_chain} | nf_nodes=${nf_nodes}
diff --git a/resources/libraries/robot/performance/performance_limits.robot b/resources/libraries/robot/performance/performance_limits.robot
index 759ee5c28f..67ef3cf5b0 100644
--- a/resources/libraries/robot/performance/performance_limits.robot
+++ b/resources/libraries/robot/performance/performance_limits.robot
@@ -75,6 +75,11 @@
| | ... | \| Set test Variable \| \${frame_size} \| IMIX_v4_1 \|
| | ... | \| Set Max Rate And Jumbo \|
| | ...
+| | # Negative overhead is possible, if DUT-DUT traffic is less encapsulated
+| | # than TG-DUT traffic.
+| | # TODO: Re-check overhead values in suites with both traffics encapsulated.
+| | # TODO: Improve layered setup to detect encap/decap and update overhead.
+| | ${overhead} = | Set Variable If | ${overhead} >= 0 | ${overhead} | ${0}
| | ${pps_limit} = | Set Variable | ${18750000.0}
| | ${bps_limit} = | Get From Dictionary | ${NIC_NAME_TO_LIMIT} | ${nic_name}
| | ${avg_size} = | Get Average Frame Size | ${frame_size}
diff --git a/resources/libraries/robot/performance/performance_utils.robot b/resources/libraries/robot/performance/performance_utils.robot
index 54b20cba2d..d809376c0f 100644
--- a/resources/libraries/robot/performance/performance_utils.robot
+++ b/resources/libraries/robot/performance/performance_utils.robot
@@ -32,7 +32,7 @@
| | [Documentation]
| | ... | Find boundaries for RFC2544 compatible NDR and PDR values
| | ... | using an optimized search algorithm.
-| | ... | Display results as formatted test message.
+| | ... | Display findings as a formatted test message.
| | ... | Fail if a resulting lower bound has too high loss fraction.
| | ... | Input rates are understood as uni-directional,
| | ... | reported result contains bi-directional rates.
@@ -61,7 +61,7 @@
| | ...
| | ... | *Example:*
| | ...
-| | ... | \| Find NDR and PDR intervals using optimized search \| \${0.005}
+| | ... | \| Find NDR and PDR intervals using optimized search \| \${0.005} \
| | ... | \| \${0.005} \| \${30.0} \| \${1.0} \| \${2} \| ${600.0} \| ${2} \|
| | ...
| | [Arguments] | ${packet_loss_ratio}=${0.005}
@@ -76,13 +76,83 @@
| | ... | ${final_trial_duration} | ${initial_trial_duration}
| | ... | ${number_of_intermediate_phases} | timeout=${timeout}
| | ... | doublings=${doublings}
-| | Display result of NDRPDR search | ${result} | ${frame_size}
+| | Display result of NDRPDR search | ${result}
| | Check NDRPDR interval validity | ${result.pdr_interval}
| | ... | ${packet_loss_ratio}
| | Check NDRPDR interval validity | ${result.ndr_interval}
| | Perform additional measurements based on NDRPDR result
| | ... | ${result} | ${frame_size} | ${traffic_profile}
+| Display Reconfig Test Message
+| | [Documentation]
+| | ... | Display the number of packets lost (bidirectionally)
+| | ... | due to reconfiguration under traffic.
+| | ...
+| | ... | *Arguments:*
+| | ... | - result - Result of bidirectional measurtement.
+| | ... | Type: ReceiveRateMeasurement
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Display Reconfig Test Message \| \${result} \|
+| | ...
+| | [Arguments] | ${result}
+| | ...
+| | Set Test Message | Packets lost due to reconfig: ${result.loss_count}
+| | ${time_lost} = | Evaluate | ${result.loss_count} / ${result.target_tr}
+| | Set Test Message | ${\n}Implied time lost: ${time_lost} | append=yes
+
+| Find Throughput Using MLRsearch
+| | [Documentation]
+| | ... | Find and return lower bound PDR (zero PLR by default)
+| | ... | bi-directional throughput using MLRsearch algorithm.
+| | ... | Input rates are understood as uni-directional,
+| | ... | reported result contains bi-directional rates.
+| | ... | Currently, the min_rate value is hardcoded to match test teardowns.
+| | ...
+| | ... | TODO: Should the trial duration of the additional
+| | ... | measurements be configurable?
+| | ...
+| | ... | Some inputs are read from variables to streamline suites.
+| | ...
+| | ... | *Test (or broader scope) variables read:*
+| | ... | - traffic_profile - Name of module defining traffc for measurements.
+| | ... | Type: string
+| | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
+| | ... | - max_rate - Calculated unidirectional maximal transmit rate [pps].
+| | ... | Type: float
+| | ...
+| | ... | *Arguments:*
+| | ... | - packet_loss_ratio - Accepted loss during search. Type: float
+| | ... | - final_relative_width - Maximal width multiple of upper. Type: float
+| | ... | - final_trial_duration - Duration of final trials [s]. Type: float
+| | ... | - initial_trial_duration - Duration of initial trials [s]. Type: float
+| | ... | - intermediate phases - Number of intermediate phases [1]. Type: int
+| | ... | - timeout - Fail if search duration is longer [s]. Type: float
+| | ... | - doublings - How many doublings to do when expanding [1]. Type: int
+| | ...
+| | ... | *Returns:*
+| | ... | - Lower bound for bi-directional throughput at given PLR. Type: float
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| \${throughpt}= \| Find Throughput Using MLRsearch \| \${0} \
+| | ... | \| \${0.001} \| \${10.0}\| \${1.0} \| \${1} \| ${720.0} \| ${2} \|
+| | ...
+| | [Arguments] | ${packet_loss_ratio}=${0.0}
+| | ... | ${final_relative_width}=${0.001} | ${final_trial_duration}=${10.0}
+| | ... | ${initial_trial_duration}=${1.0}
+| | ... | ${number_of_intermediate_phases}=${1} | ${timeout}=${720.0}
+| | ... | ${doublings}=${2}
+| | ...
+| | ${result} = | Perform optimized ndrpdr search | ${frame_size}
+| | ... | ${traffic_profile} | ${20000} | ${max_rate*2}
+| | ... | ${packet_loss_ratio} | ${final_relative_width}
+| | ... | ${final_trial_duration} | ${initial_trial_duration}
+| | ... | ${number_of_intermediate_phases} | timeout=${timeout}
+| | ... | doublings=${doublings}
+| | Return From Keyword | ${result.pdr_interval.measured_low.transmit_rate}
+
| Find critical load using PLRsearch
| | [Documentation]
| | ... | Find boundaries for troughput (of given target loss ratio)
@@ -116,7 +186,7 @@
| | ... | ${traffic_profile} | ${min_rate} | ${max_rate*2}
| | ... | ${packet_loss_ratio} | timeout=${timeout}
| | ${lower} | ${upper} = | Display result of soak search
-| | ... | ${average} | ${stdev} | ${frame_size}
+| | ... | ${average} | ${stdev}
| | Should Not Be True | ${lower} < ${min_rate}
| | ... | Lower bound ${lower} is below bidirectional minimum ${min_rate}.
@@ -162,15 +232,16 @@
| | ... | (Throughput * (L2 Frame Size + IPG) * 8) / Max bitrate of NIC
| | ... | The given result should contain latency data as well.
| | ...
+| | ... | *Test (or broader scope) variables read:*
+| | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
| | ... | *Arguments:*
| | ... | - result - Measured result data per stream [pps]. Type: NdrPdrResult
-| | ... | - frame_size - L2 Frame Size [B]. Type: integer
| | ...
| | ... | *Example:*
| | ...
-| | ... | \| Display result of NDRPDR search \| \${result} \| \${64} \|
+| | ... | \| Display result of NDRPDR search \| \${result} \|
| | ...
-| | [Arguments] | ${result} | ${frame_size}
+| | [Arguments] | ${result}
| | ...
| | ${frame_size} = | Get Average Frame Size | ${frame_size}
| | Display single bound | NDR_LOWER
@@ -196,19 +267,20 @@
| | ... | TODO: Do we want to report some latency data,
| | ... | even if not measured at the reported bounds?.
| | ...
+| | ... | *Test (or broader scope) variables read:*
+| | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
| | ... | *Arguments:*
| | ... | - avg - Estimated average critical load [pps]. Type: float
| | ... | - stdev - Standard deviation of critical load [pps]. Type: float
-| | ... | - frame_size - L2 Frame Size [B]. Type: integer
| | ...
| | ... | *Returns:*
| | ... | - Lower and upper bound of critical load [pps]. Type: 2-tuple of float
| | ...
| | ... | *Example:*
| | ...
-| | ... | \| Display result of soak search \| \${100000} \| \${100} \| \${64} \|
+| | ... | \| Display result of soak search \| \${100000} \| \${100} \|
| | ...
-| | [Arguments] | ${avg} | ${stdev} | ${frame_size}
+| | [Arguments] | ${avg} | ${stdev}
| | ...
| | ${frame_size} = | Get Average Frame Size | ${frame_size}
| | ${avg} = | Convert To Number | ${avg}
@@ -321,7 +393,7 @@
| | ...
| | ... | *Example:*
| | ...
-| | ... | \| Traffic should pass with maximum rate \| ${1} \| ${10.0} \|
+| | ... | \| Traffic should pass with maximum rate \| ${1} \| ${10.0} \
| | ... | \| ${False} \| ${False} \| ${0} \| ${1} \|
| | ...
| | [Arguments] | ${trial_duration}=${perf_trial_duration}
@@ -399,7 +471,7 @@
| | ...
| | ... | *Arguments:*
| | ... | - duration - Duration of traffic run [s]. Type: integer
-| | ... | - rate - Rate for sending packets. Type: string
+| | ... | - rate - Unidirectional rate for sending packets. Type: string
| | ... | - frame_size - L2 Frame Size [B] or IMIX_v4_1. Type: integer/string
| | ... | - traffic_profile - Name of module defining traffc for measurements.
| | ... | Type: string
@@ -425,3 +497,50 @@
| | Run Keyword If | ${dut_stats}==${True}
| | ... | Show runtime counters on all DUTs | ${nodes}
| | Stop traffic on tg
+
+| Start Traffic on Background
+| | [Documentation]
+| | ... | Start traffic at specified rate then return control to Robot.
+| | ... | Useful if the test needs to do something while traffic is running.
+| | ... | Just a wrapper around L1 keyword.
+| | ... |
+| | ... | TODO: How to make sure the traffic is stopped on any failure?
+| | ...
+| | ... | *Test (or broader scope) variables read:*
+| | ... | - traffic_profile - Name of module defining traffc for measurements.
+| | ... | Type: string
+| | ... | - frame_size - L2 Frame Size [B] or IMIX string. Type: int or str
+| | ... | *Arguments:*
+| | ... | - rate - Unidirectional rate for sending packets. Type: string
+| | ... | - unidirection - False if traffic is bidirectional. Type: boolean
+| | ... | - tx_port - TX port of TG, default 0. Type: integer
+| | ... | - rx_port - RX port of TG, default 1. Type: integer
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Start Traffic on Background \| 4.0mpps \| ${False} \| ${0} \
+| | ... | \| ${1} \|
+| | ...
+| | [Arguments] | ${rate} | ${unidirection}=${False} | ${tx_port}=${0}
+| | ... | ${rx_port}=${1}
+| | ...
+| | # Duration of -1 means we will stop traffic manually.
+| | Send traffic on tg | ${-1} | ${rate} | ${frame_size} | ${traffic_profile}
+| | ... | warmup_time=${0} | async_call=${True} | latency=${False}
+| | ... | unidirection=${unidirection} | tx_port=${tx_port} | rx_port=${rx_port}
+
+| Stop Running Traffic
+| | [Documentation]
+| | ... | Stop the running traffic, return measurement result.
+| | ... | For bidirectional traffic, the reported values are bi-directional.
+| | ... | Just a wrapper around L1 keyword.
+| | ... |
+| | ... | TODO: Tolerate if traffic was not started.
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \${result}= \| Stop Running Traffic \|
+| | ...
+| | Stop traffic on tg
+| | ${result}= | Get Measurement Result
+| | Return From Keyword | ${result}
diff --git a/resources/libraries/robot/shared/interfaces.robot b/resources/libraries/robot/shared/interfaces.robot
index 55d0a3d844..f3fb3decd5 100644
--- a/resources/libraries/robot/shared/interfaces.robot
+++ b/resources/libraries/robot/shared/interfaces.robot
@@ -233,53 +233,82 @@
| | | ... | count=${count}
| | Set Test Variable | ${prev_layer} | bond
+| Initialize layer dot1q on node for chain
+| | [Documentation]
+| | ... | Optionally create tag popping subinterface per chain.
+| | ... | Return interface indices for dot1q layer interfaces,
+| | ... | or Nones if subinterfaces are not created.
+| | ...
+| | ... | *Arguments:*
+| | ... | - dut - DUT node. Type: string
+| | ... | - id - Positive index of the chain. Type: integer
+| | ... | - vlan_per_chain - Whether to create vlan subinterface for each chain.
+| | ... | Type: boolean
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Initialize layer dot1q on node for chain \| DUT1 \| 1 \| True \|
+| | ...
+| | [Arguments] | ${dut} | ${id} | ${vlan_per_chain}=${True}
+| | ...
+| | ${dut_str}= | Convert To Lowercase | ${dut}
+| | Return From Keyword If | ${id} != ${1} and not ${vlan_per_chain}
+| | ... | ${NONE} | ${NONE}
+| | # TODO: Is it worth creating Get Variable Value If Not None keyword?
+| | ${default}= | Evaluate | ${100} + ${id} - ${1}
+| | ${if1_vlan}= | Get Variable Value | \${${dut_str}_vlan1}
+| | ${if1_vlan}= | Set Variable If | '${if1_vlan}' != '${NONE}'
+| | ... | ${if1_vlan} | ${default}
+| | ${default}= | Evaluate | ${200} + ${id} - ${1}
+| | ${if2_vlan}= | Get Variable Value | \${${dut_str}_vlan2}
+| | ${if2_vlan}= | Set Variable If | '${if2_vlan}' != '${NONE}'
+| | ... | ${if2_vlan} | ${default}
+| | ${if1_name} | ${if1_index}= | Create Vlan Subinterface
+| | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
+| | ... | ${if1_vlan}
+| | ${if2_name} | ${if2_index}= | Create Vlan Subinterface
+| | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
+| | ... | ${if2_vlan}
+| | Set Interface State | ${nodes['${dut}']} | ${if1_index} | up
+| | Set Interface State | ${nodes['${dut}']} | ${if2_index} | up
+| | Configure L2 tag rewrite method on interfaces
+| | ... | ${nodes['${dut}']} | ${if1_index} | TAG_REWRITE_METHOD=pop-1
+| | Configure L2 tag rewrite method on interfaces
+| | ... | ${nodes['${dut}']} | ${if2_index} | TAG_REWRITE_METHOD=pop-1
+| | Return From Keyword | ${if1_index} | ${if2_index}
+
| Initialize layer dot1q on node
| | [Documentation]
| | ... | Dot1q interfaces and variables to be created on all DUT's node
| | ... | interfaces.
| | ...
+| | ... | TODO: Unify names for number of chains/pipelines/instances/interfaces.
+| | ... | Chose names and descriptions that makes sense for both
+| | ... | nf_density and older tests.
+| | ... | Note that with vlan_per_chain=False it is not a number of interfaces.
+| | ... | At least not number of real interfaces, just number of aliases.
+| | ... | This TODO applies also to all keywords with nf_chains argument.
+| | ...
| | ... | *Arguments:*
| | ... | - dut - DUT node. Type: string
-| | ... | - count - Number of tagged interfaces. Type: integer
-| | ... | - create - Whether to create vlan subinterface for each chain.
+| | ... | - count - Number of chains. Type: integer
+| | ... | - vlan_per_chain - Whether to create vlan subinterface for each chain.
| | ... | Type: boolean
+| | ... | - start - Id of first chain, allows adding chains during test.
+| | ... | Type: integer
| | ...
| | ... | *Example:*
| | ...
-| | ... | \| Initialize layer dot1q on node \| DUT1 \| 1 \| True \|
+| | ... | \| Initialize layer dot1q on node \| DUT1 \| 3 \| True \| 2 \|
| | ...
-| | [Arguments] | ${dut} | ${count}=${1} | ${create}=${True}
+| | [Arguments] | ${dut} | ${count}=${1} | ${vlan_per_chain}=${True}
+| | ... | ${start}=${1}
| | ...
| | ${dut_str}= | Convert To Lowercase | ${dut}
-| | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
-| | | ${if1_vlan}= | Get Variable Value | \${${dut_str}_vlan1}
-| | | ${default}= | Evaluate | ${100} + ${id} - ${1}
-| | | ${if1_vlan}= | Set Variable If | '${if1_vlan}' == '${NONE}'
-| | | ... | ${default} | ${if1_vlan}
-| | | ${if2_vlan}= | Get Variable Value | \${${dut_str}_vlan2}
-| | | ${default}= | Evaluate | ${200} + ${id} - ${1}
-| | | ${if2_vlan}= | Set Variable If | '${if2_vlan}' == '${NONE}'
-| | | ... | ${default} | ${if2_vlan}
-| | | ${if1_name} | ${if1_index}= | Run Keyword If
-| | | ... | ${create} or ${id} == ${1}
-| | | ... | Create Vlan Subinterface
-| | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_1}
-| | | ... | ${if1_vlan}
-| | | ${if2_name} | ${if2_index}= | Run Keyword If
-| | | ... | ${create} or ${id} == ${1}
-| | | ... | Create Vlan Subinterface
-| | | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_${id}_2}
-| | | ... | ${if2_vlan}
-| | | Run Keyword If | ${create} or ${id} == ${1}
-| | | ... | Set Interface State | ${nodes['${dut}']} | ${if1_index} | up
-| | | Run Keyword If | ${create} or ${id} == ${1}
-| | | ... | Set Interface State | ${nodes['${dut}']} | ${if2_index} | up
-| | | Run Keyword If | ${create} or ${id} == ${1}
-| | | ... | Configure L2 tag rewrite method on interfaces
-| | | ... | ${nodes['${dut}']} | ${if1_index} | TAG_REWRITE_METHOD=pop-1
-| | | Run Keyword If | ${create} or ${id} == ${1}
-| | | ... | Configure L2 tag rewrite method on interfaces
-| | | ... | ${nodes['${dut}']} | ${if2_index} | TAG_REWRITE_METHOD=pop-1
+| | :FOR | ${id} | IN RANGE | ${start} | ${count} + 1
+| | | ${if1_index} | ${if2_index}= | Initialize layer dot1q on node for chain
+| | | ... | dut=${dut} | id=${id} | vlan_per_chain=${vlan_per_chain}
+| | | # First id results in non-None indices, after that _1_ are defined.
| | | ${if1_index}= | Set Variable If | '${if1_index}' == '${NONE}'
| | | ... | ${${dut_str}_dot1q_1_1} | ${if1_index}
| | | ${if2_index}= | Set Variable If | '${if2_index}' == '${NONE}'
@@ -292,16 +321,19 @@
| | ... | Dot1q interfaces and variables to be created on all DUT's interfaces.
| | ...
| | ... | *Arguments:*
-| | ... | - count - Number of tagged interfaces. Type: integer
-| | ... | - create - Whether to create vlan for each chain. Type: boolean
+| | ... | - count - Number of chains. Type: integer
+| | ... | - vlan_per_chain - Whether to create vlan subinterface for each chain.
+| | ... | Type: boolean
+| | ... | - start - Id of first chain, allows adding chains during test.
+| | ... | Type: integer
| | ...
-| | ... | \| Initialize layer dot1q \| 1 \| True \|
+| | ... | \| Initialize layer dot1q \| 3 \| True \| 2 \|
| | ...
-| | [Arguments] | ${count}=${1} | ${create}=${True}
+| | [Arguments] | ${count}=${1} | ${vlan_per_chain}=${True} | ${start}=${1}
| | ...
| | :FOR | ${dut} | IN | @{duts}
| | | Initialize layer dot1q on node | ${dut} | count=${count}
-| | | ... | create=${create}
+| | | ... | vlan_per_chain=${vlan_per_chain} | start=${start}
| | Set Test Variable | ${prev_layer} | dot1q
| Initialize layer ip4vxlan on node
@@ -314,21 +346,23 @@
| | ... | *Arguments:*
| | ... | - dut - DUT node. Type: string
| | ... | - count - Number of vxlan interfaces. Type: integer
+| | ... | - start - Id of first chain, allows adding chains during test.
+| | ... | Type: integer
| | ...
| | ... | *Example:*
| | ...
-| | ... | \| Initialize layer ip4vxlan on node \| DUT1 \| 1 \|
+| | ... | \| Initialize layer ip4vxlan on node \| DUT1 \| 3 \| 2 \|
| | ...
-| | [Arguments] | ${dut} | ${count}=${1}
+| | [Arguments] | ${dut} | ${count}=${1} | ${start}=${1}
| | ...
| | ${dut_str}= | Convert To Lowercase | ${dut}
-| | VPP Interface Set IP Address
+| | Run Keyword If | "${start}" == "1" | VPP Interface Set IP Address
| | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_1}
| | ... | 172.16.0.1 | 24
-| | VPP Interface Set IP Address
+| | Run Keyword If | "${start}" == "1" | VPP Interface Set IP Address
| | ... | ${nodes['${dut}']} | ${${dut_str}_${prev_layer}_1_2}
| | ... | 172.26.0.1 | 24
-| | :FOR | ${id} | IN RANGE | 1 | ${count} + 1
+| | :FOR | ${id} | IN RANGE | ${start} | ${count} + 1
| | | ${subnet}= | Evaluate | ${id} - 1
| | | ${vni}= | Evaluate | ${id} - 1
| | | ${ip4vxlan_1}= | Create VXLAN interface
@@ -368,13 +402,16 @@
| | ...
| | ... | *Arguments:*
| | ... | - count - Number of vxlan interfaces. Type: integer
+| | ... | - start - Id of first chain, allows adding chains during test.
+| | ... | Type: integer
| | ...
-| | ... | \| Initialize layer ip4vxlan \| 1 \|
+| | ... | \| Initialize layer ip4vxlan \| 3 \| 2 \|
| | ...
-| | [Arguments] | ${count}=${1}
+| | [Arguments] | ${count}=${1} | ${start}=${1}
| | ...
| | :FOR | ${dut} | IN | @{duts}
| | | Initialize layer ip4vxlan on node | ${dut} | count=${count}
+| | ... | start=${start}
| | Set Test Variable | ${prev_layer} | ip4vxlan
| Configure vhost interfaces
diff --git a/resources/tools/trex/trex_stateless_stop.py b/resources/tools/trex/trex_stateless_stop.py
index 9ded59a041..9421356bc1 100755
--- a/resources/tools/trex/trex_stateless_stop.py
+++ b/resources/tools/trex/trex_stateless_stop.py
@@ -34,31 +34,44 @@ from trex.stl.api import *
def main():
- """Stop traffic if any is running."""
+ """Stop traffic if any is running. Report xstats."""
client = STLClient()
try:
# connect to server
client.connect()
client.acquire(force=True)
+ # TODO: Support unidirection.
client.stop(ports=[0, 1])
# read the stats after the test
- stats = client.get_stats()
+ xstats0 = client.get_xstats(0)
+ xstats1 = client.get_xstats(1)
- print("#####statistics (approx.)#####")
- print(json.dumps(stats, indent=4, separators=(',', ': ')))
-
- lost_a = stats[0]["opackets"] - stats[1]["ipackets"]
- lost_b = stats[1]["opackets"] - stats[0]["ipackets"]
-
- print("\npackets lost from 0 --> 1: {0} pkts".format(lost_a))
- print("packets lost from 1 --> 0: {0} pkts".format(lost_b))
- except STLError as ex_error:
- print(ex_error, file=sys.stderr)
- sys.exit(1)
+ # If STLError happens, let the script fail with stack trace.
finally:
client.disconnect()
+ print("##### statistics port 0 #####")
+ print(json.dumps(xstats0, indent=4, separators=(',', ': ')))
+ print("##### statistics port 1 #####")
+ print(json.dumps(xstats1, indent=4, separators=(',', ': ')))
+
+ tx_0, rx_0 = xstats0["tx_good_packets"], xstats0["rx_good_packets"]
+ tx_1, rx_1 = xstats1["tx_good_packets"], xstats1["rx_good_packets"]
+ lost_a, lost_b = tx_0 - rx_1, tx_1 - rx_0
+
+ print("\npackets lost from 0 --> 1: {0} pkts".format(lost_a))
+ print("packets lost from 1 --> 0: {0} pkts".format(lost_b))
+
+ total_rcvd, total_sent = rx_0 + rx_1, tx_0 + tx_1
+ total_lost = total_sent - total_rcvd
+ # TODO: Add latency.
+ print(
+ "rate='unknown', totalReceived={rec}, totalSent={sen}, frameLoss={los},"
+ " latencyStream0(usec)=-1/-1/-1, latencyStream1(usec)=-1/-1/-1,"
+ " targetDuration='manual'".format(
+ rec=total_rcvd, sen=total_sent, los=total_lost))
+
if __name__ == "__main__":
main()