This patch adds a PerfTestMixins module that contains mixins to perform
additional tasks required by the BaseEnrtRecipe.do_perf_tests() method.
This is similar to ConfigMixin classes but at a deeper code level.
The module provides a base class BasePerfTestTweakMixin that defines
two methods, apply_perf_test_tweak() and remove_perf_test_tweak(), to
do additional configuration steps before and after the performance test.
The module also contains SctpFirewallPerfTestMixin that provides additional
tweak of the network stack for SCTP performance test. As an optimization,
the mixin applies iptables rules to the OUTPUT chain to drop any packets
on other than the tested interface. This is to prevent SCTP going through
unintended path.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
.../PerfTestMixins/BasePerfTestTweakMixin.py | 11 +++++++
.../SctpFirewallPerfTestMixin.py | 33 +++++++++++++++++++
lnst/Recipes/ENRT/PerfTestMixins/__init__.py | 2 ++
3 files changed, 46 insertions(+)
create mode 100644 lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py
create mode 100644 lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
create mode 100644 lnst/Recipes/ENRT/PerfTestMixins/__init__.py
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py
new file mode 100644
index 00000000..a444384d
--- /dev/null
+++ b/lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py
@@ -0,0 +1,11 @@
+class BasePerfTestTweakMixin(object):
+ """
+ This is a base class that defines common API for specific *perf test*
+ mixin classes.
+ """
+
+ def apply_perf_test_tweak(self, perf_config):
+ pass
+
+ def remove_perf_test_tweak(self, perf_config):
+ pass
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
new file mode 100644
index 00000000..46963dd2
--- /dev/null
+++ b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
@@ -0,0 +1,33 @@
+from lnst.Controller.RecipeResults import ResultLevel
+from lnst.Recipes.ENRT.PerfTestMixins import BasePerfTestTweakMixin
+from lnst.RecipeCommon.Perf.Measurements.BaseFlowMeasurement import BaseFlowMeasurement
+
+class SctpFirewallPerfTestMixin(BasePerfTestTweakMixin):
+
+ 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]
+
+ 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]
+ if flow.type == "sctp_stream":
+ for nic in [flow.generator_nic, flow.receiver_nic]:
+ nic.netns.run(
+ "iptables -I OUTPUT ! -o %s -p sctp -j DROP" % nic.name,
+ job_level=ResultLevel.NORMAL,
+ )
+
+ def remove_perf_test_tweak(self, perf_config):
+ flow_measurement = self._get_flow_measurement_from_config(perf_config)
+ flow = flow_measurement.conf[0]
+ if flow.type == "sctp_stream":
+ for nic in [flow.generator_nic, flow.receiver_nic]:
+ nic.netns.run(
+ "iptables -D OUTPUT ! -o %s -p sctp -j DROP" % nic.name,
+ job_level=ResultLevel.NORMAL,
+ )
+
+ super().remove_perf_test_tweak(perf_config)
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
b/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
new file mode 100644
index 00000000..9f320118
--- /dev/null
+++ b/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
@@ -0,0 +1,2 @@
+from lnst.Recipes.ENRT.PerfTestMixins.BasePerfTestTweakMixin import
BasePerfTestTweakMixin
+from lnst.Recipes.ENRT.PerfTestMixins.SctpFirewallPerfTestMixin import
SctpFirewallPerfTestMixin
--
2.21.3