From: Christos Sfakianakis <csfakian(a)redhat.com>
Adding 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.
Signed-off-by: Christos Sfakianakis <csfakian(a)redhat.com>
---
lnst/Recipes/ENRT/PingFloodRecipe.py | 34 ++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 lnst/Recipes/ENRT/PingFloodRecipe.py
diff --git a/lnst/Recipes/ENRT/PingFloodRecipe.py b/lnst/Recipes/ENRT/PingFloodRecipe.py
new file mode 100644
index 0000000..54c4e1f
--- /dev/null
+++ b/lnst/Recipes/ENRT/PingFloodRecipe.py
@@ -0,0 +1,34 @@
+#!/bin/python2
+"""
+Implements scenario similar to regression_tests/phase1/
+(ping_flood.xml + simple_ping.py)
+"""
+
+from lnst.Common.Parameters import Param
+from lnst.Common.IpAddress import ipaddress
+from lnst.Controller import HostReq, DeviceReq, BaseRecipe
+from lnst.Tests import Ping
+
+#TODO: Inherit just from PingTestAndEvaluate after enabling patch is available
+class PingFloodRecipe(BaseRecipe):
+ m1 = HostReq()
+ m1.eth0 = DeviceReq(label="net1")
+
+ m2 = HostReq()
+ m2.eth0 = DeviceReq(label="net1")
+
+ 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"))
+
+ if "mtu" in self.params:
+ self.matched.m1.eth0.mtu = self.params.mtu
+ self.matched.m2.eth0.mtu = self.params.mtu
+
+ self.matched.m1.eth0.up()
+ self.matched.m2.eth0.up()
+
+ ping_job = self.matched.m1.run(Ping(dst=self.matched.m2.eth0.ips[0], count=100,
interval=0.2,
+ interface=self.matched.m1.eth0))
--
2.17.1