creating a new test suite to find out maximum number of switches connected 17/23017/3
authorPeter Gubka <pgubka@cisco.com>
Fri, 19 Jun 2015 23:19:16 +0000 (01:19 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 29 Jun 2015 16:40:22 +0000 (16:40 +0000)
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 <pgubka@cisco.com>
test/csit/libraries/DynamicMininet.py [new file with mode: 0644]
test/csit/suites/openflowplugin/Maximum_Switches/020__find_max_switches.robot [new file with mode: 0644]
test/csit/testplans/openflowplugin-scalability-daily-lithium-redesign.txt
test/csit/testplans/openflowplugin-scalability-daily.txt
test/csit/testplans/openflowplugin-sw-scalability-daily-lithium-redesign.txt [new file with mode: 0644]
test/csit/testplans/openflowplugin-sw-scalability-daily.txt [new file with mode: 0644]

diff --git a/test/csit/libraries/DynamicMininet.py b/test/csit/libraries/DynamicMininet.py
new file mode 100644 (file)
index 0000000..c3c698d
--- /dev/null
@@ -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 <controller> <num>'
+       3) add another switches using 'add_switch' or 'add_switches <num>'
+       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 <controller_ip> <num>'
+        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 <num>'
+        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 (file)
index 0000000..b818753
--- /dev/null
@@ -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}
index 2761e3d01eccdeb7df121450498cb692e680f1dc..7480280ee2f0be0ee54e3be9b42e2c17c9ce0ef2 100644 (file)
@@ -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
index 2761e3d01eccdeb7df121450498cb692e680f1dc..7480280ee2f0be0ee54e3be9b42e2c17c9ce0ef2 100644 (file)
@@ -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 (file)
index 0000000..9fe2056
--- /dev/null
@@ -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 (file)
index 0000000..9fe2056
--- /dev/null
@@ -0,0 +1,2 @@
+# Place the suites in run order:
+integration/test/csit/suites/openflowplugin/Maximum_Switches/020__finding_max_switches.robot