It does not make sense to have this setup just for offloaded tests. A follow up patch will add this to proper place.
Signed-off-by: Jan Tluka jtluka@redhat.com --- .../ENRT/ConfigMixins/OffloadSubConfigMixin.py | 12 ------------ 1 file changed, 12 deletions(-)
diff --git a/lnst/Recipes/ENRT/ConfigMixins/OffloadSubConfigMixin.py b/lnst/Recipes/ENRT/ConfigMixins/OffloadSubConfigMixin.py index 989743a8..3250a6af 100644 --- a/lnst/Recipes/ENRT/ConfigMixins/OffloadSubConfigMixin.py +++ b/lnst/Recipes/ENRT/ConfigMixins/OffloadSubConfigMixin.py @@ -45,12 +45,6 @@ class OffloadSubConfigMixin(BaseSubConfigMixin): ethtool_offload_string += " %s %s" % (name, value)
for nic in self.offload_nics: - if "sctp_stream" in self.params.perf_tests: - nic.netns.run( - "iptables -I OUTPUT ! -o %s -p sctp -j DROP" % nic.name, - job_level=ResultLevel.NORMAL, - ) - nic.netns.run( "ethtool -K {} {}".format(nic.name, ethtool_offload_string), job_level=ResultLevel.NORMAL, @@ -78,12 +72,6 @@ class OffloadSubConfigMixin(BaseSubConfigMixin): ethtool_offload_string += " %s %s" % (name, "on")
for nic in self.offload_nics: - if "sctp_stream" in self.params.perf_tests: - nic.netns.run( - "iptables -D OUTPUT ! -o %s -p sctp -j DROP" % nic.name, - job_level=ResultLevel.NORMAL, - ) - # set all the offloads back to 'on' state nic.netns.run( "ethtool -K {} {}".format(nic.name, ethtool_offload_string),
This will be used for additional pre-configuration of the SCTP performance test.
Signed-off-by: Jan Tluka jtluka@redhat.com --- .../Perf/Measurements/BaseFlowMeasurement.py | 18 ++++++++++++++++-- lnst/Recipes/ENRT/BaseEnrtRecipe.py | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/lnst/RecipeCommon/Perf/Measurements/BaseFlowMeasurement.py b/lnst/RecipeCommon/Perf/Measurements/BaseFlowMeasurement.py index 8c74c610..856eeba3 100644 --- a/lnst/RecipeCommon/Perf/Measurements/BaseFlowMeasurement.py +++ b/lnst/RecipeCommon/Perf/Measurements/BaseFlowMeasurement.py @@ -8,15 +8,17 @@ from lnst.RecipeCommon.Perf.Results import SequentialPerfResult class Flow(object): def __init__(self, type, - generator, generator_bind, - receiver, receiver_bind, + generator, generator_bind, generator_nic, + receiver, receiver_bind, receiver_nic, msg_size, duration, parallel_streams, cpupin): self._type = type
self._generator = generator self._generator_bind = generator_bind + self._generator_nic = generator_nic self._receiver = receiver self._receiver_bind = receiver_bind + self._receiver_nic = receiver_nic
self._msg_size = msg_size self._duration = duration @@ -35,6 +37,10 @@ class Flow(object): def generator_bind(self): return self._generator_bind
+ @property + def generator_nic(self): + return self._generator_nic + @property def receiver(self): return self._receiver @@ -43,6 +49,10 @@ class Flow(object): def receiver_bind(self): return self._receiver_bind
+ @property + def receiver_nic(self): + return self._receiver_nic + @property def msg_size(self): return self._msg_size @@ -65,8 +75,10 @@ class Flow(object): type={type}, generator={generator}, generator_bind={generator_bind}, + generator_nic={generator_nic}, receiver={receiver}, receiver_bind={receiver_bind}, + receiver_nic={receiver_nic}, msg_size={msg_size}, duration={duration}, parallel_streams={parallel_streams}, @@ -75,8 +87,10 @@ class Flow(object): type=self.type, generator=str(self.generator), generator_bind=self.generator_bind, + generator_nic=self.generator_nic, receiver=str(self.receiver), receiver_bind=self.receiver_bind, + receiver_nic=self.receiver_nic, msg_size=self.msg_size, duration=self.duration, parallel_streams=self.parallel_streams, diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py index 6a287ada..f8fafc80 100644 --- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py +++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py @@ -508,7 +508,9 @@ class BaseEnrtRecipe(BaseSubConfigMixin, PingTestAndEvaluate, PerfRecipe): cpupin = self.params.perf_tool_cpu if "perf_tool_cpu" in self.params else None return PerfFlow(type=perf_test, generator=client_nic.netns, generator_bind=client_bind, + generator_nic=client_nic, receiver=server_nic.netns, receiver_bind=server_bind, + receiver_nic=server_nic, msg_size=msg_size, duration=self.params.perf_duration, parallel_streams=self.params.perf_parallel_streams,
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@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
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Recipes/ENRT/BaseEnrtRecipe.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py index f8fafc80..46cc09ea 100644 --- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py +++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py @@ -13,6 +13,7 @@ from lnst.Common.Parameters import ( from lnst.Common.IpAddress import AF_INET, AF_INET6
from lnst.Recipes.ENRT.ConfigMixins.BaseSubConfigMixin import BaseSubConfigMixin +from lnst.Recipes.ENRT.PerfTestMixins import SctpFirewallPerfTestMixin
from lnst.RecipeCommon.Ping.Recipe import PingTestAndEvaluate, PingConf from lnst.RecipeCommon.Perf.Recipe import Recipe as PerfRecipe @@ -32,7 +33,8 @@ class EnrtConfiguration(object): """ pass
-class BaseEnrtRecipe(BaseSubConfigMixin, PingTestAndEvaluate, PerfRecipe): +class BaseEnrtRecipe(SctpFirewallPerfTestMixin, BaseSubConfigMixin, + PingTestAndEvaluate, PerfRecipe): """Base Recipe class for the ENRT recipe package
This class defines the shared *test* method defining the common test @@ -343,7 +345,9 @@ class BaseEnrtRecipe(BaseSubConfigMixin, PingTestAndEvaluate, PerfRecipe): methods to execute, report and evaluate the results. """ for perf_config in self.generate_perf_configurations(recipe_config): + self.apply_perf_test_tweak(perf_config) result = self.perf_test(perf_config) + self.remove_perf_test_tweak(perf_config) self.perf_report_and_evaluate(result)
def generate_ping_configurations(self, config):
Signed-off-by: Jan Tluka jtluka@redhat.com --- .../PerfTestMixins/BasePerfTestTweakMixin.py | 6 +++++- .../SctpFirewallPerfTestMixin.py | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py b/lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py index a444384d..380fc72e 100644 --- a/lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py +++ b/lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py @@ -4,8 +4,12 @@ class BasePerfTestTweakMixin(object): mixin classes. """
+ def generate_perf_test_tweak_description(self, perf_config): + return ["Performance test tweaks:"] + def apply_perf_test_tweak(self, perf_config): - pass + perf_config.perf_test_tweak_config = {}
def remove_perf_test_tweak(self, perf_config): + # TODO: check if anything left in the perf_config.perf_test_tweak_config pass diff --git a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py index 46963dd2..6c6cc416 100644 --- a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py +++ b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py @@ -20,6 +20,9 @@ class SctpFirewallPerfTestMixin(BasePerfTestTweakMixin): job_level=ResultLevel.NORMAL, )
+ tweak_config = perf_config.perf_test_tweak_config + 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] @@ -29,5 +32,23 @@ class SctpFirewallPerfTestMixin(BasePerfTestTweakMixin): "iptables -D OUTPUT ! -o %s -p sctp -j DROP" % nic.name, job_level=ResultLevel.NORMAL, ) + tweak_config = perf_config.perf_test_tweak_config + del tweak_config["iptables_sctp"]
super().remove_perf_test_tweak(perf_config) + + def generate_perf_test_tweak_description(self, perf_config): + description = super().generate_perf_test_tweak_description(perf_config) + tweak_config = perf_config.perf_test_tweak_config + if "iptables_sctp" in tweak_config: + description.append( + "added iptables rules to drop SCTP packets on other than " + "tested interface" + ) + else: + description.append( + "skipped addition of iptables rules to drop SCTP packets on " + "other than tested interface" + ) + + return description
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Recipes/ENRT/BaseEnrtRecipe.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py index 46cc09ea..438128a2 100644 --- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py +++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py @@ -337,6 +337,10 @@ class BaseEnrtRecipe(SctpFirewallPerfTestMixin, BaseSubConfigMixin, result = self.ping_test(ping_configs) self.ping_report_and_evaluate(result)
+ def describe_perf_test_tweak(self, perf_config): + description = self.generate_perf_test_tweak_description(perf_config) + self.add_result(True, "\n".join(description)) + def do_perf_tests(self, recipe_config): """Performance testing loop
@@ -346,6 +350,7 @@ class BaseEnrtRecipe(SctpFirewallPerfTestMixin, BaseSubConfigMixin, """ for perf_config in self.generate_perf_configurations(recipe_config): self.apply_perf_test_tweak(perf_config) + self.describe_perf_test_tweak(perf_config) result = self.perf_test(perf_config) self.remove_perf_test_tweak(perf_config) self.perf_report_and_evaluate(result)
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Recipes/ENRT/BaseEnrtRecipe.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py index 438128a2..4d0c93c8 100644 --- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py +++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py @@ -351,9 +351,11 @@ class BaseEnrtRecipe(SctpFirewallPerfTestMixin, BaseSubConfigMixin, for perf_config in self.generate_perf_configurations(recipe_config): self.apply_perf_test_tweak(perf_config) self.describe_perf_test_tweak(perf_config) - result = self.perf_test(perf_config) - self.remove_perf_test_tweak(perf_config) - self.perf_report_and_evaluate(result) + try: + result = self.perf_test(perf_config) + self.perf_report_and_evaluate(result) + finally: + self.remove_perf_test_tweak(perf_config)
def generate_ping_configurations(self, config): """Base ping test configuration generator
On Mon, Jul 27, 2020 at 05:51:30PM +0200, Jan Tluka wrote:
It does not make sense to have this setup just for offloaded tests. A follow up patch will add this to proper place.
Signed-off-by: Jan Tluka jtluka@redhat.com
.../ENRT/ConfigMixins/OffloadSubConfigMixin.py | 12 ------------ 1 file changed, 12 deletions(-)
diff --git a/lnst/Recipes/ENRT/ConfigMixins/OffloadSubConfigMixin.py b/lnst/Recipes/ENRT/ConfigMixins/OffloadSubConfigMixin.py index 989743a8..3250a6af 100644 --- a/lnst/Recipes/ENRT/ConfigMixins/OffloadSubConfigMixin.py +++ b/lnst/Recipes/ENRT/ConfigMixins/OffloadSubConfigMixin.py @@ -45,12 +45,6 @@ class OffloadSubConfigMixin(BaseSubConfigMixin): ethtool_offload_string += " %s %s" % (name, value)
for nic in self.offload_nics:
if "sctp_stream" in self.params.perf_tests:
nic.netns.run(
"iptables -I OUTPUT ! -o %s -p sctp -j DROP" % nic.name,
job_level=ResultLevel.NORMAL,
)
nic.netns.run( "ethtool -K {} {}".format(nic.name, ethtool_offload_string), job_level=ResultLevel.NORMAL,
@@ -78,12 +72,6 @@ class OffloadSubConfigMixin(BaseSubConfigMixin): ethtool_offload_string += " %s %s" % (name, "on")
for nic in self.offload_nics:
if "sctp_stream" in self.params.perf_tests:
nic.netns.run(
"iptables -D OUTPUT ! -o %s -p sctp -j DROP" % nic.name,
job_level=ResultLevel.NORMAL,
)
# set all the offloads back to 'on' state nic.netns.run( "ethtool -K {} {}".format(nic.name, ethtool_offload_string),
-- 2.21.3 _______________________________________________ LNST-developers mailing list -- lnst-developers@lists.fedorahosted.org To unsubscribe send an email to lnst-developers-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedorahos...
Looks good to me, pushing to master.
-Ondrej
lnst-developers@lists.fedorahosted.org