Basic Test suite to Test the VXLAN Functionality 61/23661/20
authorChaudhry Muhammad Usama <chaudhryusama@gmail.com>
Wed, 1 Jul 2015 21:13:11 +0000 (14:13 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 15 Jul 2015 22:23:09 +0000 (22:23 +0000)
Change-Id: Ic4c1552a4e4bb43b17d1ae62f3708280dc7791f7
Signed-off-by: Chaudhry Muhammad Usama <chaudhryusama@gmail.com>
test/csit/libraries/OVSDB.robot [new file with mode: 0644]
test/csit/libraries/Utils.txt
test/csit/suites/ovsdb/Southbound_Domain/040__Vxlan_Extension_Test.robot [new file with mode: 0644]
test/csit/variables/ovsdb/add_flow_rule1.xml [new file with mode: 0644]
test/csit/variables/ovsdb/add_flow_rule2.xml [new file with mode: 0644]
test/csit/variables/ovsdb/ovsdb.py [new file with mode: 0644]

diff --git a/test/csit/libraries/OVSDB.robot b/test/csit/libraries/OVSDB.robot
new file mode 100644 (file)
index 0000000..bc9ac92
--- /dev/null
@@ -0,0 +1,59 @@
+*** Settings ***
+Library           SSHLibrary
+Resource          Utils.txt
+Library           String
+Library           Collections
+Variables         ../variables/Variables.py
+Library           RequestsLibrary
+
+*** Variables ***
+${OVSDB_CONFIG_DIR}    ../variables/ovsdb
+${SOUTHBOUND_CONFIG_API}    ${CONFIG_TOPO_API}/topology/ovsdb:1/node/ovsdb:%2F%2F
+
+*** Keywords ***
+Connect To Ovsdb Node
+    [Arguments]    ${mininet_ip}
+    [Documentation]    This will Initiate the connection to OVSDB node from controller
+    ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/connect.json
+    ${sample1}    Replace String    ${sample}    127.0.0.1    ${mininet_ip}
+    ${body}    Replace String    ${sample1}    61644    ${OVSDB_PORT}
+    Log    URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}
+    ${resp}    RequestsLibrary.Put    session    ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Disconnect From Ovsdb Node
+    [Arguments]    ${mininet_ip}
+    [Documentation]    This request will disconnect the OVSDB node from the controller
+    ${resp}    RequestsLibrary.Delete    session    ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Add Bridge To Ovsdb Node
+    [Arguments]    ${mininet_ip}    ${bridge_num}    ${datapath_id}
+    [Documentation]    This will create a bridge and add it to the OVSDB node.
+    ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_bridge.json
+    ${sample1}    Replace String    ${sample}    tcp:127.0.0.1:6633    tcp:${CONTROLLER}:6633
+    ${sample2}    Replace String    ${sample1}    127.0.0.1    ${mininet_ip}
+    ${sample3}    Replace String    ${sample2}    br01    ${bridge_num}
+    ${sample4}    Replace String    ${sample3}    61644    ${OVSDB_PORT}
+    ${body}    Replace String    ${sample4}    0000000000000001    ${datapath_id}
+    Log    URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}
+    ${resp}    RequestsLibrary.Put    session    ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Delete Bridge From Ovsdb Node
+    [Arguments]    ${mininet_ip}    ${bridge_num}
+    [Documentation]    This request will delete the bridge node from the OVSDB
+    ${resp}    RequestsLibrary.Delete    session    ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Add Vxlan To Bridge
+    [Arguments]    ${mininet_ip}    ${bridge_num}    ${vxlan_port}    ${remote_ip}
+    [Documentation]    This request will create vxlan port for vxlan tunnel and attach it to the specific bridge
+    ${sample}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/create_port.json
+    ${body}    Replace String    ${sample}    192.168.0.21    ${remote_ip}
+    Log    URL is ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}/termination-point/${vxlan_port}/
+    ${resp}    RequestsLibrary.Put    session    ${SOUTHBOUND_CONFIG_API}${mininet_ip}:${OVSDB_PORT}%2Fbridge%2F${bridge_num}/termination-point/${vxlan_port}/    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
index 0a648eeeb951b86972c1ccad9a976b89cd24a470..8a28ad081795411f776fe6a5eaa2a3cf40b4c1a2 100644 (file)
@@ -21,6 +21,27 @@ Start Suite
     Write    ${start}
     Read Until    mininet>
 
