This test aims to verify that the route update flow is working on a
stressed situation.
The test algorithm is:
- Add 100 (S,G) random routes
- Add 100 (*,G) random routes
- Test random subset of the routes with traffic
- Update all the routes
- Test random subset of the updated routes with traffic
- Remove all routes in random order
To allow that, add the MrouteTest.random_mroute_add helper function.
Signed-off-by: Yotam Gigi <yotamg(a)mellanox.com>
---
recipes/switchdev/mr-009-stressed_update.py | 114 +++++++++++++++++++++++++++
recipes/switchdev/mr-009-stressed_update.xml | 5 ++
recipes/switchdev/mr_common.py | 26 ++++++
3 files changed, 145 insertions(+)
create mode 100644 recipes/switchdev/mr-009-stressed_update.py
create mode 100644 recipes/switchdev/mr-009-stressed_update.xml
diff --git a/recipes/switchdev/mr-009-stressed_update.py
b/recipes/switchdev/mr-009-stressed_update.py
new file mode 100644
index 0000000..a4b5cc5
--- /dev/null
+++ b/recipes/switchdev/mr-009-stressed_update.py
@@ -0,0 +1,114 @@
+"""
+Copyright 2017 Mellanox Technologies. All rights reserved.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+yotamg(a)mellanox.com (Yotam Gigi)
+"""
+
+from lnst.Controller.Task import ctl
+from lnst.Common.Consts import MROUTE
+from TestLib import TestLib
+from time import sleep
+from mr_common import MrouteTest
+import random
+
+MANY_ROUTES = 100
+SOME_ROUTES = 20
+
+def test_ip(major, minor):
+ return ["192.168.%d.%d" % (major, minor),
+ "2002:%d::%d" % (major, minor)]
+def ipv4(ip):
+ return ip[0]
+
+def mcgrp(num):
+ return "239.255.%d.%d" % (num/0x100, num%0x100)
+
+def do_task(ctl, hosts, ifaces, aliases):
+ m1, m2, sw = hosts
+ m1_if1, m1_if2, m2_if1, m2_if2, m2_if3, m2_if4, sw_if1, \
+ sw_br_m1, sw_br_m2, sw_if3, sw_if4, sw_if5, sw_if2 = ifaces
+
+ sw_ports = [sw_if1, sw_if2, sw_if3, sw_if4, sw_if5]
+
+ tl = TestLib(ctl, aliases)
+ mt = MrouteTest(tl, hosts, ifaces)
+
+ sleep(30)
+ mt.init()
+
+ # add vifs
+ mt.add_vif(sw_if1, 0)
+ mt.add_vif(sw_if2, 1)
+ mt.add_vif(sw_if3, 2)
+ mt.add_vif(sw_if4, 3)
+ mt.add_vif(sw_if5, 4)
+ mt.pimreg_add(5)
+
+ # add many (S,G) routes
+ sg_mroutes = []
+ for i in range(MANY_ROUTES):
+ sg = mt.random_mroute_add(mcgrp(i + 1), False, test = False)
+ sg_mroutes.append(sg)
+
+ # add many (*,G) routes
+ starg_mroutes = []
+ for i in range(MANY_ROUTES):
+ starg = mt.random_mroute_add(mcgrp(MANY_ROUTES + i + 1), True,
+ test = False)
+ starg_mroutes.append(starg)
+
+ # create a shuffled route list
+ mroutes = sg_mroutes + starg_mroutes
+ random.shuffle(mroutes)
+
+ # test some routes
+ some_mroutes = mroutes[:SOME_ROUTES]
+ for mroute in some_mroutes:
+ mt.mroute_test(mroute)
+
+ for i, sg in enumerate(sg_mroutes):
+ sg = mt.random_mroute_add(mcgrp(i + 1), False, ivif = sg["ivif"],
+ test = False)
+ sg_mroutes[i] = sg
+
+ for i, starg in enumerate(starg_mroutes):
+ starg = mt.random_mroute_add(mcgrp(MANY_ROUTES + i + 1), True,
+ test = False)
+ starg_mroutes[i] = starg
+
+ # create a shuffled route list
+ mroutes = sg_mroutes + starg_mroutes
+ random.shuffle(mroutes)
+
+ # test some routes
+ some_mroutes = mroutes[:SOME_ROUTES]
+ for mroute in some_mroutes:
+ mt.mroute_test(mroute)
+
+ # delete all in random order, as mroutes is shuffled
+ for mroute in mroutes:
+ mt.mroute_remove(mroute, test = False)
+
+ mt.fini()
+
+do_task(ctl, [ctl.get_host("machine1"),
+ ctl.get_host("machine2"),
+ ctl.get_host("switch")],
+ [ctl.get_host("machine1").get_interface("if1"),
+ ctl.get_host("machine1").get_interface("if2"),
+ ctl.get_host("machine2").get_interface("if1"),
+ ctl.get_host("machine2").get_interface("if2"),
+ ctl.get_host("machine2").get_interface("if3"),
+ ctl.get_host("machine2").get_interface("if4"),
+ ctl.get_host("switch").get_interface("if1"),
+ ctl.get_host("switch").get_interface("if2"),
+ ctl.get_host("switch").get_interface("if3"),
+ ctl.get_host("switch").get_interface("if4"),
+ ctl.get_host("switch").get_interface("if5"),
+ ctl.get_host("switch").get_interface("if6"),
+ ctl.get_host("switch").get_interface("br0")],
+ ctl.get_aliases())
diff --git a/recipes/switchdev/mr-009-stressed_update.xml
b/recipes/switchdev/mr-009-stressed_update.xml
new file mode 100644
index 0000000..3e7af6d
--- /dev/null
+++ b/recipes/switchdev/mr-009-stressed_update.xml
@@ -0,0 +1,5 @@
+<lnstrecipe
xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="default_aliases.xml" />
+ <xi:include href="mr_common_topology.xml" />
+ <task python="mr-009-stressed_update.py" />
+</lnstrecipe>
diff --git a/recipes/switchdev/mr_common.py b/recipes/switchdev/mr_common.py
index 69dcdb6..2b53827 100644
--- a/recipes/switchdev/mr_common.py
+++ b/recipes/switchdev/mr_common.py
@@ -2,6 +2,7 @@ from time import sleep
from lnst.Controller.Task import ctl
from lnst.Common.Consts import MROUTE
import copy
+import random
# The topology used is:
#
@@ -203,3 +204,28 @@ class MrouteTest:
if test:
self.test_fwd(mroute["group"],
self.vif2port[mroute["ivif"]], [])
+
+ def _random_evifs(self, ivif, starg):
+ vifs = self.vif2port.keys()
+ evifs = [evif for evif in vifs
+ if random.choice([True, False]) and evif != ivif]
+ if starg:
+ evifs += [ivif]
+ return evifs
+
+ def random_mroute_add(self, group, starg, ivif = None, test = True):
+ vifs = self.vif2port.keys()
+
+ if not ivif:
+ ivif = random.choice(vifs)
+ evifs = self._random_evifs(ivif, starg)
+ if starg:
+ source = "0.0.0.0"
+ else:
+ if self.vif2port[ivif] != "pimreg":
+ source_port = self.sw_mach_conn[self.vif2port[ivif]][0]
+ source = str(source_port.get_ip(0))
+ else:
+ source = "1.2.3.4"
+
+ return self.mroute_create(source, group, ivif, evifs, test)
--
2.8.4