From: Ondrej Lichtner <olichtne(a)redhat.com>
Turns out, measurement_conf is highly specific to each derived
Measurement class. This means it doesn't really make sense to include it
into the BaseMeasurement class, instead each derived class should take
care of defining it's own init parameters and their handling.
This still keeps the "recipe_conf" parameter in the BaseMeasurement
class as this is still universal.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
.../RecipeCommon/Perf/Measurements/BaseMeasurement.py | 9 ++-------
.../Perf/Measurements/IperfFlowMeasurement.py | 11 ++++++-----
.../Perf/Measurements/StatCPUMeasurement.py | 11 ++++++++---
.../Perf/Measurements/TRexFlowMeasurement.py | 10 +---------
.../ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py | 4 ++--
.../PerfTestMixins/UdpFragmentationPerfTestMixin.py | 2 +-
6 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/lnst/RecipeCommon/Perf/Measurements/BaseMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/BaseMeasurement.py
index 4c0b093..198a0c6 100644
--- a/lnst/RecipeCommon/Perf/Measurements/BaseMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/BaseMeasurement.py
@@ -1,6 +1,5 @@
class BaseMeasurement(object):
- def __init__(self, measurement_conf, recipe_conf=None):
- self._conf = measurement_conf
+ def __init__(self, recipe_conf=None):
self._recipe_conf = recipe_conf
@property
@@ -11,10 +10,6 @@ def name(self):
def version(self):
raise NotImplementedError()
- @property
- def conf(self):
- return self._conf
-
@property
def recipe_conf(self):
return self._recipe_conf
@@ -39,7 +34,7 @@ def aggregate_results(first, second):
def __repr__(self):
return "{}({})".format(
self.__class__.__name__,
- repr(self.conf),
+ repr(self.recipe_conf),
)
diff --git a/lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py
index ee01c82..ed1f537 100644
--- a/lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py
@@ -20,8 +20,9 @@
class IperfFlowMeasurement(BaseFlowMeasurement):
_MEASUREMENT_VERSION = 1
- def __init__(self, *args):
- super(IperfFlowMeasurement, self).__init__(*args)
+ def __init__(self, flows, recipe_conf=None):
+ super(IperfFlowMeasurement, self).__init__(recipe_conf)
+ self._flows = flows
self._running_measurements = []
self._finished_measurements = []
@@ -29,12 +30,12 @@ def __init__(self, *args):
@property
def flows(self):
- return self._conf
+ return self._flows
@property
def version(self):
if not self._hosts_versions:
- for flow in self._conf:
+ for flow in self.flows:
if flow.receiver not in self._hosts_versions:
self._hosts_versions[flow.receiver] =
self._get_host_iperf_version(flow.receiver)
if flow.generator not in self._hosts_versions:
@@ -55,7 +56,7 @@ def start(self):
if len(self._running_measurements) > 0:
raise MeasurementError("Measurement already running!")
- test_flows = self._prepare_test_flows(self._conf)
+ test_flows = self._prepare_test_flows(self.flows)
result = None
for flow in test_flows:
diff --git a/lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py
index 7279b03..49aa262 100644
--- a/lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py
@@ -52,8 +52,9 @@ def align_data(self, start, end):
class StatCPUMeasurement(BaseCPUMeasurement):
- def __init__(self, *args):
- super(StatCPUMeasurement, self).__init__(*args)
+ def __init__(self, hosts, recipe_conf=None):
+ super(StatCPUMeasurement, self).__init__(recipe_conf)
+ self._hosts = hosts
self._running_measurements = []
self._finished_measurements = []
@@ -61,9 +62,13 @@ def __init__(self, *args):
def version(self):
return "1"
+ @property
+ def hosts(self):
+ return self._hosts
+
def start(self):
jobs = []
- for host in sorted(self._conf, key=lambda x: x.hostid):
+ for host in sorted(self.hosts, key=lambda x: x.hostid):
jobs.append(
host.run(
CPUStatMonitor(interval=1000),
diff --git a/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
index 3426360..d96ecc9 100644
--- a/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
@@ -20,18 +20,10 @@ 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(
- flows=flows,
- trex_dir=trex_dir,
- server_cpu_cores=server_cpu_cores,
- ),
- recipe_conf=recipe_conf,
- )
+ super(TRexFlowMeasurement, self).__init__(recipe_conf)
self._flows = flows
self._trex_dir = trex_dir
self._server_cpu_cores = server_cpu_cores
- self._conf = dict(flows=flows, trex_dir=trex_dir)
self._running_measurements = []
self._finished_measurements = []
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
index 437a9a4..1c08acc 100644
--- a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
+++ b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
@@ -7,7 +7,7 @@ def apply_perf_test_tweak(self, perf_config):
super().apply_perf_test_tweak(perf_config)
flow_measurements = get_flow_measurements_from_config(perf_config)
- flow = flow_measurements[0].conf[0]
+ flow = flow_measurements[0].flows[0]
if flow.type == "sctp_stream":
for nic in [flow.generator_nic, flow.receiver_nic]:
nic.netns.run(
@@ -20,7 +20,7 @@ def apply_perf_test_tweak(self, perf_config):
def remove_perf_test_tweak(self, perf_config):
flow_measurements = get_flow_measurements_from_config(perf_config)
- flow = flow_measurements[0].conf[0]
+ flow = flow_measurements[0].flows[0]
if flow.type == "sctp_stream":
for nic in [flow.generator_nic, flow.receiver_nic]:
nic.netns.run(
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/UdpFragmentationPerfTestMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/UdpFragmentationPerfTestMixin.py
index 0f5c6c7..a8e3e62 100644
--- a/lnst/Recipes/ENRT/PerfTestMixins/UdpFragmentationPerfTestMixin.py
+++ b/lnst/Recipes/ENRT/PerfTestMixins/UdpFragmentationPerfTestMixin.py
@@ -16,7 +16,7 @@ def apply_perf_test_tweak(self, perf_config):
super().apply_perf_test_tweak(perf_config)
flow_measurements = get_flow_measurements_from_config(perf_config)
- flow = flow_measurements[0].conf[0]
+ flow = flow_measurements[0].flows[0]
tweak_config = perf_config.perf_test_tweak_config
if flow.type == "udp_stream":
tweak_config["udp_fragmentation"] = {}
--
2.30.0