+Start Mininet
+    [Arguments]    ${MININET}    ${cmd}=${start}    ${custom}=${OVSDB_CONFIG_DIR}/ovsdb.py    ${user}=${MININET_USER}    ${prompt}=${LINUX_PROMPT}    ${prompt_timeout}=30s
+    [Documentation]    Basic setup to start mininet with custom topology
+    Log    Start the test on the base edition
+    Clean Mininet System
+    ${mininet_conn_id}=    Open Connection    ${MININET}    prompt=${LINUX_PROMPT}    timeout=30s
+    Set Suite Variable    ${mininet_conn_id}
+    Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/id_rsa    any
+    Put File    ${custom}
+    Write    ${cmd}
+    Read Until    mininet>
+    [Return]    ${mininet_conn_id}
+
+Stop Mininet
+    [Arguments]    ${mininet_conn_id}    ${prompt}=${LINUX_PROMPT}
+    [Documentation]    Basic setup to stop/clean mininet
+    Switch Connection    ${mininet_conn_id}
+    SSHLibrary.Write    exit
+    Read Until    ${LINUX_PROMPT}
+    Close Connection
+
 Stop Suite
     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all
     ...    tests
@@ -91,9 +112,9 @@ Check For Elements Not At URI
     \    Should Not Contain    ${resp.content}    ${i}
 
 Clean Mininet System
-    [Arguments]     ${mininet_system}=${MININET}
-    Run Command On Remote System    ${mininet_system}   sudo mn -c
-    Run Command On Remote System    ${mininet_system}   sudo ps -elf | egrep 'usr/local/bin/mn' | egrep python | awk '{print "sudo kill -9",$4}' | sh
+    [Arguments]    ${mininet_system}=${MININET}
+    Run Command On Remote System    ${mininet_system}    sudo mn -c
+    Run Command On Remote System    ${mininet_system}    sudo ps -elf | egrep 'usr/local/bin/mn' | egrep python | awk '{print "sudo kill -9",$4}' | sh
 
 Clean Up Ovs
     [Arguments]     ${mininet_system}=${MININET}
