From: Ondrej Lichtner <olichtne(a)redhat.com>
Based on the IperfFlowMeasurement implementation, there's a measurement
version indicating the version of the FlowMeasurement class, and there
are multiple host versions available (in case there's multiple hosts
running trex) reporting the used version of the trex software.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
.../Perf/Measurements/TRexFlowMeasurement.py | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
index 800b7b7..c12e922 100644
--- a/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
@@ -1,5 +1,6 @@
import time
import signal
+import re
from lnst.Controller.Recipe import RecipeError
from lnst.Controller.RecipeResults import ResultLevel
@@ -16,6 +17,8 @@
from lnst.Tests.TRex import TRexServer, TRexClient
class TRexFlowMeasurement(BaseFlowMeasurement):
+ _MEASUREMENT_VERSION = 1
+
def __init__(self, flows, trex_dir, server_cpu_cores, recipe_conf=None):
super(TRexFlowMeasurement, self).__init__(
measurement_conf=dict(
@@ -32,6 +35,26 @@ def __init__(self, flows, trex_dir, server_cpu_cores,
recipe_conf=None):
self._running_measurements = []
self._finished_measurements = []
+ self._hosts_versions = {}
+
+ @property
+ def version(self):
+ if not self._hosts_versions:
+ for flow in self._flows:
+ if flow.generator not in self._hosts_versions:
+ self._hosts_versions[flow.generator] =
self._get_host_trex_version(flow.generator)
+
+ return {"measurement_version": self._MEASUREMENT_VERSION,
+ "hosts_trex_versions": self._hosts_versions}
+
+ def _get_host_trex_version(self, host):
+ version_job = host.run("cd {trex_dir} ; ./t-rex-64 --help", job_level =
ResultLevel.DEBUG)
+ if version_job.passed:
+ match = re.match(r"Starting TRex (v.+?) please wait ...",
version_job.stdout)
+ if match:
+ return match.group(1)
+ return None
+
def start(self):
if len(self._running_measurements) > 0:
raise MeasurementError("Measurement already running!")
--
2.28.0