The method will be used by mixin classes derived from both
BasePerfTestTweakMixin and BasePerfTestIterationTweakMixin.
v2:
The commit renames the function according to the changed return
value which is complete list of flow measurements rather than
the first entry.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
.../Perf/PerfTestMixins/BasePerfTestTweakMixin.py | 6 ------
.../ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py | 9 +++++----
lnst/Recipes/ENRT/PerfTestMixins/Utils.py | 5 +++++
3 files changed, 10 insertions(+), 10 deletions(-)
create mode 100644 lnst/Recipes/ENRT/PerfTestMixins/Utils.py
diff --git a/lnst/RecipeCommon/Perf/PerfTestMixins/BasePerfTestTweakMixin.py
b/lnst/RecipeCommon/Perf/PerfTestMixins/BasePerfTestTweakMixin.py
index 5e008a68..380fc72e 100644
--- a/lnst/RecipeCommon/Perf/PerfTestMixins/BasePerfTestTweakMixin.py
+++ b/lnst/RecipeCommon/Perf/PerfTestMixins/BasePerfTestTweakMixin.py
@@ -1,5 +1,3 @@
-from lnst.RecipeCommon.Perf.Measurements.BaseFlowMeasurement import BaseFlowMeasurement
-
class BasePerfTestTweakMixin(object):
"""
This is a base class that defines common API for specific *perf test*
@@ -15,7 +13,3 @@ class BasePerfTestTweakMixin(object):
def remove_perf_test_tweak(self, perf_config):
# TODO: check if anything left in the perf_config.perf_test_tweak_config
pass
-
- def _get_flow_measurement_from_config(self, perf_config):
- flow_measurements = [ m for m in perf_config.measurements if isinstance(m,
BaseFlowMeasurement) ]
- return flow_measurements[0]
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
index 841df3f7..437a9a40 100644
--- a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
+++ b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
@@ -1,12 +1,13 @@
from lnst.Controller.RecipeResults import ResultLevel
from lnst.RecipeCommon.Perf.PerfTestMixins import BasePerfTestTweakMixin
+from lnst.Recipes.ENRT.PerfTestMixins.Utils import get_flow_measurements_from_config
class SctpFirewallPerfTestMixin(BasePerfTestTweakMixin):
def apply_perf_test_tweak(self, perf_config):
super().apply_perf_test_tweak(perf_config)
- flow_measurement = self._get_flow_measurement_from_config(perf_config)
- flow = flow_measurement.conf[0]
+ flow_measurements = get_flow_measurements_from_config(perf_config)
+ flow = flow_measurements[0].conf[0]
if flow.type == "sctp_stream":
for nic in [flow.generator_nic, flow.receiver_nic]:
nic.netns.run(
@@ -18,8 +19,8 @@ class SctpFirewallPerfTestMixin(BasePerfTestTweakMixin):
tweak_config["iptables_sctp"] = True
def remove_perf_test_tweak(self, perf_config):
- flow_measurement = self._get_flow_measurement_from_config(perf_config)
- flow = flow_measurement.conf[0]
+ flow_measurements = get_flow_measurements_from_config(perf_config)
+ flow = flow_measurements[0].conf[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/Utils.py
b/lnst/Recipes/ENRT/PerfTestMixins/Utils.py
new file mode 100644
index 00000000..16dd807e
--- /dev/null
+++ b/lnst/Recipes/ENRT/PerfTestMixins/Utils.py
@@ -0,0 +1,5 @@
+from lnst.RecipeCommon.Perf.Measurements.BaseFlowMeasurement import BaseFlowMeasurement
+
+def get_flow_measurements_from_config(perf_config):
+ flow_measurements = [ m for m in perf_config.measurements if isinstance(m,
BaseFlowMeasurement) ]
+ return flow_measurements
--
2.21.3