diff --git a/test/csit/suites/ovsdb/Southbound_Domain/040__Vxlan_Extension_Test.robot b/test/csit/suites/ovsdb/Southbound_Domain/040__Vxlan_Extension_Test.robot
new file mode 100644 (file)
index 0000000..953be63
--- /dev/null
@@ -0,0 +1,182 @@
+*** Settings ***
+Documentation     Test suite for Connection Manager
+Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
+Suite Teardown    Delete All Sessions
+Library           OperatingSystem
+Library           String
+Library           Collections
+Library           SSHLibrary
+Library           RequestsLibrary
+Library           ../../../libraries/Common.py
+Variables         ../../../variables/Variables.py
+Resource          ../../../libraries/Utils.txt
+Resource          ../../../libraries/OVSDB.robot
+
+*** Variables ***
+${OVSDB_PORT}     6634
+${OVSDB_CONFIG_DIR}    ${CURDIR}/../../../variables/ovsdb
+@{node_list1}     ovsdb://${MININET1}:${OVSDB_PORT}    ${MININET1}    ${OVSDB_PORT}    ovsdb://${MININET}:${OVSDB_PORT}    ${MININET}    ${OVSDB_PORT}    br-int
+${start1}         sudo mn --controller=remote,ip=${CONTROLLER} --switch=ovsk,protocols=OpenFlow13 --custom ovsdb.py --topo host,1
+${start2}         sudo mn --controller=remote,ip=${CONTROLLER} --switch=ovsk,protocols=OpenFlow13 --custom ovsdb.py --topo host,2
+
+*** Test Cases ***
+Make the OVS instance to listen for connection
+    [Tags]    Southbound
+    Run Command On Remote System    ${MININET1}    sudo ovs-vsctl del-manager
+    Run Command On Remote System    ${MININET1}    sudo ovs-vsctl set-manager ptcp:6634
+    Run Command On Remote System    ${MININET}    sudo ovs-vsctl del-manager
+    Run Command On Remote System    ${MININET}    sudo ovs-vsctl set-manager ptcp:6634
+
+Connect controller to OVSDB Node1
+    [Documentation]    Initiate the connection to OVSDB node from controller
+    [Tags]    Southbound
+    Connect To Ovsdb Node    ${MININET1}
+
+Connect controller to OVSDB Node2
+    [Documentation]    Initiate the connection to OVSDB node from controller
+    [Tags]    Southbound
+    Connect To Ovsdb Node    ${MININET}
+
+Get Operational Topology from OVSDB Node1 and OVSDB Node2
+    [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
+    [Tags]    Southbound
+    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${node_list1}
+
+Delete the integration Bridge from OVSDB node 1 and 2 and Verify it
+    [Documentation]    This request will delete the integation bridge node from the OVSDB as we don't need it and verify the operation.
+    [Tags]    Southbound
+    Delete Bridge From Ovsdb Node    ${MININET}    br-int
+    Delete Bridge From Ovsdb Node    ${MININET1}    br-int
+    @{list}    Create List    br-int
+    Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
+
+Start the Mininet and create custom topology
+    [Documentation]    This will start mininet with custom topology on both the Virtual Machines
+    [Tags]    Southbound
+    ${conn_id1}    Start Mininet    ${MININET1}    ${start1}    ${OVSDB_CONFIG_DIR}/ovsdb.py
+    Set Global Variable    ${conn_id1}
+    ${conn_id2}    Start Mininet    ${MININET}    ${start2}    ${OVSDB_CONFIG_DIR}/ovsdb.py
+    Set Global Variable    ${conn_id2}
+
+Get Operational Topology with custom topology
+    [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes to make sure the mininet created custom topology
+    [Tags]    Southbound
+    @{list}    Create List    s1    s2
+    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
+
+Add the bridge s1 in the config datastore of OVSDB Node1
+    [Documentation]    This request will add already operational bridge to the config data store of the OVSDB node.
+    [Tags]    Southbound
+    Add Bridge To Ovsdb Node    ${MININET1}    s1    0000000000000001
+
+Add the bridge s2 in the config datastore of OVSDB Node2
+    [Documentation]    This request will add already operational bridge to the config data store of the OVSDB node.
+    [Tags]    Southbound
+    Add Bridge To Ovsdb Node    ${MININET}    s2    0000000000000002
+
+Get Config Topology with s1 and s2 Bridges
+    [Documentation]    This will fetch the configuration topology from configuration data store to verify the bridge is added to the config data store
+    [Tags]    Southbound
+    @{list}    Create List    s1    s2
+    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${CONFIG_TOPO_API}    ${list}
+
+Create Vxlan Port and attach to s1 Bridge
+    [Documentation]    This request will create vxlan port/interface for vxlan tunnel and attach it to the specific bridge s1 of OVSDB node 1
+    [Tags]    Southbound
+    Add Vxlan To Bridge    ${MININET}    s2    vxlanport    ${MININET1}
+
+Create Vxlan Port and attach to s2 Bridge
+    [Documentation]    This request will create vxlan port/interface for vxlan tunnel and attach it to the specific bridge s2 of OVSDB node 2
+    [Tags]    Southbound
+    Add Vxlan To Bridge    ${MININET1}    s1    vxlanport    ${MININET}
+
+Get Operational Topology with vxlan tunnel
+    [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes to verify that the vxlan tunnel is created
+    [Tags]    Southbound
+    @{list}    Create List    vxlanport    ${MININET1}    ${MININET}
+    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
+
+Add Flow1 Rule for s1 and verify
+    [Documentation]    This request will add flow to the switch and after that verify through the config datastore flow
+    [Tags]    Southbound
+    ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/add_flow_rule1.xml
+    Set Suite Variable    ${body}
+    Log    URL is ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/1
+    ${resp}    RequestsLibrary.Put    session    ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/1    headers=${HEADERS_XML}    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    ${resp}    RequestsLibrary.Get    session    ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/1    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    compare xml    ${body}    ${resp.content}
+
+Add Flow2 Rule for s1 and verify
+    [Documentation]    This request will add flow to the switch and after that verify through the config datastore flow
+    [Tags]    Southbound
+    ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/add_flow_rule2.xml
+    Log    URL is ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/2
+    ${resp}    RequestsLibrary.Put    session    ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/2    headers=${HEADERS_XML}    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    ${resp}    RequestsLibrary.Get    session    ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/2    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    compare xml    ${body}    ${resp.content}
+
+Get Operational Topology to verify the flows successfully installed in the bridge s1
+    [Documentation]    This request will fetch the operational topology and verify that the flows has been installed in the switch
+    [Tags]    Southbound
+    @{list}    Create List    openflow:1
+    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
+
+Add Flow1 Rule for s2 and verify
+    [Documentation]    This request will add flow to the switch and after that verify through the config datastore flow
+    [Tags]    Southbound
+    ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/add_flow_rule1.xml
+    Log    URL is ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/1
+    ${resp}    RequestsLibrary.Put    session    ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/1    headers=${HEADERS_XML}    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    ${resp}    RequestsLibrary.Get    session    ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/1    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    compare xml    ${body}    ${resp.content}
+
+Add Flow2 Rule for s2 and verify
+    [Documentation]    This request will add flow to the switch and after that verify through the config datastore flow
+    [Tags]    Southbound
+    ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/add_flow_rule2.xml
+    Log    URL is ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/2
+    ${resp}    RequestsLibrary.Put    session    ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/2    headers=${HEADERS_XML}    data=${body}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    ${resp}    RequestsLibrary.Get    session    ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/2    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    compare xml    ${body}    ${resp.content}
+
+Get Operational Topology to verify the flows successfully installed in the bridge s2
+    [Documentation]    This request will fetch the operational topology and verify that the flows has been installed in the switch
+    [Tags]    Southbound
+    @{list}    Create List    openflow:2
+    Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
+
+Ping host2 to IP of host1
+    [Documentation]    This step will verify the functionality of the vxlan tunnel between two OVSDB nodes. Ping h2(10.0.0.2)---> 10.0.0.1 , verify no packet loss
+    Switch Connection    ${conn_id2}
+    SSHLibrary.Write    h2 ping -w 1 10.0.0.1
+    ${result}    Read Until    mininet>
+    Should Contain    ${result}    1 received, 0% packet loss
+
+Cleanup work after test completed
+    [Documentation]    Cleanup/Shutdown work that should be done at the completion of all tests
+    Stop Mininet    ${conn_id2}
+    Stop Mininet    ${conn_id1}
+
+Disconnect controller connection from the connected OVSDBs nodes
+    [Documentation]    This request will disconnect the controller from the connected OVSDB node for clean startup for next suite.
+    [Tags]    Southbound
+    Disconnect From Ovsdb Node    ${MININET}
+    Disconnect From Ovsdb Node    ${MININET1}
+
+Verify that the operational topology is clean
+    [Documentation]    This request will verify the operational toplogy after the mininet is cleaned.
+    [Tags]    Southbound
+    @{list}    Create List    ${MININET}    ${MININET1}    s1    s2
+    Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
diff --git a/test/csit/variables/ovsdb/add_flow_rule1.xml b/test/csit/variables/ovsdb/add_flow_rule1.xml
new file mode 100644 (file)
index 0000000..ae34139
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<flow xmlns="urn:opendaylight:flow:inventory">
+    <hard-timeout>0</hard-timeout>
+    <idle-timeout>0</idle-timeout>
+    <priority>2</priority>
+    <flow-name>flow1</flow-name>
+    <match>
+    <in-port>1</in-port>
+    </match>
+    <id>1</id>
+    <table_id>0</table_id>
+    <instructions>
+        <instruction>
+            <order>0</order>
+            <apply-actions>
+                <action>
+                    <output-action>
+                        <output-node-connector>2</output-node-connector>
+                    </output-action>
+                    <order>0</order>
+                </action>
+            </apply-actions>
+        </instruction>
+    </instructions>
+</flow>
diff --git a/test/csit/variables/ovsdb/add_flow_rule2.xml b/test/csit/variables/ovsdb/add_flow_rule2.xml
new file mode 100644 (file)
index 0000000..646f6e9
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<flow xmlns="urn:opendaylight:flow:inventory">
+    <hard-timeout>0</hard-timeout>
+    <idle-timeout>0</idle-timeout>
+    <priority>2</priority>
+    <flow-name>flow2</flow-name>
+    <match>
+    <in-port>2</in-port>
+    </match>
+    <id>2</id>
+    <table_id>0</table_id>
+    <instructions>
+        <instruction>
+            <order>0</order>
+            <apply-actions>
+                <action>
+                    <output-action>
+                        <output-node-connector>1</output-node-connector>
+                    </output-action>
+                    <order>0</order>
+                </action>
+            </apply-actions>
+        </instruction>
+    </instructions>
+</flow>
diff --git a/test/csit/variables/ovsdb/ovsdb.py b/test/csit/variables/ovsdb/ovsdb.py
new file mode 100644 (file)
index 0000000..4c4a2c9
--- /dev/null
@@ -0,0 +1,44 @@
+"""
+Custom Topology to test extended Vxlan Tunnel Functionality created via OVSDB SouthBound plugin.
+usage: mn --controller=remote,ip=<> --switch=ovsk,protocols=OpenFlow13 --custom <> --topo host1
+
+"""
+
+from mininet.topo import Topo
+
+
+def add_hosts(self, switch, hosts, start_host_suffix):
+    """Add and connect specified number of hosts to the the switch
+
+    Args:
+        :param switch: A string that describes the switch name to which the hosts are to be connected
+            example 's1 s2 s3 ...'
+
+        :param hosts: A integer that describes the number of hosts to be added to the switch
+
+        :param start_host_suffix: A integer that describes the starting suffix of the host from which
+
+    Returns:
+        :returns Nothing
+    """
+    host_suffix = start_host_suffix
+    for _ in range(hosts):
+        host = self.addHost("h%s" % host_suffix, ip="10.0.0.%s" % host_suffix)
+        self.addLink(switch, host)
+        host_suffix += 1
+
+
+class HostTopo(Topo):
+    """Class to create a switch and host with suffix
+
+    Args:
+        :param host_suffix: specified else default is 1. For example: if equals to 3 (s3,h3)
+        :param hosts_per_switch: Number of hosts be connected to the switch. Default is 1.
+    """
+    def __init__(self, host_suffix=1, hosts_per_switch=1, **opts):
+        Topo.__init__(self, **opts)
+        switch = self.addSwitch('s%s' % host_suffix)
+        add_hosts(self, switch, hosts_per_switch, host_suffix)
+
+
+topos = {'host': HostTopo}