From: Christos Sfakianakis csfakian@redhat.com
Make use of the update in PingConf class (commit ddc871c - count and interval properties defined). Inherit from PingTestAndEvaluate "common recipe template" that BaseEnrtRecipe inherits from.
Christos Sfakianakis (1): lnst.Recipes.ENRT.PingFloodRecipe: rework to inherit from PingTestAndEvaluate
lnst/Recipes/ENRT/PingFloodRecipe.py | 42 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 14 deletions(-)
From: Christos Sfakianakis csfakian@redhat.com
Inherit from PingTestAndEvaluate and allow the user to choose parameters like ping count, ping interval, packet size.
Signed-off-by: Christos Sfakianakis csfakian@redhat.com --- lnst/Recipes/ENRT/PingFloodRecipe.py | 42 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/lnst/Recipes/ENRT/PingFloodRecipe.py b/lnst/Recipes/ENRT/PingFloodRecipe.py index 54c4e1f..b7fff01 100644 --- a/lnst/Recipes/ENRT/PingFloodRecipe.py +++ b/lnst/Recipes/ENRT/PingFloodRecipe.py @@ -1,34 +1,48 @@ #!/bin/python2 """ Implements scenario similar to regression_tests/phase1/ -(ping_flood.xml + simple_ping.py) +(ping_flood.xml + simple_ping.py). """
-from lnst.Common.Parameters import Param +from lnst.Common.Parameters import Param, IntParam, StrParam from lnst.Common.IpAddress import ipaddress -from lnst.Controller import HostReq, DeviceReq, BaseRecipe -from lnst.Tests import Ping +from lnst.Controller import HostReq, DeviceReq +from lnst.RecipeCommon.Ping import PingConf, PingTestAndEvaluate
-#TODO: Inherit just from PingTestAndEvaluate after enabling patch is available -class PingFloodRecipe(BaseRecipe): +class PingFloodRecipe(PingTestAndEvaluate): m1 = HostReq() m1.eth0 = DeviceReq(label="net1")
m2 = HostReq() m2.eth0 = DeviceReq(label="net1")
+ #TODO: use a parameter for the network + src_addr = StrParam(default = "192.168.1.1/24") + dst_addr = StrParam(default = "192.168.1.2/24") + count = IntParam(default = 100) + interval = StrParam(default = 0.2) + size = IntParam(default = None) + def test(self): m1, m2 = self.matched.m1, self.matched.m2
- self.matched.m1.eth0.ip_add(ipaddress("192.168.1.1/24")) - self.matched.m2.eth0.ip_add(ipaddress("192.168.1.2/24")) + m1.eth0.ip_add(ipaddress(self.params.src_addr)) + m2.eth0.ip_add(ipaddress(self.params.dst_addr))
if "mtu" in self.params: - self.matched.m1.eth0.mtu = self.params.mtu - self.matched.m2.eth0.mtu = self.params.mtu + m1.eth0.mtu = self.params.mtu + m2.eth0.mtu = self.params.mtu + + m1.eth0.up() + m2.eth0.up() + + if1 = m1.eth0 + ip2 = m2.eth0.ips[0] + cn = self.params.count + iv = self.params.interval + sz = self.params.size
- self.matched.m1.eth0.up() - self.matched.m2.eth0.up() + pcfg=PingConf(m1, if1, m2, ip2, count = cn, interval = iv, size = sz or None)
- ping_job = self.matched.m1.run(Ping(dst=self.matched.m2.eth0.ips[0], count=100, interval=0.2, - interface=self.matched.m1.eth0)) + result = self.ping_test(pcfg) + self.ping_evaluate_and_report(pcfg, result)
On Fri, Oct 26, 2018 at 10:46:45AM +0200, csfakian@redhat.com wrote:
From: Christos Sfakianakis csfakian@redhat.com
Inherit from PingTestAndEvaluate and allow the user to choose parameters like ping count, ping interval, packet size.
Signed-off-by: Christos Sfakianakis csfakian@redhat.com
lnst/Recipes/ENRT/PingFloodRecipe.py | 42 ++++++++++++++++++---------- 1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/lnst/Recipes/ENRT/PingFloodRecipe.py b/lnst/Recipes/ENRT/PingFloodRecipe.py index 54c4e1f..b7fff01 100644 --- a/lnst/Recipes/ENRT/PingFloodRecipe.py +++ b/lnst/Recipes/ENRT/PingFloodRecipe.py @@ -1,34 +1,48 @@ #!/bin/python2 """ Implements scenario similar to regression_tests/phase1/ -(ping_flood.xml + simple_ping.py) +(ping_flood.xml + simple_ping.py). """
-from lnst.Common.Parameters import Param +from lnst.Common.Parameters import Param, IntParam, StrParam from lnst.Common.IpAddress import ipaddress -from lnst.Controller import HostReq, DeviceReq, BaseRecipe -from lnst.Tests import Ping +from lnst.Controller import HostReq, DeviceReq +from lnst.RecipeCommon.Ping import PingConf, PingTestAndEvaluate
-#TODO: Inherit just from PingTestAndEvaluate after enabling patch is available -class PingFloodRecipe(BaseRecipe): +class PingFloodRecipe(PingTestAndEvaluate): m1 = HostReq() m1.eth0 = DeviceReq(label="net1")
m2 = HostReq() m2.eth0 = DeviceReq(label="net1")
- #TODO: use a parameter for the network
- src_addr = StrParam(default = "192.168.1.1/24")
- dst_addr = StrParam(default = "192.168.1.2/24")
- count = IntParam(default = 100)
- interval = StrParam(default = 0.2)
- size = IntParam(default = None)
- def test(self): m1, m2 = self.matched.m1, self.matched.m2
self.matched.m1.eth0.ip_add(ipaddress("192.168.1.1/24"))self.matched.m2.eth0.ip_add(ipaddress("192.168.1.2/24"))
m1.eth0.ip_add(ipaddress(self.params.src_addr))m2.eth0.ip_add(ipaddress(self.params.dst_addr)) if "mtu" in self.params:
self.matched.m1.eth0.mtu = self.params.mtuself.matched.m2.eth0.mtu = self.params.mtu
m1.eth0.mtu = self.params.mtum2.eth0.mtu = self.params.mtum1.eth0.up()m2.eth0.up()if1 = m1.eth0ip2 = m2.eth0.ips[0]cn = self.params.countiv = self.params.intervalsz = self.params.size
self.matched.m1.eth0.up()self.matched.m2.eth0.up()
pcfg=PingConf(m1, if1, m2, ip2, count = cn, interval = iv, size = sz or None)
ping_job = self.matched.m1.run(Ping(dst=self.matched.m2.eth0.ips[0], count=100, interval=0.2,interface=self.matched.m1.eth0))
result = self.ping_test(pcfg)self.ping_evaluate_and_report(pcfg, result)-- 2.17.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://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedorahos...
This looks ok so I'll apply it, I'll edit the commit message to contain the commit reference that is mentioned in the cover letter.
-Ondrej
lnst-developers@lists.fedorahosted.org