This is a series of patches that attempts to remove the duplicated code in Recipes/ENRT in case of cross-vlan ping runs.
The changes include: * split of ping command execution and evaluation of results * introducing two basic Ping evaluators * replacing the duplicated code in Recipes/ENRT with the new reusable code
Jan Tluka (12): RecipeCommon.Ping: rename running_ping to ping RecipeCommon.Ping: move prepare_job to ping_init RecipeCommon.Ping: remove ping_config from ping_evaluate_and_report Tests.Ping: update failure logic Tests.Ping: do not check rtt data if no packets were received RecipeCommon.Ping: rename ping_evaluate_and_report method lnst.RecipeCommon: move Ping Recipe to separate directory lnst.RecipeCommon.Ping: add Ping evaluators RecipeCommon.Ping.Recipe: add evaluators to PingConf object Recipes.ENRT.BaseEnrtRecipe: register default PingEvaluator RecipeCommon.Ping.Recipe: split report and evaluate Recipes.ENRT: use Ping evaluators to remove code duplicity
.../Ping/Evaluators/RatePingEvaluator.py | 59 +++++++++++++++++++ .../Ping/Evaluators/ZeroPassPingEvaluator.py | 22 +++++++ lnst/RecipeCommon/Ping/Evaluators/__init__.py | 2 + lnst/RecipeCommon/{Ping.py => Ping/Recipe.py} | 51 ++++++++++------ lnst/RecipeCommon/Ping/__init__.py | 0 lnst/Recipes/ENRT/BaseEnrtRecipe.py | 8 ++- lnst/Recipes/ENRT/BasePvPRecipe.py | 2 +- lnst/Recipes/ENRT/IpsecEspAeadRecipe.py | 2 +- lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py | 2 +- lnst/Recipes/ENRT/OvS_DPDK_PvP.py | 2 +- lnst/Recipes/ENRT/PingFloodRecipe.py | 4 +- lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py | 46 +++------------ .../ENRT/VirtualBridgeVlansOverBondRecipe.py | 49 +++------------ .../VirtualOvsBridgeVlansOverBondRecipe.py | 49 +++------------ lnst/Recipes/ENRT/VlansOverBondRecipe.py | 49 +++------------ lnst/Recipes/ENRT/VlansOverTeamRecipe.py | 49 +++------------ lnst/Recipes/ENRT/VlansRecipe.py | 49 +++------------ lnst/Tests/Ping.py | 20 +++---- 18 files changed, 189 insertions(+), 276 deletions(-) create mode 100644 lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py create mode 100644 lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py create mode 100644 lnst/RecipeCommon/Ping/Evaluators/__init__.py rename lnst/RecipeCommon/{Ping.py => Ping/Recipe.py} (65%) create mode 100644 lnst/RecipeCommon/Ping/__init__.py
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/Ping.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lnst/RecipeCommon/Ping.py b/lnst/RecipeCommon/Ping.py index 62cbc2ff..f6ad47e9 100644 --- a/lnst/RecipeCommon/Ping.py +++ b/lnst/RecipeCommon/Ping.py @@ -50,20 +50,20 @@ class PingTestAndEvaluate(BaseRecipe): def ping_test(self, ping_config): results = {}
- running_ping_array = [] + ping_array = [] for pingconf in ping_config: ping, client = self.ping_init(pingconf) - running_ping = client.prepare_job(ping) - running_ping.start(bg = True) - running_ping_array.append((pingconf, running_ping)) + ping = client.prepare_job(ping) + ping.start(bg = True) + ping_array.append((pingconf, ping))
- for _, pingjob in running_ping_array: + for _, pingjob in ping_array: try: pingjob.wait() finally: pingjob.kill()
- for pingconf, pingjob in running_ping_array: + for pingconf, pingjob in ping_array: result = pingjob.result results[pingconf] = result
On Mon, Mar 16, 2020 at 07:03:12PM +0100, Jan Tluka wrote:
Signed-off-by: Jan Tluka jtluka@redhat.com
lnst/RecipeCommon/Ping.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lnst/RecipeCommon/Ping.py b/lnst/RecipeCommon/Ping.py index 62cbc2ff..f6ad47e9 100644 --- a/lnst/RecipeCommon/Ping.py +++ b/lnst/RecipeCommon/Ping.py @@ -50,20 +50,20 @@ class PingTestAndEvaluate(BaseRecipe): def ping_test(self, ping_config): results = {}
running_ping_array = []
ping_array = [] for pingconf in ping_config:
^^^^^^^^^^ can we also rename this to ping_configs so that we don't have two variables with the same name differentiated by a '_'? adding '-s' at least makes it clear that it's plural
ping, client = self.ping_init(pingconf)
running_ping = client.prepare_job(ping)
running_ping.start(bg = True)
running_ping_array.append((pingconf, running_ping))
ping = client.prepare_job(ping)
ping.start(bg = True)
ping_array.append((pingconf, ping))
for _, pingjob in running_ping_array:
for _, pingjob in ping_array: try: pingjob.wait() finally: pingjob.kill()
for pingconf, pingjob in running_ping_array:
for pingconf, pingjob in ping_array: result = pingjob.result results[pingconf] = result
-- 2.21.1 _______________________________________________ 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...
Fri, Mar 20, 2020 at 04:13:40PM CET, olichtne@redhat.com wrote:
On Mon, Mar 16, 2020 at 07:03:12PM +0100, Jan Tluka wrote:
Signed-off-by: Jan Tluka jtluka@redhat.com
lnst/RecipeCommon/Ping.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lnst/RecipeCommon/Ping.py b/lnst/RecipeCommon/Ping.py index 62cbc2ff..f6ad47e9 100644 --- a/lnst/RecipeCommon/Ping.py +++ b/lnst/RecipeCommon/Ping.py @@ -50,20 +50,20 @@ class PingTestAndEvaluate(BaseRecipe): def ping_test(self, ping_config): results = {}
running_ping_array = []
ping_array = [] for pingconf in ping_config:
^^^^^^^^^^
can we also rename this to ping_configs so that we don't have two variables with the same name differentiated by a '_'? adding '-s' at least makes it clear that it's plural
Sure. A good idea. I got confused many times by this. Will update the patches.
ping, client = self.ping_init(pingconf)
running_ping = client.prepare_job(ping)
running_ping.start(bg = True)
running_ping_array.append((pingconf, running_ping))
ping = client.prepare_job(ping)
ping.start(bg = True)
ping_array.append((pingconf, ping))
for _, pingjob in running_ping_array:
for _, pingjob in ping_array: try: pingjob.wait() finally: pingjob.kill()
for pingconf, pingjob in running_ping_array:
for pingconf, pingjob in ping_array: result = pingjob.result results[pingconf] = result
-- 2.21.1 _______________________________________________ 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...
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/Ping.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/lnst/RecipeCommon/Ping.py b/lnst/RecipeCommon/Ping.py index f6ad47e9..985f4073 100644 --- a/lnst/RecipeCommon/Ping.py +++ b/lnst/RecipeCommon/Ping.py @@ -52,8 +52,7 @@ class PingTestAndEvaluate(BaseRecipe):
ping_array = [] for pingconf in ping_config: - ping, client = self.ping_init(pingconf) - ping = client.prepare_job(ping) + ping = self.ping_init(pingconf) ping.start(bg = True) ping_array.append((pingconf, ping))
@@ -72,8 +71,8 @@ class PingTestAndEvaluate(BaseRecipe): def ping_init(self, ping_config): client = ping_config.client kwargs = self._generate_ping_kwargs(ping_config) - ping = Ping(**kwargs) - return (ping, client) + ping = client.prepare_job(Ping(**kwargs)) + return ping
def ping_evaluate_and_report(self, ping_config, results): for pingconf, result in results.items():
This parameter is never used. The value is a list of PingConf objects and these are available in the results parameter anyway.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/Ping.py | 2 +- lnst/Recipes/ENRT/BaseEnrtRecipe.py | 2 +- lnst/Recipes/ENRT/IpsecEspAeadRecipe.py | 2 +- lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py | 2 +- lnst/Recipes/ENRT/PingFloodRecipe.py | 2 +- lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py | 2 +- lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py | 2 +- lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py | 2 +- lnst/Recipes/ENRT/VlansOverBondRecipe.py | 2 +- lnst/Recipes/ENRT/VlansOverTeamRecipe.py | 2 +- lnst/Recipes/ENRT/VlansRecipe.py | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/lnst/RecipeCommon/Ping.py b/lnst/RecipeCommon/Ping.py index 985f4073..792b0e52 100644 --- a/lnst/RecipeCommon/Ping.py +++ b/lnst/RecipeCommon/Ping.py @@ -74,7 +74,7 @@ class PingTestAndEvaluate(BaseRecipe): ping = client.prepare_job(Ping(**kwargs)) return ping
- def ping_evaluate_and_report(self, ping_config, results): + def ping_evaluate_and_report(self, results): for pingconf, result in results.items(): self.single_ping_evaluate_and_report(pingconf, result)
diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py index 5862311b..7a8cd55e 100644 --- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py +++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py @@ -102,7 +102,7 @@ class BaseEnrtRecipe(BaseSubConfigMixin, PingTestAndEvaluate, PerfRecipe): def do_ping_tests(self, recipe_config): for ping_config in self.generate_ping_configurations(recipe_config): result = self.ping_test(ping_config) - self.ping_evaluate_and_report(ping_config, result) + self.ping_evaluate_and_report(result)
def do_perf_tests(self, recipe_config): for perf_config in self.generate_perf_configurations(recipe_config): diff --git a/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py b/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py index fd8b1bda..6d7e1c1c 100644 --- a/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py +++ b/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py @@ -186,7 +186,7 @@ class IpsecEspAeadRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe, return (ping_result, pa_config, pa_result)
def ping_evaluate_and_report(self, ping_config, result): - super().ping_evaluate_and_report(ping_config, result[0]) + super().ping_evaluate_and_report(result[0]) self.packet_assert_evaluate_and_report(result[1], result[2])
def get_dev_by_ip(self, netns, ip): diff --git a/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py b/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py index 26ecda03..7ecb5ae1 100644 --- a/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py +++ b/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py @@ -217,7 +217,7 @@ class IpsecEspAhCompRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe,
def ping_evaluate_and_report(self, ping_config, result): for res in result: - super().ping_evaluate_and_report(ping_config, res[0]) + super().ping_evaluate_and_report(res[0]) self.packet_assert_evaluate_and_report(res[1], res[2])
def get_dev_by_ip(self, netns, ip): diff --git a/lnst/Recipes/ENRT/PingFloodRecipe.py b/lnst/Recipes/ENRT/PingFloodRecipe.py index bb04e169..1b1dec41 100644 --- a/lnst/Recipes/ENRT/PingFloodRecipe.py +++ b/lnst/Recipes/ENRT/PingFloodRecipe.py @@ -43,4 +43,4 @@ class PingFloodRecipe(PingTestAndEvaluate): pcfg=PingConf(host1, ip1, host2, ip2, count = cn, interval = iv, size = sz) result = self.ping_test([pcfg]) - self.ping_evaluate_and_report(pcfg, result) + self.ping_evaluate_and_report(result) diff --git a/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py b/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py index f7c7511c..c1fc1478 100644 --- a/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py +++ b/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py @@ -154,7 +154,7 @@ class VirtOvsVxlanRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe): pconf.destination_address) exp_fail.append(cond) result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(ping_config, result) + self.ping_evaluate_and_report(result)
def ping_test(self, ping_config, exp_fail): results = {} diff --git a/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py b/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py index c12d1945..8edf4234 100644 --- a/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py @@ -190,7 +190,7 @@ class VirtualBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, pconf.destination_address) exp_fail.append(cond) result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(ping_config, result) + self.ping_evaluate_and_report(result)
def ping_test(self, ping_config, exp_fail): results = {} diff --git a/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py b/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py index e8efd1d8..7cc9641f 100644 --- a/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py @@ -194,7 +194,7 @@ class VirtualOvsBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, pconf.destination_address) exp_fail.append(cond) result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(ping_config, result) + self.ping_evaluate_and_report(result)
def ping_test(self, ping_config, exp_fail): results = {} diff --git a/lnst/Recipes/ENRT/VlansOverBondRecipe.py b/lnst/Recipes/ENRT/VlansOverBondRecipe.py index f47d0a2c..12ce812d 100644 --- a/lnst/Recipes/ENRT/VlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VlansOverBondRecipe.py @@ -182,7 +182,7 @@ class VlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, pconf.destination_address) exp_fail.append(cond) result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(ping_config, result) + self.ping_evaluate_and_report(result)
def ping_test(self, ping_config, exp_fail): results = {} diff --git a/lnst/Recipes/ENRT/VlansOverTeamRecipe.py b/lnst/Recipes/ENRT/VlansOverTeamRecipe.py index 4b62be8d..679ab35f 100644 --- a/lnst/Recipes/ENRT/VlansOverTeamRecipe.py +++ b/lnst/Recipes/ENRT/VlansOverTeamRecipe.py @@ -179,7 +179,7 @@ class VlansOverTeamRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, pconf.destination_address) exp_fail.append(cond) result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(ping_config, result) + self.ping_evaluate_and_report(result)
def ping_test(self, ping_config, exp_fail): results = {} diff --git a/lnst/Recipes/ENRT/VlansRecipe.py b/lnst/Recipes/ENRT/VlansRecipe.py index bfaa51dd..38f1f454 100644 --- a/lnst/Recipes/ENRT/VlansRecipe.py +++ b/lnst/Recipes/ENRT/VlansRecipe.py @@ -148,7 +148,7 @@ class VlansRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, pconf.destination_address) exp_fail.append(cond) result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(ping_config, result) + self.ping_evaluate_and_report(result)
def ping_test(self, ping_config, exp_fail): results = {}
This patch modifies the code to leave the pass/fail decision to a user of the test module.
The module will now return with failure only if exit code is higher than 1. Exit code 1 is used to report that ping did not receive any reply packets at all or fewer packets than expected are received. Ping exits with exit code 2 on other errors.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Tests/Ping.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/lnst/Tests/Ping.py b/lnst/Tests/Ping.py index 17de8abf..b6ab9d55 100644 --- a/lnst/Tests/Ping.py +++ b/lnst/Tests/Ping.py @@ -53,16 +53,13 @@ class Ping(BaseTestModule): except KeyboardInterrupt: pass
- self._res_data["stderr"] = stderr - - if stderr != "": - self._res_data["msg"] = "errors reported by ping" - logging.error(self._res_data["msg"]) - logging.error(self._res_data["stderr"]) - - if ping_process.returncode > 0: + if ping_process.returncode > 1: self._res_data["msg"] = "returncode = {}".format(ping_process.returncode) logging.error(self._res_data["msg"]) + if stderr != "": + self._res_data["stderr"] = stderr + logging.error("errors reported by ping") + logging.error(self._res_data["stderr"]) return False
stat_pttr1 = r'(\d+) packets transmitted, (\d+) received'
If no packets are received there's no rtt data reported by ping. Still, this could be a valid case, e.g. when we expect no packets should pass.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Tests/Ping.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lnst/Tests/Ping.py b/lnst/Tests/Ping.py index b6ab9d55..c42e2f6a 100644 --- a/lnst/Tests/Ping.py +++ b/lnst/Tests/Ping.py @@ -82,9 +82,10 @@ class Ping(BaseTestModule):
match = re.search(stat_pttr2, stdout) if not match: - self._res_data = {"msg": "expected pattern not found"} - logging.error(self._res_data["msg"]) - return False + if self._res_data['rate'] > 0: + self._res_data = {"msg": "expected pattern not found"} + logging.error(self._res_data["msg"]) + return False else: tmin, tavg, tmax, tmdev = [float(x) for x in match.groups()] logging.debug("rtt min "%.3f", avg "%.3f", max "%.3f", "
This is to match Perf pattern.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/Ping.py | 6 +++--- lnst/Recipes/ENRT/BaseEnrtRecipe.py | 2 +- lnst/Recipes/ENRT/IpsecEspAeadRecipe.py | 2 +- lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py | 2 +- lnst/Recipes/ENRT/PingFloodRecipe.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lnst/RecipeCommon/Ping.py b/lnst/RecipeCommon/Ping.py index 792b0e52..320e4ac5 100644 --- a/lnst/RecipeCommon/Ping.py +++ b/lnst/RecipeCommon/Ping.py @@ -74,11 +74,11 @@ class PingTestAndEvaluate(BaseRecipe): ping = client.prepare_job(Ping(**kwargs)) return ping
- def ping_evaluate_and_report(self, results): + def ping_report_and_evaluate(self, results): for pingconf, result in results.items(): - self.single_ping_evaluate_and_report(pingconf, result) + self.single_ping_report_and_evaluate(pingconf, result)
- def single_ping_evaluate_and_report(self, ping_config, result): + def single_ping_report_and_evaluate(self, ping_config, result): fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ "<{0.destination.hostid} ({0.destination_address})>" description = fmt.format(ping_config) diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py index 7a8cd55e..ac4794d3 100644 --- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py +++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py @@ -102,7 +102,7 @@ class BaseEnrtRecipe(BaseSubConfigMixin, PingTestAndEvaluate, PerfRecipe): def do_ping_tests(self, recipe_config): for ping_config in self.generate_ping_configurations(recipe_config): result = self.ping_test(ping_config) - self.ping_evaluate_and_report(result) + self.ping_report_and_evaluate(result)
def do_perf_tests(self, recipe_config): for perf_config in self.generate_perf_configurations(recipe_config): diff --git a/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py b/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py index 6d7e1c1c..014891c0 100644 --- a/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py +++ b/lnst/Recipes/ENRT/IpsecEspAeadRecipe.py @@ -186,7 +186,7 @@ class IpsecEspAeadRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe, return (ping_result, pa_config, pa_result)
def ping_evaluate_and_report(self, ping_config, result): - super().ping_evaluate_and_report(result[0]) + super().ping_report_and_evaluate(result[0]) self.packet_assert_evaluate_and_report(result[1], result[2])
def get_dev_by_ip(self, netns, ip): diff --git a/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py b/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py index 7ecb5ae1..eb67e236 100644 --- a/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py +++ b/lnst/Recipes/ENRT/IpsecEspAhCompRecipe.py @@ -217,7 +217,7 @@ class IpsecEspAhCompRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe,
def ping_evaluate_and_report(self, ping_config, result): for res in result: - super().ping_evaluate_and_report(res[0]) + super().ping_report_and_evaluate(res[0]) self.packet_assert_evaluate_and_report(res[1], res[2])
def get_dev_by_ip(self, netns, ip): diff --git a/lnst/Recipes/ENRT/PingFloodRecipe.py b/lnst/Recipes/ENRT/PingFloodRecipe.py index 1b1dec41..964f956b 100644 --- a/lnst/Recipes/ENRT/PingFloodRecipe.py +++ b/lnst/Recipes/ENRT/PingFloodRecipe.py @@ -43,4 +43,4 @@ class PingFloodRecipe(PingTestAndEvaluate): pcfg=PingConf(host1, ip1, host2, ip2, count = cn, interval = iv, size = sz) result = self.ping_test([pcfg]) - self.ping_evaluate_and_report(result) + self.ping_report_and_evaluate(result)
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/{Ping.py => Ping/Recipe.py} | 0 lnst/RecipeCommon/Ping/__init__.py | 0 lnst/Recipes/ENRT/BaseEnrtRecipe.py | 2 +- lnst/Recipes/ENRT/BasePvPRecipe.py | 2 +- lnst/Recipes/ENRT/OvS_DPDK_PvP.py | 2 +- lnst/Recipes/ENRT/PingFloodRecipe.py | 2 +- 6 files changed, 4 insertions(+), 4 deletions(-) rename lnst/RecipeCommon/{Ping.py => Ping/Recipe.py} (100%) create mode 100644 lnst/RecipeCommon/Ping/__init__.py
diff --git a/lnst/RecipeCommon/Ping.py b/lnst/RecipeCommon/Ping/Recipe.py similarity index 100% rename from lnst/RecipeCommon/Ping.py rename to lnst/RecipeCommon/Ping/Recipe.py diff --git a/lnst/RecipeCommon/Ping/__init__.py b/lnst/RecipeCommon/Ping/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py index ac4794d3..a098553a 100644 --- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py +++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py @@ -7,7 +7,7 @@ from lnst.Common.IpAddress import AF_INET, AF_INET6
from lnst.Recipes.ENRT.ConfigMixins.BaseSubConfigMixin import BaseSubConfigMixin
-from lnst.RecipeCommon.Ping import PingTestAndEvaluate, PingConf +from lnst.RecipeCommon.Ping.Recipe import PingTestAndEvaluate, PingConf from lnst.RecipeCommon.Perf.Recipe import Recipe as PerfRecipe from lnst.RecipeCommon.Perf.Recipe import RecipeConf as PerfRecipeConf from lnst.RecipeCommon.Perf.Measurements import Flow as PerfFlow diff --git a/lnst/Recipes/ENRT/BasePvPRecipe.py b/lnst/Recipes/ENRT/BasePvPRecipe.py index 34fa2e3d..89e42938 100644 --- a/lnst/Recipes/ENRT/BasePvPRecipe.py +++ b/lnst/Recipes/ENRT/BasePvPRecipe.py @@ -4,7 +4,7 @@ from enum import Enum from lnst.Common.LnstError import LnstError from lnst.Common.Parameters import Param, IntParam, StrParam from lnst.Common.IpAddress import ipaddress -from lnst.RecipeCommon.Ping import PingTestAndEvaluate +from lnst.RecipeCommon.Ping.Recipe import PingTestAndEvaluate from lnst.Tests import Ping
from lnst.RecipeCommon.Perf.Recipe import Recipe as PerfRecipe diff --git a/lnst/Recipes/ENRT/OvS_DPDK_PvP.py b/lnst/Recipes/ENRT/OvS_DPDK_PvP.py index 63a6af45..899057d9 100644 --- a/lnst/Recipes/ENRT/OvS_DPDK_PvP.py +++ b/lnst/Recipes/ENRT/OvS_DPDK_PvP.py @@ -9,7 +9,7 @@ from lnst.Controller import HostReq, DeviceReq, RecipeParam from lnst.Common.Logs import log_exc_traceback from lnst.Common.Parameters import Param, IntParam, StrParam, BoolParam from lnst.Common.IpAddress import ipaddress -from lnst.RecipeCommon.Ping import PingTestAndEvaluate, PingConf +from lnst.RecipeCommon.Ping.Recipe import PingTestAndEvaluate, PingConf from lnst.Tests import Ping from lnst.Tests.TestPMD import TestPMD
diff --git a/lnst/Recipes/ENRT/PingFloodRecipe.py b/lnst/Recipes/ENRT/PingFloodRecipe.py index 964f956b..d5c00ce1 100644 --- a/lnst/Recipes/ENRT/PingFloodRecipe.py +++ b/lnst/Recipes/ENRT/PingFloodRecipe.py @@ -1,7 +1,7 @@ from lnst.Common.Parameters import Param, IntParam, StrParam from lnst.Common.IpAddress import ipaddress from lnst.Controller import HostReq, DeviceReq, RecipeParam -from lnst.RecipeCommon.Ping import PingConf, PingTestAndEvaluate +from lnst.RecipeCommon.Ping.Recipe import PingConf, PingTestAndEvaluate
class PingFloodRecipe(PingTestAndEvaluate): driver = StrParam(default='ixgbe')
This patch adds ZeroPassPingEvaluator and RatePingEvaluator evaluators that can be used to evaluate results of Ping test module.
ZeroPassPingEvaluator passes when no packets could be sent. RatePingEvaluator uses the rate reported by the Ping test module and compares with the configured min_rate, max_rate and rate parameters.
Signed-off-by: Jan Tluka jtluka@redhat.com --- .../Ping/Evaluators/RatePingEvaluator.py | 59 +++++++++++++++++++ .../Ping/Evaluators/ZeroPassPingEvaluator.py | 22 +++++++ lnst/RecipeCommon/Ping/Evaluators/__init__.py | 2 + 3 files changed, 83 insertions(+) create mode 100644 lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py create mode 100644 lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py create mode 100644 lnst/RecipeCommon/Ping/Evaluators/__init__.py
diff --git a/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py b/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py new file mode 100644 index 00000000..7e0ca715 --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py @@ -0,0 +1,59 @@ +from lnst.RecipeCommon.Perf.Evaluators.BaseEvaluator import BaseEvaluator + +class RatePingEvaluator(BaseEvaluator): + def __init__(self, min_rate=None, max_rate=None, rate=None): + self.min_rate = min_rate + self.max_rate = max_rate + self.rate = rate + + if min_rate is None and max_rate is None and rate is None: + raise Exception('{} requires at least one of min_rate, ' + 'max_rate and rate parameters specified'.format( + self.__class__.__name__) + ) + + def evaluate_results(self, recipe, result): + result_status = True + ping_rate = int(result['rate']) + + result_text = [] + + if self.min_rate is not None: + rate_text = 'measured rate {} is {} than min_rate({})' + if ping_rate < int(self.min_rate): + result_status = False + result_text.append( + rate_text.format(ping_rate, 'less', self.min_rate) + ) + else: + result_text.append( + rate_text.format(ping_rate, 'more', self.min_rate) + ) + + if self.max_rate is not None: + rate_text = 'measured rate {} is {} than max_rate({})' + if ping_rate > int(self.max_rate): + result_status = False + result_text.append( + rate_text.format(ping_rate, 'more', self.max_rate) + ) + else: + result_text.append( + rate_text.format(ping_rate, 'less', self.max_rate) + ) + + if self.rate is not None: + rate_text = 'measured rate {} is {} rate({})'.format( + ping_rate, self.rate) + + if ping_rate != int(self.rate): + result_status = False + result_text.append( + rate_text.format(ping_rate, 'different than', self.rate) + ) + else: + result_text.append( + rate_text.format(ping_rate, 'equal to', self.rate) + ) + + recipe.add_result(result_status, "\n".join(result_text)) diff --git a/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py b/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py new file mode 100644 index 00000000..13f5087a --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py @@ -0,0 +1,22 @@ +from lnst.RecipeCommon.Perf.Evaluators.BaseEvaluator import BaseEvaluator + +class ZeroPassPingEvaluator(BaseEvaluator): + def evaluate_results(self, recipe, result): + result_status = True + trans_packets = int(result['trans_pkts']) + recv_packets = int(result['recv_pkts']) + + if recv_packets > 0: + result_status = False + result_text = [ + 'expected zero packets but {} of {} packets ' + 'were received'.format( + recv_packets, trans_packets) + ] + else: + result_text = ['received {} of {} packets as expected'.format( + recv_packets, trans_packets) + ] + + recipe.add_result(result_status, "\n".join(result_text)) + diff --git a/lnst/RecipeCommon/Ping/Evaluators/__init__.py b/lnst/RecipeCommon/Ping/Evaluators/__init__.py new file mode 100644 index 00000000..2270cce7 --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/__init__.py @@ -0,0 +1,2 @@ +from lnst.RecipeCommon.Ping.Evaluators.ZeroPassPingEvaluator import ZeroPassPingEvaluator +from lnst.RecipeCommon.Ping.Evaluators.RatePingEvaluator import RatePingEvaluator
On Mon, Mar 16, 2020 at 07:03:19PM +0100, Jan Tluka wrote:
This patch adds ZeroPassPingEvaluator and RatePingEvaluator evaluators that can be used to evaluate results of Ping test module.
ZeroPassPingEvaluator passes when no packets could be sent. RatePingEvaluator uses the rate reported by the Ping test module and compares with the configured min_rate, max_rate and rate parameters.
Signed-off-by: Jan Tluka jtluka@redhat.com
There's a whitespace error:
Applying: lnst.RecipeCommon.Ping: add Ping evaluators .git/rebase-apply/patch:102: new blank line at EOF. + warning: 1 line adds whitespace errors.
I may remove this myself if there's no other major issues with the patchset.
-Ondrej
On Mon, Mar 16, 2020 at 07:03:19PM +0100, Jan Tluka wrote:
This patch adds ZeroPassPingEvaluator and RatePingEvaluator evaluators that can be used to evaluate results of Ping test module.
ZeroPassPingEvaluator passes when no packets could be sent. RatePingEvaluator uses the rate reported by the Ping test module and compares with the configured min_rate, max_rate and rate parameters.
Signed-off-by: Jan Tluka jtluka@redhat.com
.../Ping/Evaluators/RatePingEvaluator.py | 59 +++++++++++++++++++ .../Ping/Evaluators/ZeroPassPingEvaluator.py | 22 +++++++ lnst/RecipeCommon/Ping/Evaluators/__init__.py | 2 + 3 files changed, 83 insertions(+) create mode 100644 lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py create mode 100644 lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py create mode 100644 lnst/RecipeCommon/Ping/Evaluators/__init__.py
diff --git a/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py b/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py new file mode 100644 index 00000000..7e0ca715 --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py @@ -0,0 +1,59 @@ +from lnst.RecipeCommon.Perf.Evaluators.BaseEvaluator import BaseEvaluator
The BaseEvaluator should probably be moved to just the RecipeCommon package, I don't like it being imported in Ping package from the Perf package.
Should also probably be renamed to something like BaseResultEvaluator.
+class RatePingEvaluator(BaseEvaluator):
- def __init__(self, min_rate=None, max_rate=None, rate=None):
self.min_rate = min_rate
self.max_rate = max_rate
self.rate = rate
if min_rate is None and max_rate is None and rate is None:
raise Exception('{} requires at least one of min_rate, '
'max_rate and rate parameters specified'.format(
self.__class__.__name__)
)
- def evaluate_results(self, recipe, result):
result_status = True
ping_rate = int(result['rate'])
result_text = []
if self.min_rate is not None:
rate_text = 'measured rate {} is {} than min_rate({})'
if ping_rate < int(self.min_rate):
result_status = False
result_text.append(
rate_text.format(ping_rate, 'less', self.min_rate)
)
else:
result_text.append(
rate_text.format(ping_rate, 'more', self.min_rate)
)
if self.max_rate is not None:
rate_text = 'measured rate {} is {} than max_rate({})'
if ping_rate > int(self.max_rate):
result_status = False
result_text.append(
rate_text.format(ping_rate, 'more', self.max_rate)
)
else:
result_text.append(
rate_text.format(ping_rate, 'less', self.max_rate)
)
if self.rate is not None:
rate_text = 'measured rate {} is {} rate({})'.format(
ping_rate, self.rate)
if ping_rate != int(self.rate):
result_status = False
result_text.append(
rate_text.format(ping_rate, 'different than', self.rate)
)
else:
result_text.append(
rate_text.format(ping_rate, 'equal to', self.rate)
)
recipe.add_result(result_status, "\n".join(result_text))
diff --git a/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py b/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py new file mode 100644 index 00000000..13f5087a --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py @@ -0,0 +1,22 @@ +from lnst.RecipeCommon.Perf.Evaluators.BaseEvaluator import BaseEvaluator
+class ZeroPassPingEvaluator(BaseEvaluator):
- def evaluate_results(self, recipe, result):
result_status = True
trans_packets = int(result['trans_pkts'])
recv_packets = int(result['recv_pkts'])
if recv_packets > 0:
result_status = False
result_text = [
'expected zero packets but {} of {} packets '
'were received'.format(
recv_packets, trans_packets)
]
else:
result_text = ['received {} of {} packets as expected'.format(
recv_packets, trans_packets)
]
recipe.add_result(result_status, "\n".join(result_text))
diff --git a/lnst/RecipeCommon/Ping/Evaluators/__init__.py b/lnst/RecipeCommon/Ping/Evaluators/__init__.py new file mode 100644 index 00000000..2270cce7 --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/__init__.py @@ -0,0 +1,2 @@ +from lnst.RecipeCommon.Ping.Evaluators.ZeroPassPingEvaluator import ZeroPassPingEvaluator
+from lnst.RecipeCommon.Ping.Evaluators.RatePingEvaluator import RatePingEvaluator
2.21.1 _______________________________________________ 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...
Fri, Mar 20, 2020 at 04:12:10PM CET, olichtne@redhat.com wrote:
On Mon, Mar 16, 2020 at 07:03:19PM +0100, Jan Tluka wrote:
This patch adds ZeroPassPingEvaluator and RatePingEvaluator evaluators that can be used to evaluate results of Ping test module.
ZeroPassPingEvaluator passes when no packets could be sent. RatePingEvaluator uses the rate reported by the Ping test module and compares with the configured min_rate, max_rate and rate parameters.
Signed-off-by: Jan Tluka jtluka@redhat.com
.../Ping/Evaluators/RatePingEvaluator.py | 59 +++++++++++++++++++ .../Ping/Evaluators/ZeroPassPingEvaluator.py | 22 +++++++ lnst/RecipeCommon/Ping/Evaluators/__init__.py | 2 + 3 files changed, 83 insertions(+) create mode 100644 lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py create mode 100644 lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py create mode 100644 lnst/RecipeCommon/Ping/Evaluators/__init__.py
diff --git a/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py b/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py new file mode 100644 index 00000000..7e0ca715 --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/RatePingEvaluator.py @@ -0,0 +1,59 @@ +from lnst.RecipeCommon.Perf.Evaluators.BaseEvaluator import BaseEvaluator
The BaseEvaluator should probably be moved to just the RecipeCommon package, I don't like it being imported in Ping package from the Perf package.
Should also probably be renamed to something like BaseResultEvaluator.
Yes, makes sense.
+class RatePingEvaluator(BaseEvaluator):
- def __init__(self, min_rate=None, max_rate=None, rate=None):
self.min_rate = min_rate
self.max_rate = max_rate
self.rate = rate
if min_rate is None and max_rate is None and rate is None:
raise Exception('{} requires at least one of min_rate, '
'max_rate and rate parameters specified'.format(
self.__class__.__name__)
)
- def evaluate_results(self, recipe, result):
result_status = True
ping_rate = int(result['rate'])
result_text = []
if self.min_rate is not None:
rate_text = 'measured rate {} is {} than min_rate({})'
if ping_rate < int(self.min_rate):
result_status = False
result_text.append(
rate_text.format(ping_rate, 'less', self.min_rate)
)
else:
result_text.append(
rate_text.format(ping_rate, 'more', self.min_rate)
)
if self.max_rate is not None:
rate_text = 'measured rate {} is {} than max_rate({})'
if ping_rate > int(self.max_rate):
result_status = False
result_text.append(
rate_text.format(ping_rate, 'more', self.max_rate)
)
else:
result_text.append(
rate_text.format(ping_rate, 'less', self.max_rate)
)
if self.rate is not None:
rate_text = 'measured rate {} is {} rate({})'.format(
ping_rate, self.rate)
if ping_rate != int(self.rate):
result_status = False
result_text.append(
rate_text.format(ping_rate, 'different than', self.rate)
)
else:
result_text.append(
rate_text.format(ping_rate, 'equal to', self.rate)
)
recipe.add_result(result_status, "\n".join(result_text))
diff --git a/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py b/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py new file mode 100644 index 00000000..13f5087a --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/ZeroPassPingEvaluator.py @@ -0,0 +1,22 @@ +from lnst.RecipeCommon.Perf.Evaluators.BaseEvaluator import BaseEvaluator
+class ZeroPassPingEvaluator(BaseEvaluator):
- def evaluate_results(self, recipe, result):
result_status = True
trans_packets = int(result['trans_pkts'])
recv_packets = int(result['recv_pkts'])
if recv_packets > 0:
result_status = False
result_text = [
'expected zero packets but {} of {} packets '
'were received'.format(
recv_packets, trans_packets)
]
else:
result_text = ['received {} of {} packets as expected'.format(
recv_packets, trans_packets)
]
recipe.add_result(result_status, "\n".join(result_text))
diff --git a/lnst/RecipeCommon/Ping/Evaluators/__init__.py b/lnst/RecipeCommon/Ping/Evaluators/__init__.py new file mode 100644 index 00000000..2270cce7 --- /dev/null +++ b/lnst/RecipeCommon/Ping/Evaluators/__init__.py @@ -0,0 +1,2 @@ +from lnst.RecipeCommon.Ping.Evaluators.ZeroPassPingEvaluator import ZeroPassPingEvaluator
+from lnst.RecipeCommon.Ping.Evaluators.RatePingEvaluator import RatePingEvaluator
2.21.1 _______________________________________________ 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...
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/Ping/Recipe.py | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/lnst/RecipeCommon/Ping/Recipe.py b/lnst/RecipeCommon/Ping/Recipe.py index 320e4ac5..2ca86e07 100644 --- a/lnst/RecipeCommon/Ping/Recipe.py +++ b/lnst/RecipeCommon/Ping/Recipe.py @@ -13,6 +13,7 @@ class PingConf(object): self._count = count self._interval = interval self._size = size + self._evaluators = list()
@property def client(self): @@ -46,6 +47,14 @@ class PingConf(object): def size(self, value): self._size = value
+ @property + def evaluators(self): + return self._evaluators + + def register_evaluators(self, evaluators): + self._evaluators = list(evaluators) + + class PingTestAndEvaluate(BaseRecipe): def ping_test(self, ping_config): results = {}
Unless the do_ping_tests method is overriden, the default is to check the minimum ping rate that must be higher than 50%.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Recipes/ENRT/BaseEnrtRecipe.py | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py index a098553a..c68c86e7 100644 --- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py +++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py @@ -14,6 +14,7 @@ from lnst.RecipeCommon.Perf.Measurements import Flow as PerfFlow from lnst.RecipeCommon.Perf.Measurements import IperfFlowMeasurement from lnst.RecipeCommon.Perf.Measurements import StatCPUMeasurement from lnst.RecipeCommon.Perf.Evaluators import NonzeroFlowEvaluator +from lnst.RecipeCommon.Ping.Evaluators import RatePingEvaluator
class EnrtConfiguration(object): pass @@ -101,6 +102,9 @@ class BaseEnrtRecipe(BaseSubConfigMixin, PingTestAndEvaluate, PerfRecipe):
def do_ping_tests(self, recipe_config): for ping_config in self.generate_ping_configurations(recipe_config): + for pconf in ping_config: + pconf.register_evaluators([RatePingEvaluator(min_rate=50)]) + result = self.ping_test(ping_config) self.ping_report_and_evaluate(result)
The report part will now add result about the ping command status. The evaluation part will be handled separately by configured Ping evaluators.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/RecipeCommon/Ping/Recipe.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/lnst/RecipeCommon/Ping/Recipe.py b/lnst/RecipeCommon/Ping/Recipe.py index 2ca86e07..128d7356 100644 --- a/lnst/RecipeCommon/Ping/Recipe.py +++ b/lnst/RecipeCommon/Ping/Recipe.py @@ -72,7 +72,7 @@ class PingTestAndEvaluate(BaseRecipe): pingjob.kill()
for pingconf, pingjob in ping_array: - result = pingjob.result + result = (pingjob.passed, pingjob.result) results[pingconf] = result
return results @@ -88,15 +88,20 @@ class PingTestAndEvaluate(BaseRecipe): self.single_ping_report_and_evaluate(pingconf, result)
def single_ping_report_and_evaluate(self, ping_config, result): + self.single_ping_report(ping_config, result) + + self.single_ping_evaluate(ping_config, result) + + def single_ping_report(self, ping_config, result): fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ "<{0.destination.hostid} ({0.destination_address})>" description = fmt.format(ping_config) - if result["rate"] > 50: - message = "Ping successful --- " + description - self.add_result(True, message, result) - else: - message = "Ping unsuccessful --- " + description - self.add_result(False, message, result) + message = "Ping result --- " + description + self.add_result(result[0], message, result[1]) + + def single_ping_evaluate(self, ping_config, result): + for evaluator in ping_config.evaluators: + evaluator.evaluate_results(self, result[1])
def _generate_ping_kwargs(self, ping_config): kwargs = dict(dst=ping_config.destination_address,
On Mon, Mar 16, 2020 at 07:03:22PM +0100, Jan Tluka wrote:
The report part will now add result about the ping command status. The evaluation part will be handled separately by configured Ping evaluators.
Signed-off-by: Jan Tluka jtluka@redhat.com
lnst/RecipeCommon/Ping/Recipe.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/lnst/RecipeCommon/Ping/Recipe.py b/lnst/RecipeCommon/Ping/Recipe.py index 2ca86e07..128d7356 100644 --- a/lnst/RecipeCommon/Ping/Recipe.py +++ b/lnst/RecipeCommon/Ping/Recipe.py @@ -72,7 +72,7 @@ class PingTestAndEvaluate(BaseRecipe): pingjob.kill()
for pingconf, pingjob in ping_array:
result = pingjob.result
result = (pingjob.passed, pingjob.result) results[pingconf] = result return results
@@ -88,15 +88,20 @@ class PingTestAndEvaluate(BaseRecipe): self.single_ping_report_and_evaluate(pingconf, result)
def single_ping_report_and_evaluate(self, ping_config, result):
self.single_ping_report(ping_config, result)
self.single_ping_evaluate(ping_config, result)
- def single_ping_report(self, ping_config, result): fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ "<{0.destination.hostid} ({0.destination_address})>" description = fmt.format(ping_config)
if result["rate"] > 50:
message = "Ping successful --- " + description
self.add_result(True, message, result)
else:
message = "Ping unsuccessful --- " + description
self.add_result(False, message, result)
message = "Ping result --- " + description
self.add_result(result[0], message, result[1])
I think the PASS/FAIL distinction here is unnecessary. If the Ping test module returns with a FAIL, this is already automatically represented in the results and will be shown in the summary.
This should just be a "passing" result object that reports what was returned by the ping module - in other words... what was measured.
def single_ping_evaluate(self, ping_config, result):
for evaluator in ping_config.evaluators:
evaluator.evaluate_results(self, result[1])
def _generate_ping_kwargs(self, ping_config): kwargs = dict(dst=ping_config.destination_address,
-- 2.21.1 _______________________________________________ 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...
Fri, Mar 20, 2020 at 04:20:05PM CET, olichtne@redhat.com wrote:
On Mon, Mar 16, 2020 at 07:03:22PM +0100, Jan Tluka wrote:
- def single_ping_report(self, ping_config, result): fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ "<{0.destination.hostid} ({0.destination_address})>" description = fmt.format(ping_config)
if result["rate"] > 50:
message = "Ping successful --- " + description
self.add_result(True, message, result)
else:
message = "Ping unsuccessful --- " + description
self.add_result(False, message, result)
message = "Ping result --- " + description
self.add_result(result[0], message, result[1])
I think the PASS/FAIL distinction here is unnecessary. If the Ping test module returns with a FAIL, this is already automatically represented in the results and will be shown in the summary.
This should just be a "passing" result object that reports what was returned by the ping module - in other words... what was measured.
I think this would be confusing. In FAIL case you would have two records in the log:
FAIL I could not do ping for whatever reason ... (from Ping test module) PASS Ping result --- from ... to ... (from the Ping recipe)
I also looked at the Perf code and it also reports FAIL if there are no measurements to report.
Still in doubts as I understand your idea behind. I'll wait for your further comments.
-Jan
def single_ping_evaluate(self, ping_config, result):
for evaluator in ping_config.evaluators:
evaluator.evaluate_results(self, result[1])
def _generate_ping_kwargs(self, ping_config): kwargs = dict(dst=ping_config.destination_address,
-- 2.21.1 _______________________________________________ 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...
On Mon, Mar 23, 2020 at 11:33:00AM +0100, Jan Tluka wrote:
Fri, Mar 20, 2020 at 04:20:05PM CET, olichtne@redhat.com wrote:
On Mon, Mar 16, 2020 at 07:03:22PM +0100, Jan Tluka wrote:
- def single_ping_report(self, ping_config, result): fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ "<{0.destination.hostid} ({0.destination_address})>" description = fmt.format(ping_config)
if result["rate"] > 50:
message = "Ping successful --- " + description
self.add_result(True, message, result)
else:
message = "Ping unsuccessful --- " + description
self.add_result(False, message, result)
message = "Ping result --- " + description
self.add_result(result[0], message, result[1])
I think the PASS/FAIL distinction here is unnecessary. If the Ping test module returns with a FAIL, this is already automatically represented in the results and will be shown in the summary.
This should just be a "passing" result object that reports what was returned by the ping module - in other words... what was measured.
I think this would be confusing. In FAIL case you would have two records in the log:
FAIL I could not do ping for whatever reason ... (from Ping test module) PASS Ping result --- from ... to ... (from the Ping recipe)
I also looked at the Perf code and it also reports FAIL if there are no measurements to report.
yeah so there is a difference in the Perf code - the FAIL is reported only if there are no results to report on, these "no results" are when the Perf test fails - nothing gets parsed into the Parallel/Sequential perf results. If these get parsed and created then this always returns PASS and just prints the number.
I wrote a longer email here... but in the end I realized that your Ping approach is probably equivalent to what Perf does - the PASS/FAIL matches the PASS/FAIL of the lnst.Test.* module. The structure is slightly different because Ping doesn't have the additional layer of parsing measurements.
Still in doubts as I understand your idea behind. I'll wait for your further comments.
In the end, I think the original patch is correct. No need to fix anything here.
-Ondrej
This patch removes some code duplicity by using code from the base classes.
For pings within the vlan the RatePingEvaluator is used, for cross-vlan ping the ZeroPassPingEvaluator is used.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py | 46 +++-------------- .../ENRT/VirtualBridgeVlansOverBondRecipe.py | 49 ++++--------------- .../VirtualOvsBridgeVlansOverBondRecipe.py | 49 ++++--------------- lnst/Recipes/ENRT/VlansOverBondRecipe.py | 49 ++++--------------- lnst/Recipes/ENRT/VlansOverTeamRecipe.py | 49 ++++--------------- lnst/Recipes/ENRT/VlansRecipe.py | 49 ++++--------------- 6 files changed, 53 insertions(+), 238 deletions(-)
diff --git a/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py b/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py index c1fc1478..3c966ad4 100644 --- a/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py +++ b/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py @@ -5,6 +5,8 @@ from lnst.Recipes.ENRT.BaseEnrtRecipe import BaseEnrtRecipe from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( CommonHWSubConfigMixin) from lnst.Devices import OvsBridgeDevice +from lnst.RecipeCommon.Ping.Evaluators import ( + ZeroPassPingEvaluator, RatePingEvaluator)
class VirtOvsVxlanRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe): host1 = HostReq() @@ -148,47 +150,15 @@ class VirtOvsVxlanRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe):
def do_ping_tests(self, recipe_config): for ping_config in self.generate_ping_configurations(recipe_config): - exp_fail = [] for pconf in ping_config: cond = self.tun_id_match(pconf.client_bind, pconf.destination_address) - exp_fail.append(cond) - result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(result) - - def ping_test(self, ping_config, exp_fail): - results = {} - - running_ping_array = [] - for pingconf, fail in zip(ping_config, exp_fail): - ping, client = self.ping_init(pingconf) - running_ping = client.prepare_job(ping, fail=fail) - running_ping.start(bg = True) - running_ping_array.append((pingconf, running_ping)) - - for _, pingjob in running_ping_array: - try: - pingjob.wait() - finally: - pingjob.kill() - - for pingconf, pingjob in running_ping_array: - result = pingjob.result - passed = pingjob.passed - results[pingconf] = (result, passed) - - return results - - def single_ping_evaluate_and_report(self, ping_config, result): - fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ - "<{0.destination.hostid} ({0.destination_address})>" - description = fmt.format(ping_config) - if result[0].get("rate", 0) > 50: - message = "Ping successful --- " + description - self.add_result(result[1], message, result[0]) - else: - message = "Ping unsuccessful --- " + description - self.add_result(result[1], message, result[0]) + if cond: + pconf.register_evaluators([ZeroPassPingEvaluator()]) + else: + pconf.register_evaluators([RatePingEvaluator(min_rate=50)]) + result = self.ping_test(ping_config) + self.ping_report_and_evaluate(result)
def tun_id_match(self, src_addr, dst_addr): guest1, guest2, guest3, guest4 = (self.matched.guest1, diff --git a/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py b/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py index 8edf4234..fbda81ab 100644 --- a/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py @@ -10,6 +10,8 @@ from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( from lnst.Devices import VlanDevice from lnst.Devices import BondDevice from lnst.Devices import BridgeDevice +from lnst.RecipeCommon.Ping.Evaluators import ( + ZeroPassPingEvaluator, RatePingEvaluator)
class VirtualBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -182,49 +184,16 @@ class VirtualBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, self.ctl.wait_for_condition(condition, timeout=5)
def do_ping_tests(self, recipe_config): - for ping_config in self.generate_ping_configurations( - recipe_config): - exp_fail = [] + for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_match(pconf.client_bind, pconf.destination_address) - exp_fail.append(cond) - result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(result) - - def ping_test(self, ping_config, exp_fail): - results = {} - - running_ping_array = [] - for pingconf, fail in zip(ping_config, exp_fail): - ping, client = self.ping_init(pingconf) - running_ping = client.prepare_job(ping, fail=fail) - running_ping.start(bg = True) - running_ping_array.append((pingconf, running_ping)) - - for _, pingjob in running_ping_array: - try: - pingjob.wait() - finally: - pingjob.kill() - - for pingconf, pingjob in running_ping_array: - result = pingjob.result - passed = pingjob.passed - results[pingconf] = (result, passed) - - return results - - def single_ping_evaluate_and_report(self, ping_config, result): - fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ - "<{0.destination.hostid} ({0.destination_address})>" - description = fmt.format(ping_config) - if result[0].get("rate", 0) > 50: - message = "Ping successful --- " + description - self.add_result(result[1], message, result[0]) - else: - message = "Ping unsuccessful --- " + description - self.add_result(result[1], message, result[0]) + if cond: + pconf.register_evaluators([ZeroPassPingEvaluator()]) + else: + pconf.register_evaluators([RatePingEvaluator(min_rate=50)]) + result = self.ping_test(ping_config) + self.ping_report_and_evaluate(result)
def vlan_id_match(self, src_addr, dst_addr): guest1, guest2, guest3, guest4 = (self.matched.guest1, diff --git a/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py b/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py index 7cc9641f..b89e5133 100644 --- a/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py @@ -8,6 +8,8 @@ from lnst.Recipes.ENRT.ConfigMixins.OffloadSubConfigMixin import ( from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( CommonHWSubConfigMixin) from lnst.Devices import OvsBridgeDevice +from lnst.RecipeCommon.Ping.Evaluators import ( + ZeroPassPingEvaluator, RatePingEvaluator)
class VirtualOvsBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -186,49 +188,16 @@ class VirtualOvsBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, self.matched.host2.eth0, self.matched.host2.eth1]
def do_ping_tests(self, recipe_config): - for ping_config in self.generate_ping_configurations( - recipe_config): - exp_fail = [] + for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_match(pconf.client_bind, pconf.destination_address) - exp_fail.append(cond) - result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(result) - - def ping_test(self, ping_config, exp_fail): - results = {} - - running_ping_array = [] - for pingconf, fail in zip(ping_config, exp_fail): - ping, client = self.ping_init(pingconf) - running_ping = client.prepare_job(ping, fail=fail) - running_ping.start(bg = True) - running_ping_array.append((pingconf, running_ping)) - - for _, pingjob in running_ping_array: - try: - pingjob.wait() - finally: - pingjob.kill() - - for pingconf, pingjob in running_ping_array: - result = pingjob.result - passed = pingjob.passed - results[pingconf] = (result, passed) - - return results - - def single_ping_evaluate_and_report(self, ping_config, result): - fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ - "<{0.destination.hostid} ({0.destination_address})>" - description = fmt.format(ping_config) - if result[0].get("rate", 0) > 50: - message = "Ping successful --- " + description - self.add_result(result[1], message, result[0]) - else: - message = "Ping unsuccessful --- " + description - self.add_result(result[1], message, result[0]) + if cond: + pconf.register_evaluators([ZeroPassPingEvaluator()]) + else: + pconf.register_evaluators([RatePingEvaluator(min_rate=50)]) + result = self.ping_test(ping_config) + self.ping_report_and_evaluate(result)
def vlan_id_match(self, src_addr, dst_addr): guest1, guest2, guest3, guest4 = (self.matched.guest1, diff --git a/lnst/Recipes/ENRT/VlansOverBondRecipe.py b/lnst/Recipes/ENRT/VlansOverBondRecipe.py index 12ce812d..d2e1514d 100644 --- a/lnst/Recipes/ENRT/VlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VlansOverBondRecipe.py @@ -9,6 +9,8 @@ from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( from lnst.Devices import VlanDevice from lnst.Devices.VlanDevice import VlanDevice as Vlan from lnst.Devices import BondDevice +from lnst.RecipeCommon.Ping.Evaluators import ( + ZeroPassPingEvaluator, RatePingEvaluator)
class VlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -174,49 +176,16 @@ class VlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, return [host1.eth0, host1.eth1, host2.eth0]
def do_ping_tests(self, recipe_config): - for ping_config in self.generate_ping_configurations( - recipe_config): - exp_fail = [] + for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_same(pconf.client_bind, pconf.destination_address) - exp_fail.append(cond) - result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(result) - - def ping_test(self, ping_config, exp_fail): - results = {} - - running_ping_array = [] - for pingconf, fail in zip(ping_config, exp_fail): - ping, client = self.ping_init(pingconf) - running_ping = client.prepare_job(ping, fail=fail) - running_ping.start(bg = True) - running_ping_array.append((pingconf, running_ping)) - - for _, pingjob in running_ping_array: - try: - pingjob.wait() - finally: - pingjob.kill() - - for pingconf, pingjob in running_ping_array: - result = pingjob.result - passed = pingjob.passed - results[pingconf] = (result, passed) - - return results - - def single_ping_evaluate_and_report(self, ping_config, result): - fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ - "<{0.destination.hostid} ({0.destination_address})>" - description = fmt.format(ping_config) - if result[0].get("rate", 0) > 50: - message = "Ping successful --- " + description - self.add_result(result[1], message, result[0]) - else: - message = "Ping unsuccessful --- " + description - self.add_result(result[1], message, result[0]) + if cond: + pconf.register_evaluators([ZeroPassPingEvaluator()]) + else: + pconf.register_evaluators([RatePingEvaluator(min_rate=50)]) + result = self.ping_test(ping_config) + self.ping_report_and_evaluate(result)
def vlan_id_same(self, src_addr, dst_addr): host1, host2 = self.matched.host1, self.matched.host2 diff --git a/lnst/Recipes/ENRT/VlansOverTeamRecipe.py b/lnst/Recipes/ENRT/VlansOverTeamRecipe.py index 679ab35f..ffe91fd0 100644 --- a/lnst/Recipes/ENRT/VlansOverTeamRecipe.py +++ b/lnst/Recipes/ENRT/VlansOverTeamRecipe.py @@ -9,6 +9,8 @@ from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( from lnst.Devices import VlanDevice from lnst.Devices.VlanDevice import VlanDevice as Vlan from lnst.Devices import TeamDevice +from lnst.RecipeCommon.Ping.Evaluators import ( + ZeroPassPingEvaluator, RatePingEvaluator)
class VlansOverTeamRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -171,49 +173,16 @@ class VlansOverTeamRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, return [host1.eth0, host1.eth1, host2.eth0]
def do_ping_tests(self, recipe_config): - for ping_config in self.generate_ping_configurations( - recipe_config): - exp_fail = [] + for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_same(pconf.client_bind, pconf.destination_address) - exp_fail.append(cond) - result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(result) - - def ping_test(self, ping_config, exp_fail): - results = {} - - running_ping_array = [] - for pingconf, fail in zip(ping_config, exp_fail): - ping, client = self.ping_init(pingconf) - running_ping = client.prepare_job(ping, fail=fail) - running_ping.start(bg = True) - running_ping_array.append((pingconf, running_ping)) - - for _, pingjob in running_ping_array: - try: - pingjob.wait() - finally: - pingjob.kill() - - for pingconf, pingjob in running_ping_array: - result = pingjob.result - passed = pingjob.passed - results[pingconf] = (result, passed) - - return results - - def single_ping_evaluate_and_report(self, ping_config, result): - fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ - "<{0.destination.hostid} ({0.destination_address})>" - description = fmt.format(ping_config) - if result[0].get("rate", 0) > 50: - message = "Ping successful --- " + description - self.add_result(result[1], message, result[0]) - else: - message = "Ping unsuccessful --- " + description - self.add_result(result[1], message, result[0]) + if cond: + pconf.register_evaluators([ZeroPassPingEvaluator()]) + else: + pconf.register_evaluators([RatePingEvaluator(min_rate=50)]) + result = self.ping_test(ping_config) + self.ping_report_and_evaluate(result)
def vlan_id_same(self, src_addr, dst_addr): host1, host2 = self.matched.host1, self.matched.host2 diff --git a/lnst/Recipes/ENRT/VlansRecipe.py b/lnst/Recipes/ENRT/VlansRecipe.py index 38f1f454..bd9e0555 100644 --- a/lnst/Recipes/ENRT/VlansRecipe.py +++ b/lnst/Recipes/ENRT/VlansRecipe.py @@ -7,6 +7,8 @@ from lnst.Recipes.ENRT.ConfigMixins.OffloadSubConfigMixin import ( from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( CommonHWSubConfigMixin) from lnst.Devices import VlanDevice +from lnst.RecipeCommon.Ping.Evaluators import ( + ZeroPassPingEvaluator, RatePingEvaluator)
class VlansRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -140,49 +142,16 @@ class VlansRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, return [self.matched.host1.eth0, self.matched.host2.eth0]
def do_ping_tests(self, recipe_config): - for ping_config in self.generate_ping_configurations( - recipe_config): - exp_fail = [] + for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_same(pconf.client_bind, pconf.destination_address) - exp_fail.append(cond) - result = self.ping_test(ping_config, exp_fail) - self.ping_evaluate_and_report(result) - - def ping_test(self, ping_config, exp_fail): - results = {} - - running_ping_array = [] - for pingconf, fail in zip(ping_config, exp_fail): - ping, client = self.ping_init(pingconf) - running_ping = client.prepare_job(ping, fail=fail) - running_ping.start(bg = True) - running_ping_array.append((pingconf, running_ping)) - - for _, pingjob in running_ping_array: - try: - pingjob.wait() - finally: - pingjob.kill() - - for pingconf, pingjob in running_ping_array: - result = pingjob.result - passed = pingjob.passed - results[pingconf] = (result, passed) - - return results - - def single_ping_evaluate_and_report(self, ping_config, result): - fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \ - "<{0.destination.hostid} ({0.destination_address})>" - description = fmt.format(ping_config) - if result[0].get("rate", 0) > 50: - message = "Ping successful --- " + description - self.add_result(result[1], message, result[0]) - else: - message = "Ping unsuccessful --- " + description - self.add_result(result[1], message, result[0]) + if cond: + pconf.register_evaluators([ZeroPassPingEvaluator()]) + else: + pconf.register_evaluators([RatePingEvaluator(min_rate=50)]) + result = self.ping_test(ping_config) + self.ping_report_and_evaluate(result)
def vlan_id_same(self, src_addr, dst_addr): host1, host2 = self.matched.host1, self.matched.host2
On Mon, Mar 16, 2020 at 07:03:23PM +0100, Jan Tluka wrote:
This patch removes some code duplicity by using code from the base classes.
For pings within the vlan the RatePingEvaluator is used, for cross-vlan ping the ZeroPassPingEvaluator is used.
Signed-off-by: Jan Tluka jtluka@redhat.com
lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py | 46 +++-------------- .../ENRT/VirtualBridgeVlansOverBondRecipe.py | 49 ++++--------------- .../VirtualOvsBridgeVlansOverBondRecipe.py | 49 ++++--------------- lnst/Recipes/ENRT/VlansOverBondRecipe.py | 49 ++++--------------- lnst/Recipes/ENRT/VlansOverTeamRecipe.py | 49 ++++--------------- lnst/Recipes/ENRT/VlansRecipe.py | 49 ++++--------------- 6 files changed, 53 insertions(+), 238 deletions(-)
diff --git a/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py b/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py index c1fc1478..3c966ad4 100644 --- a/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py +++ b/lnst/Recipes/ENRT/VirtOvsVxlanRecipe.py @@ -5,6 +5,8 @@ from lnst.Recipes.ENRT.BaseEnrtRecipe import BaseEnrtRecipe from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( CommonHWSubConfigMixin) from lnst.Devices import OvsBridgeDevice +from lnst.RecipeCommon.Ping.Evaluators import (
- ZeroPassPingEvaluator, RatePingEvaluator)
class VirtOvsVxlanRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe): host1 = HostReq() @@ -148,47 +150,15 @@ class VirtOvsVxlanRecipe(CommonHWSubConfigMixin, BaseEnrtRecipe):
def do_ping_tests(self, recipe_config): for ping_config in self.generate_ping_configurations(recipe_config):
I think at this point it might just be easier to extend the generate_ping_configurations method instead and keep using the original do_ping_tests method as it is defined in the parent class. So it should just look something like this:
def generate_ping_configurations(self, recipe_config): for ping_config in super().generate_ping_configurations(recipe_config): #add the condition and evaluator registration here yield ping_config
This saves the two following lines that otherwise need to be part of the loop...
result = self.ping_test(ping_config, exp_fail) self.ping_evaluate_and_report(result)
Same pattern applies for all the other recipes as well.
exp_fail = [] for pconf in ping_config: cond = self.tun_id_match(pconf.client_bind, pconf.destination_address)
exp_fail.append(cond)
result = self.ping_test(ping_config, exp_fail)
self.ping_evaluate_and_report(result)
- def ping_test(self, ping_config, exp_fail):
results = {}
running_ping_array = []
for pingconf, fail in zip(ping_config, exp_fail):
ping, client = self.ping_init(pingconf)
running_ping = client.prepare_job(ping, fail=fail)
running_ping.start(bg = True)
running_ping_array.append((pingconf, running_ping))
for _, pingjob in running_ping_array:
try:
pingjob.wait()
finally:
pingjob.kill()
for pingconf, pingjob in running_ping_array:
result = pingjob.result
passed = pingjob.passed
results[pingconf] = (result, passed)
return results
- def single_ping_evaluate_and_report(self, ping_config, result):
fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \
"<{0.destination.hostid} ({0.destination_address})>"
description = fmt.format(ping_config)
if result[0].get("rate", 0) > 50:
message = "Ping successful --- " + description
self.add_result(result[1], message, result[0])
else:
message = "Ping unsuccessful --- " + description
self.add_result(result[1], message, result[0])
if cond:
pconf.register_evaluators([ZeroPassPingEvaluator()])
else:
pconf.register_evaluators([RatePingEvaluator(min_rate=50)])
result = self.ping_test(ping_config)
self.ping_report_and_evaluate(result)
def tun_id_match(self, src_addr, dst_addr): guest1, guest2, guest3, guest4 = (self.matched.guest1,
diff --git a/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py b/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py index 8edf4234..fbda81ab 100644 --- a/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VirtualBridgeVlansOverBondRecipe.py @@ -10,6 +10,8 @@ from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( from lnst.Devices import VlanDevice from lnst.Devices import BondDevice from lnst.Devices import BridgeDevice +from lnst.RecipeCommon.Ping.Evaluators import (
- ZeroPassPingEvaluator, RatePingEvaluator)
class VirtualBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -182,49 +184,16 @@ class VirtualBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, self.ctl.wait_for_condition(condition, timeout=5)
def do_ping_tests(self, recipe_config):
for ping_config in self.generate_ping_configurations(
recipe_config):
exp_fail = []
for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_match(pconf.client_bind, pconf.destination_address)
exp_fail.append(cond)
result = self.ping_test(ping_config, exp_fail)
self.ping_evaluate_and_report(result)
- def ping_test(self, ping_config, exp_fail):
results = {}
running_ping_array = []
for pingconf, fail in zip(ping_config, exp_fail):
ping, client = self.ping_init(pingconf)
running_ping = client.prepare_job(ping, fail=fail)
running_ping.start(bg = True)
running_ping_array.append((pingconf, running_ping))
for _, pingjob in running_ping_array:
try:
pingjob.wait()
finally:
pingjob.kill()
for pingconf, pingjob in running_ping_array:
result = pingjob.result
passed = pingjob.passed
results[pingconf] = (result, passed)
return results
- def single_ping_evaluate_and_report(self, ping_config, result):
fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \
"<{0.destination.hostid} ({0.destination_address})>"
description = fmt.format(ping_config)
if result[0].get("rate", 0) > 50:
message = "Ping successful --- " + description
self.add_result(result[1], message, result[0])
else:
message = "Ping unsuccessful --- " + description
self.add_result(result[1], message, result[0])
if cond:
pconf.register_evaluators([ZeroPassPingEvaluator()])
else:
pconf.register_evaluators([RatePingEvaluator(min_rate=50)])
result = self.ping_test(ping_config)
self.ping_report_and_evaluate(result)
def vlan_id_match(self, src_addr, dst_addr): guest1, guest2, guest3, guest4 = (self.matched.guest1,
diff --git a/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py b/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py index 7cc9641f..b89e5133 100644 --- a/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VirtualOvsBridgeVlansOverBondRecipe.py @@ -8,6 +8,8 @@ from lnst.Recipes.ENRT.ConfigMixins.OffloadSubConfigMixin import ( from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( CommonHWSubConfigMixin) from lnst.Devices import OvsBridgeDevice +from lnst.RecipeCommon.Ping.Evaluators import (
- ZeroPassPingEvaluator, RatePingEvaluator)
class VirtualOvsBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -186,49 +188,16 @@ class VirtualOvsBridgeVlansOverBondRecipe(CommonHWSubConfigMixin, self.matched.host2.eth0, self.matched.host2.eth1]
def do_ping_tests(self, recipe_config):
for ping_config in self.generate_ping_configurations(
recipe_config):
exp_fail = []
for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_match(pconf.client_bind, pconf.destination_address)
exp_fail.append(cond)
result = self.ping_test(ping_config, exp_fail)
self.ping_evaluate_and_report(result)
- def ping_test(self, ping_config, exp_fail):
results = {}
running_ping_array = []
for pingconf, fail in zip(ping_config, exp_fail):
ping, client = self.ping_init(pingconf)
running_ping = client.prepare_job(ping, fail=fail)
running_ping.start(bg = True)
running_ping_array.append((pingconf, running_ping))
for _, pingjob in running_ping_array:
try:
pingjob.wait()
finally:
pingjob.kill()
for pingconf, pingjob in running_ping_array:
result = pingjob.result
passed = pingjob.passed
results[pingconf] = (result, passed)
return results
- def single_ping_evaluate_and_report(self, ping_config, result):
fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \
"<{0.destination.hostid} ({0.destination_address})>"
description = fmt.format(ping_config)
if result[0].get("rate", 0) > 50:
message = "Ping successful --- " + description
self.add_result(result[1], message, result[0])
else:
message = "Ping unsuccessful --- " + description
self.add_result(result[1], message, result[0])
if cond:
pconf.register_evaluators([ZeroPassPingEvaluator()])
else:
pconf.register_evaluators([RatePingEvaluator(min_rate=50)])
result = self.ping_test(ping_config)
self.ping_report_and_evaluate(result)
def vlan_id_match(self, src_addr, dst_addr): guest1, guest2, guest3, guest4 = (self.matched.guest1,
diff --git a/lnst/Recipes/ENRT/VlansOverBondRecipe.py b/lnst/Recipes/ENRT/VlansOverBondRecipe.py index 12ce812d..d2e1514d 100644 --- a/lnst/Recipes/ENRT/VlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VlansOverBondRecipe.py @@ -9,6 +9,8 @@ from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( from lnst.Devices import VlanDevice from lnst.Devices.VlanDevice import VlanDevice as Vlan from lnst.Devices import BondDevice +from lnst.RecipeCommon.Ping.Evaluators import (
- ZeroPassPingEvaluator, RatePingEvaluator)
class VlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -174,49 +176,16 @@ class VlansOverBondRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, return [host1.eth0, host1.eth1, host2.eth0]
def do_ping_tests(self, recipe_config):
for ping_config in self.generate_ping_configurations(
recipe_config):
exp_fail = []
for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_same(pconf.client_bind, pconf.destination_address)
exp_fail.append(cond)
result = self.ping_test(ping_config, exp_fail)
self.ping_evaluate_and_report(result)
- def ping_test(self, ping_config, exp_fail):
results = {}
running_ping_array = []
for pingconf, fail in zip(ping_config, exp_fail):
ping, client = self.ping_init(pingconf)
running_ping = client.prepare_job(ping, fail=fail)
running_ping.start(bg = True)
running_ping_array.append((pingconf, running_ping))
for _, pingjob in running_ping_array:
try:
pingjob.wait()
finally:
pingjob.kill()
for pingconf, pingjob in running_ping_array:
result = pingjob.result
passed = pingjob.passed
results[pingconf] = (result, passed)
return results
- def single_ping_evaluate_and_report(self, ping_config, result):
fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \
"<{0.destination.hostid} ({0.destination_address})>"
description = fmt.format(ping_config)
if result[0].get("rate", 0) > 50:
message = "Ping successful --- " + description
self.add_result(result[1], message, result[0])
else:
message = "Ping unsuccessful --- " + description
self.add_result(result[1], message, result[0])
if cond:
pconf.register_evaluators([ZeroPassPingEvaluator()])
else:
pconf.register_evaluators([RatePingEvaluator(min_rate=50)])
result = self.ping_test(ping_config)
self.ping_report_and_evaluate(result)
def vlan_id_same(self, src_addr, dst_addr): host1, host2 = self.matched.host1, self.matched.host2
diff --git a/lnst/Recipes/ENRT/VlansOverTeamRecipe.py b/lnst/Recipes/ENRT/VlansOverTeamRecipe.py index 679ab35f..ffe91fd0 100644 --- a/lnst/Recipes/ENRT/VlansOverTeamRecipe.py +++ b/lnst/Recipes/ENRT/VlansOverTeamRecipe.py @@ -9,6 +9,8 @@ from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( from lnst.Devices import VlanDevice from lnst.Devices.VlanDevice import VlanDevice as Vlan from lnst.Devices import TeamDevice +from lnst.RecipeCommon.Ping.Evaluators import (
- ZeroPassPingEvaluator, RatePingEvaluator)
class VlansOverTeamRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -171,49 +173,16 @@ class VlansOverTeamRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, return [host1.eth0, host1.eth1, host2.eth0]
def do_ping_tests(self, recipe_config):
for ping_config in self.generate_ping_configurations(
recipe_config):
exp_fail = []
for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_same(pconf.client_bind, pconf.destination_address)
exp_fail.append(cond)
result = self.ping_test(ping_config, exp_fail)
self.ping_evaluate_and_report(result)
- def ping_test(self, ping_config, exp_fail):
results = {}
running_ping_array = []
for pingconf, fail in zip(ping_config, exp_fail):
ping, client = self.ping_init(pingconf)
running_ping = client.prepare_job(ping, fail=fail)
running_ping.start(bg = True)
running_ping_array.append((pingconf, running_ping))
for _, pingjob in running_ping_array:
try:
pingjob.wait()
finally:
pingjob.kill()
for pingconf, pingjob in running_ping_array:
result = pingjob.result
passed = pingjob.passed
results[pingconf] = (result, passed)
return results
- def single_ping_evaluate_and_report(self, ping_config, result):
fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \
"<{0.destination.hostid} ({0.destination_address})>"
description = fmt.format(ping_config)
if result[0].get("rate", 0) > 50:
message = "Ping successful --- " + description
self.add_result(result[1], message, result[0])
else:
message = "Ping unsuccessful --- " + description
self.add_result(result[1], message, result[0])
if cond:
pconf.register_evaluators([ZeroPassPingEvaluator()])
else:
pconf.register_evaluators([RatePingEvaluator(min_rate=50)])
result = self.ping_test(ping_config)
self.ping_report_and_evaluate(result)
def vlan_id_same(self, src_addr, dst_addr): host1, host2 = self.matched.host1, self.matched.host2
diff --git a/lnst/Recipes/ENRT/VlansRecipe.py b/lnst/Recipes/ENRT/VlansRecipe.py index 38f1f454..bd9e0555 100644 --- a/lnst/Recipes/ENRT/VlansRecipe.py +++ b/lnst/Recipes/ENRT/VlansRecipe.py @@ -7,6 +7,8 @@ from lnst.Recipes.ENRT.ConfigMixins.OffloadSubConfigMixin import ( from lnst.Recipes.ENRT.ConfigMixins.CommonHWSubConfigMixin import ( CommonHWSubConfigMixin) from lnst.Devices import VlanDevice +from lnst.RecipeCommon.Ping.Evaluators import (
- ZeroPassPingEvaluator, RatePingEvaluator)
class VlansRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, BaseEnrtRecipe): @@ -140,49 +142,16 @@ class VlansRecipe(CommonHWSubConfigMixin, OffloadSubConfigMixin, return [self.matched.host1.eth0, self.matched.host2.eth0]
def do_ping_tests(self, recipe_config):
for ping_config in self.generate_ping_configurations(
recipe_config):
exp_fail = []
for ping_config in self.generate_ping_configurations(recipe_config): for pconf in ping_config: cond = self.vlan_id_same(pconf.client_bind, pconf.destination_address)
exp_fail.append(cond)
result = self.ping_test(ping_config, exp_fail)
self.ping_evaluate_and_report(result)
- def ping_test(self, ping_config, exp_fail):
results = {}
running_ping_array = []
for pingconf, fail in zip(ping_config, exp_fail):
ping, client = self.ping_init(pingconf)
running_ping = client.prepare_job(ping, fail=fail)
running_ping.start(bg = True)
running_ping_array.append((pingconf, running_ping))
for _, pingjob in running_ping_array:
try:
pingjob.wait()
finally:
pingjob.kill()
for pingconf, pingjob in running_ping_array:
result = pingjob.result
passed = pingjob.passed
results[pingconf] = (result, passed)
return results
- def single_ping_evaluate_and_report(self, ping_config, result):
fmt = "From: <{0.client.hostid} ({0.client_bind})> To: " \
"<{0.destination.hostid} ({0.destination_address})>"
description = fmt.format(ping_config)
if result[0].get("rate", 0) > 50:
message = "Ping successful --- " + description
self.add_result(result[1], message, result[0])
else:
message = "Ping unsuccessful --- " + description
self.add_result(result[1], message, result[0])
if cond:
pconf.register_evaluators([ZeroPassPingEvaluator()])
else:
pconf.register_evaluators([RatePingEvaluator(min_rate=50)])
result = self.ping_test(ping_config)
self.ping_report_and_evaluate(result)
def vlan_id_same(self, src_addr, dst_addr): host1, host2 = self.matched.host1, self.matched.host2
-- 2.21.1 _______________________________________________ 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...
lnst-developers@lists.fedorahosted.org