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: add PingFloodRecipe
lnst/Recipes/ENRT/PingFloodRecipe.py | 36 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-)
From: Christos Sfakianakis csfakian@redhat.com
Add ported recipe PingFloodRecipe, implementing old regression_tests/phase1/ping_flood.xml. Its PingFloodRecipe class is an immediate subclass of BaseRecipe. It is almost identical to examples/python_recipe.py.
v2: Set interval=0.2 and count=100. Correct false comment in test method and add TODO for future reference.
v3: Inherit from PingTestAndEvaluate and allow the user to choose source/destination ip address, ping count, ping interval, packet size.
Signed-off-by: Christos Sfakianakis csfakian@redhat.com --- lnst/Recipes/ENRT/PingFloodRecipe.py | 36 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/lnst/Recipes/ENRT/PingFloodRecipe.py b/lnst/Recipes/ENRT/PingFloodRecipe.py index 54c4e1f..910e916 100644 --- a/lnst/Recipes/ENRT/PingFloodRecipe.py +++ b/lnst/Recipes/ENRT/PingFloodRecipe.py @@ -1,34 +1,42 @@ #!/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")
+ 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()
- self.matched.m1.eth0.up() - self.matched.m2.eth0.up() + ping_config=PingConf(m1, m1.eth0, m2, m2.eth0.ips[0], count = self.params.count, + interval = self.params.interval, size = self.params.size 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(ping_config) + self.ping_evaluate_and_report(ping_config, result)
On Tue, Sep 18, 2018 at 03:49:47PM +0200, csfakian@redhat.com wrote:
From: Christos Sfakianakis csfakian@redhat.com
Add ported recipe PingFloodRecipe, implementing old regression_tests/phase1/ping_flood.xml. Its PingFloodRecipe class is an immediate subclass of BaseRecipe. It is almost identical to examples/python_recipe.py.
v2: Set interval=0.2 and count=100. Correct false comment in test method and add TODO for future reference.
v3: Inherit from PingTestAndEvaluate and allow the user to choose source/destination ip address, ping count, ping interval, packet size.
This isn't a "add PingFloddRecipe" commit or a v3 anymore... the v2 was applied already and pushed upstream.
This should now be a "lnst.Recipes.ENRT.PingFloodRecipe: rework to inherit from PingTestAndEvaluate"
And the commit exaplanation should be just about that change.
Signed-off-by: Christos Sfakianakis csfakian@redhat.com
lnst/Recipes/ENRT/PingFloodRecipe.py | 36 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/lnst/Recipes/ENRT/PingFloodRecipe.py b/lnst/Recipes/ENRT/PingFloodRecipe.py index 54c4e1f..910e916 100644 --- a/lnst/Recipes/ENRT/PingFloodRecipe.py +++ b/lnst/Recipes/ENRT/PingFloodRecipe.py @@ -1,34 +1,42 @@ #!/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")
- src_addr = StrParam(default = "192.168.1.1/24")
- dst_addr = StrParam(default =" 192.168.1.2/24")
^ there's a space that shouldn't be there
Also, I don't think {src, dst}_addr should be parameters, if we want to go by the example of the original ping_flood.xml we should instead have a parameter for the network, but keep the address selection as part of the test code.
But we don't have good support for specifying a network yet so I'd skip it for now...
- 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()
self.matched.m1.eth0.up()self.matched.m2.eth0.up()
ping_config=PingConf(m1, m1.eth0, m2, m2.eth0.ips[0], count = self.params.count,interval = self.params.interval, size = self.params.size 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))
Can we keep the lines under 80 chars? Make the argument specification a bit more readable by editing it a little...
result = self.ping_test(ping_config)self.ping_evaluate_and_report(ping_config, result)
-Ondrej
lnst-developers@lists.fedorahosted.org