From 7046fc9beffa1c94a30cece84597800e17fef037 Mon Sep 17 00:00:00 2001 From: Peter Gubka Date: Sat, 20 Jun 2015 01:19:16 +0200 Subject: [PATCH] creating a new test suite to find out maximum number of switches connected the idea is not to start and stop mininet with different paramentes, but to add (and remove) switches to the running topology the other idea is to make that test not as long as the one running from ../../../testplans/openflowplugin-scalability-daily.txt (1.5h). The new suite has to last much less. Existing testplans were updated to point on certain files, not the whole directory, so new robot file can be placed there. Change-Id: Ifc7c9beb103b87d049f112ac57215705b8364412 Signed-off-by: Peter Gubka --- test/csit/libraries/DynamicMininet.py | 119 ++++++++++++++++++ .../020__find_max_switches.robot | 70 +++++++++++ ...gin-scalability-daily-lithium-redesign.txt | 2 +- .../openflowplugin-scalability-daily.txt | 2 +- ...-sw-scalability-daily-lithium-redesign.txt | 2 + .../openflowplugin-sw-scalability-daily.txt | 2 + 6 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 test/csit/libraries/DynamicMininet.py create mode 100644 test/csit/suites/openflowplugin/Maximum_Switches/020__find_max_switches.robot create mode 100644 test/csit/testplans/openflowplugin-sw-scalability-daily-lithium-redesign.txt create mode 100644 test/csit/testplans/openflowplugin-sw-scalability-daily.txt diff --git a/test/csit/libraries/DynamicMininet.py b/test/csit/libraries/DynamicMininet.py new file mode 100644 index 0000000000..c3c698d1d5 --- /dev/null +++ b/test/csit/libraries/DynamicMininet.py @@ -0,0 +1,119 @@ +""" +New CLI for mininet which should dynamically add and delete switches from network" +""" + +import cmd +# import json +# import logging + +import mininet.node +import mininet.topo +import mininet.net +import mininet.util +from mininet.node import RemoteController +from mininet.node import OVSKernelSwitch + + +class DynamicMininet(cmd.Cmd): + """Cli wrapper over Mininet network instance tool. + + - when starting this CLI the 'mininet> ' cli appears, but no switches are active + - topology is very simple, just as many single switches without any hosts nor links + - how to use it: + 1) start cli + 2) start mininet using command 'start ' + 3) add another switches using 'add_switch' or 'add_switches ' + 4) stop mininet usinf 'exit' + """ + + prompt = 'mininet> ' + + def __init__(self): + cmd.Cmd.__init__(self) + self._running = False + self._net = None + self._topo = None + # last used switch id + self._lid = 0 + + def do_start(self, line): + """Starts mininet network with initial number of switches + + Args: + :param controller_ip: controller's ip address or host name + :param num: initial number of switches in the topology + """ + if self._running: + print 'Mininet topology is already active' + return + cntl, numsw = line.split() + self._topo = mininet.topo.Topo() + for _ in range(int(numsw)): + self._lid += 1 + self._topo.addSwitch('s{}'.format(self._lid)) + controller = mininet.util.customConstructor({'remote': RemoteController}, 'remote,ip={0}'.format(cntl)) + switch = mininet.util.customConstructor({'ovsk': OVSKernelSwitch}, 'ovsk,protocols=OpenFlow13') + self._net = mininet.net.Mininet(topo=self._topo, switch=switch, controller=controller) + self._net.start() + self._running = True + + def help_start(self): + """Provide help message for start command""" + print 'Starts mininet' + print 'Usage: start ' + print '\tcontroller_ip - controllers ip or host name' + print '\tnum - number of switches at start' + + def do_add_switch(self, line): + """Adds one switch to the network + Args: + no args (any given agrs are ignored) + """ + if not self._running: + raise RuntimeError('Network not running, use command "start" first') + self._lid += 1 + sname = 's{0}'.format(self._lid) + self._topo.addSwitch(sname) + self._net.addSwitch(sname, **self._topo.nodeInfo(sname)) + s = self._net.get(sname) + c = self._net.get('c0') + s.start([c]) + + def help_add_switch(self): + """Provide help message for add_switch command""" + print 'Adds one sinle switch to the running topology' + print 'Usage: add_switch' + + def do_add_switches(self, line): + """Adds switches to the network + Args: + :param num: number of switches to be added to the running topology + """ + for i in range(int(line)): + self.do_add_switch("") + + def help_add_switches(self): + """Provide help message for add_switch command""" + print 'Adds one sinle switch to the running topology' + print 'Usage: add_switches ' + print '\tnum - number of switches tp be added' + + def do_exit(self, line): + """Stops mininet""" + if self._running: + self._net.stop() + self._running = False + return True + + def help_exit(self, line): + """Provide help message for exit command""" + print 'Exit mininet cli' + print 'Usage: exit' + + def emptyline(self): + pass + + +if __name__ == '__main__': + dynamic_mininet_cli = DynamicMininet() + dynamic_mininet_cli.cmdloop() diff --git a/test/csit/suites/openflowplugin/Maximum_Switches/020__find_max_switches.robot b/test/csit/suites/openflowplugin/Maximum_Switches/020__find_max_switches.robot new file mode 100644 index 0000000000..b8187537f6 --- /dev/null +++ b/test/csit/suites/openflowplugin/Maximum_Switches/020__find_max_switches.robot @@ -0,0 +1,70 @@ +*** Settings *** +Documentation Test suite to find maximum switches which can be connected to the controller +Suite Setup Start Suite +Suite Teardown Stop Suite +Library SSHLibrary +Library ../../../libraries/ScaleClient.py +Library OperatingSystem + +*** Variables *** +${start} sudo python DynamicMininet.py +${linux_prompt} > +${max_sw} 500 +${step_sw} 10 +${init_sw} 10 +${max_found} 0 +${outfile} max_found.csv + +*** Test Cases *** +Find Max Switches + [Documentation] Will find out max switches starting from ${start_sw} till reaching ${max_sw} with step defined by ${step_sw} + ${init_sw} Convert to Integer ${init_sw} + ${max_sw} Convert to Integer ${max_sw} + ${step_sw} Convert to Integer ${step_sw} + : FOR ${exp_sw} IN RANGE ${init_sw} ${max_sw+1} ${step_sw} + \ BuiltIn.Wait Until Keyword Succeeds 15s 5s Verify Switches Connected + \ ${max_found}= Set Variable ${exp_sw} + \ Set Suite variable ${max_found} + \ Add Switches 10 + [Teardown] Log Store Max Found + +*** Keywords *** +Start Suite + [Documentation] Starts mininet with requested number of switches + Log Start the test on the base edition + Open Connection ${MININET} prompt=> timeout=1800 + Login With Public Key ${MININET_USER} ${USER_HOME}/.ssh/id_rsa any + Put File ${CURDIR}/../../../libraries/DynamicMininet.py DynamicMininet.py + Execute Command sudo ovs-vsctl set-manager ptcp:6644 + Execute Command sudo mn -c + Write ${start} + Read Until mininet> + Write start ${CONTROLLER} ${init_sw} + Read Until mininet> + Sleep 1s + ${sw} ${rep} ${found}= Flow Stats Collected controller=${CONTROLLER} + Should Be Equal As Numbers ${sw} ${init_sw} + +Stop Suite + [Documentation] Stops mininet + Log Stop the test on the base edition + Read + Write exit + Read Until ${linux_prompt} + Close Connection + +Add Switches + [Arguments] ${nr_switches} + [Documentation] Adds requested number of switches to the network + Write add_switches ${nr_switches} + Read Until mininet> + +Verify Switches Connected + [Documentation] Verifies if switches are connected/present in operational inventory + ${sw} ${rep} ${found}= Flow Stats Collected controller=${CONTROLLER} + Should Be Equal As Numbers ${sw} ${exp_sw} + +Log Store Max Found + [Documentation] Logs the found number + Log To Console ${max_found} + Append To File ${out_file} Max\n${max_found} diff --git a/test/csit/testplans/openflowplugin-scalability-daily-lithium-redesign.txt b/test/csit/testplans/openflowplugin-scalability-daily-lithium-redesign.txt index 2761e3d01e..7480280ee2 100644 --- a/test/csit/testplans/openflowplugin-scalability-daily-lithium-redesign.txt +++ b/test/csit/testplans/openflowplugin-scalability-daily-lithium-redesign.txt @@ -1,2 +1,2 @@ # Place the suites in run order: -integration/test/csit/suites/openflowplugin/Maximum_Switches +integration/test/csit/suites/openflowplugin/Maximum_Switches/010__finding_max_switches.txt diff --git a/test/csit/testplans/openflowplugin-scalability-daily.txt b/test/csit/testplans/openflowplugin-scalability-daily.txt index 2761e3d01e..7480280ee2 100644 --- a/test/csit/testplans/openflowplugin-scalability-daily.txt +++ b/test/csit/testplans/openflowplugin-scalability-daily.txt @@ -1,2 +1,2 @@ # Place the suites in run order: -integration/test/csit/suites/openflowplugin/Maximum_Switches +integration/test/csit/suites/openflowplugin/Maximum_Switches/010__finding_max_switches.txt diff --git a/test/csit/testplans/openflowplugin-sw-scalability-daily-lithium-redesign.txt b/test/csit/testplans/openflowplugin-sw-scalability-daily-lithium-redesign.txt new file mode 100644 index 0000000000..9fe20568aa --- /dev/null +++ b/test/csit/testplans/openflowplugin-sw-scalability-daily-lithium-redesign.txt @@ -0,0 +1,2 @@ +# Place the suites in run order: +integration/test/csit/suites/openflowplugin/Maximum_Switches/020__finding_max_switches.robot diff --git a/test/csit/testplans/openflowplugin-sw-scalability-daily.txt b/test/csit/testplans/openflowplugin-sw-scalability-daily.txt new file mode 100644 index 0000000000..9fe20568aa --- /dev/null +++ b/test/csit/testplans/openflowplugin-sw-scalability-daily.txt @@ -0,0 +1,2 @@ +# Place the suites in run order: +integration/test/csit/suites/openflowplugin/Maximum_Switches/020__finding_max_switches.robot -- 2.36.6