Test suite to configure hosts on 2 switches for vpnservice 12/23512/7
authorSindhuri <sindhuri.b@ericsson.com>
Mon, 29 Jun 2015 13:19:08 +0000 (06:19 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 9 Jul 2015 19:51:12 +0000 (19:51 +0000)
Signed-off-by: Sindhuri <sindhuri.b@ericsson.com>
Change-Id: Ib8d13afffccdc62e4cc5ca416660460afa46ccf5

test/csit/suites/vpnservice/030__configure_2_switches.robot [new file with mode: 0644]
test/csit/suites/vpnservice/__init__.robot [new file with mode: 0644]
test/csit/suites/vpnservice/custom.py [new file with mode: 0755]
test/csit/variables/vpnservice/configureSwitches.py [new file with mode: 0644]

diff --git a/test/csit/suites/vpnservice/030__configure_2_switches.robot b/test/csit/suites/vpnservice/030__configure_2_switches.robot
new file mode 100644 (file)
index 0000000..a650a83
--- /dev/null
@@ -0,0 +1,193 @@
+*** Settings ***
+Documentation     Test Suite for vpn instance
+Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
+Suite Teardown    Delete All Sessions
+Variables         ../../variables/vpnservice/configureSwitches.py    ${MININET}    ${MININET1}
+Library           SSHLibrary
+Variables         ../../variables/Variables.py
+Resource          ../../libraries/Utils.txt
+Library           RequestsLibrary
+
+*** Variables ***
+${REST_CON}       /restconf/config
+@{vpn_inst_values}    testVpn1    100:1    200:1    300:1    testVpn2    400:1    500:1
+...               600:1
+@{ietf_int_values}    s1-eth1    s1-eth2    s1-gre1    s2-eth1    s2-eth2    s2-gre1
+@{vpn_int_values}    s1-eth1    testVpn1    10.0.0.1    00:00:00:00:00:01    s1-eth2    10.0.0.2    00:00:00:00:00:02
+...               s2-eth1    10.0.0.3    00:00:00:00:00:03    testVpn2    s2-eth2    10.0.0.4    00:00:00:00:00:04
+${REST_OPER}      /restconf/operational
+@{NODE_ELEMENTS}    openflow:1    openflow:1:1    openflow:1:2    openflow:1:3    openflow:2    openflow:2:1    openflow:2:2
+...               openflow:2:3
+
+*** Test Cases ***
+Veirfy The Switches
+    [Documentation]    Verifies if the switches and node connectors data is available to the controller
+    Check For Elements At URI    ${REST_OPER}/opendaylight-inventory:nodes/    ${NODE_ELEMENTS}
+
+Create VPN Instances
+    [Documentation]    Creates VPN Instances through restconf
+    [Tags]    Post
+    ${resp}    RequestsLibrary.Post    session    ${REST_CON}/l3vpn:vpn-instances/    data=${vpn_instances}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    204
+
+Verify VPN instances
+    [Documentation]    Verifies the vpn instances in the datastores
+    [Tags]    Get
+    Wait Until Keyword Succeeds    5s    1s    Check For Elements At URI    ${REST_CON}/l3vpn:vpn-instances/    ${vpn_inst_values}
+    Wait Until Keyword Succeeds    5s    1s    Check For Elements At URI    ${REST_OPER}/l3vpn:vpn-instances/    ${vpn_inst_values}
+
+Create ietf interfaces
+    [Documentation]    Creates ietf interfaces through the restconf
+    [Tags]    Post
+    ${resp}    RequestsLibrary.Post    session    ${REST_CON}/ietf-interfaces:interfaces/    data=${ietf_interfaces}
+    Should Be Equal As Strings    ${resp.status_code}    204
+
+Verify ietf interfaces
+    [Documentation]    Verifies ietf interfaces created in datastores
+    [Tags]    Get
+    Wait Until Keyword Succeeds    5s    1s    Check For Elements At URI    ${REST_CON}/ietf-interfaces:interfaces/    ${ietf_int_values}
+    Wait Until Keyword Succeeds    5s    1s    Check For Elements At URI    ${REST_OPER}/ietf-interfaces:interfaces-state/    ${ietf_int_values}
+    @{state}=    Create List    down
+    Wait Until Keyword Succeeds    2s    1s    Check For Elements Not At URI    ${REST_OPER}/ietf-interfaces:interfaces-state/    ${state}
+
+Create VPN interfaces
+    [Documentation]    Creates vpn interface for the corresponding ietf interface
+    [Tags]    Post
+    ${resp}    RequestsLibrary.Post    session    ${REST_CON}/l3vpn:vpn-interfaces/    data=${vpn_interfaces}
+    Should Be Equal As Strings    ${resp.status_code}    204
+
+Verify VPN interfaces
+    [Documentation]    Verifies the vpn interfaces created in datastores
+    [Tags]    Get
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_CON}/l3vpn:vpn-interfaces/    ${vpn_int_values}
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_OPER}/l3vpn:vpn-interfaces/    ${vpn_int_values}
+
+Verify FIB entries after create
+    [Documentation]    Verifies the fib entries in the operational DS for the corresponding vpn interfaces
+    [Tags]    Get
+    @{fib_entries1}=    Create List    ${vpn_int_values[2]}    ${vpn_int_values[8]}
+    @{fib_entries2}=    Create List    ${vpn_int_values[5]}    ${vpn_int_values[12]}
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_OPER}/odl-fib:fibEntries/vrfTables/${vpn_inst_values[1]}    ${fib_entries1}
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${REST_OPER}/odl-fib:fibEntries/vrfTables/${vpn_inst_values[5]}    ${fib_entries2}
+
+Verify flows
+    [Documentation]    Verify flows in the switches
+    [Tags]    verify in switch
+    @{flow_elements}    Create List    ${vpn_int_values[2]}    ${vpn_int_values[5]}    ${vpn_int_values[8]}    ${vpn_int_values[12]}
+    Wait Until Keyword Succeeds    6s    2s    Ensure Flows Are Present    ${mininet1_conn_id_1}    ${flow_elements}
+    Wait Until Keyword Succeeds    6s    2s    Ensure Flows Are Present    ${mininet2_conn_id_1}    ${flow_elements}
+
+Verify groups
+    [Documentation]    Verify groups in the switches
+    [Tags]    verify in switch
+    @{group_elements1}    Create List    ${vpn_int_values[3]}    ${vpn_int_values[6]}
+    @{group_elements2}    Create List    ${vpn_int_values[9]}    ${vpn_int_values[13]}
+    Wait Until Keyword Succeeds    5s    1s    Ensure Groups Are Present    ${mininet1_conn_id_1}    ${group_elements1}    3
+    Wait Until Keyword Succeeds    5s    1s    Ensure Groups Are Present    ${mininet2_conn_id_1}    ${group_elements2}    3
+
+Verify ping
+    [Documentation]    Verifies the ping between the two hosts. Ping should succeed between hosts in same vpn, (h1,h3) and (h2,h4).Ping between hosts in different vpns should fail (h1,h2) & (h3,h4). The commented out section is to be uncommented when ovs supports mpls over gre in datapath
+    [Tags]    verify in switch
+    Switch Connection    ${mininet1_conn_id_1}
+    Write    h1 ping h2 -c 5
+    ${result}    Read Until    mininet>
+    Log    ${result}
+    Should Contain    ${result}    100% packet loss
+
+Delete vpn interfaces
+    [Documentation]    Deletes the vpn interfaces
+    [Tags]    Delete
+    ${resp}    RequestsLibrary.Delete    session    ${REST_CON}/l3vpn:vpn-interfaces/
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Verify after deleting vpn interfaces
+    [Documentation]    Verifies if vpn interfaces are deleted
+    [Tags]    Verify after delete
+    ${resp}    RequestsLibrary.get    session    ${REST_CON}/l3vpn:vpn-interfaces/    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    404
+
+Delete ietf interfaces
+    [Documentation]    Deletes the ietf interfaces
+    [Tags]    Delete
+    ${resp}    RequestsLibrary.Delete    session    ${REST_CON}/ietf-interfaces:interfaces/
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Verify after deleting ietf interfaces
+    [Documentation]    Verifies if ietf interfaces are deleted
+    [Tags]    Verify after delete
+    ${resp}    RequestsLibrary.get    session    ${REST_CON}/ietf-interfaces:interfaces/    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    404
+
+Delete VPN Instances
+    [Documentation]    Deletes the VPN Instances
+    [Tags]    Delete
+    ${resp}    RequestsLibrary.Delete    session    ${REST_CON}/l3vpn:vpn-instances/
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Verify after deleting the vpn instances
+    [Documentation]    Verifies after deleting the vpn instances
+    [Tags]    Verfiy after delete
+    ${resp}    RequestsLibrary.get    session    ${REST_CON}/l3vpn:vpn-instances/    headers=${ACCEPT_XML}
+    Should Be Equal As Strings    ${resp.status_code}    404
+
+Verify FIB entries after delete
+    [Documentation]    Verifies if the fib entries are deleted in the operational DS
+    [Tags]    Get
+    @{fib_entries}=    Create List    ${vpn_int_values[2]}    ${vpn_int_values[5]}    ${vpn_int_values[8]}    ${vpn_int_values[12]}
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements Not At URI    ${REST_OPER}/odl-fib:fibEntries/    ${fib_entries}
+
+Verify flows after delete
+    [Documentation]    Verify if the flows are deleted from the switch
+    [Tags]    verify in switch
+    [Template]
+    Wait Until Keyword Succeeds    12s    2s    Ensure Flows Are Removed    ${mininet1_conn_id_1}
+    Wait Until Keyword Succeeds    12s    2s    Ensure Flows Are Removed    ${mininet2_conn_id_1}
+
+*** Keywords ***
+Ensure Flows Are Present
+    [Arguments]    ${conn_id}    ${flow_elements}
+    [Documentation]    Succeeds if the flows for vpn service are present
+    Switch Connection    ${conn_id}
+    Write    dpctl dump-flows -O OpenFlow13
+    ${output}=    Read Until    mininet>
+    Log    ${output}
+    Should Contain    ${output}    goto_table:20
+    Should Contain X Times    ${output}    goto_table:21    2
+    Should Contain X Times    ${output}    table=20    2
+    Should Contain X Times    ${output}    table=21    4
+    : FOR    ${i}    IN    @{flow_elements}
+    \    Should Contain    ${output}    ${i}
+
+Ensure Groups Are Present
+    [Arguments]    ${conn_id}    ${group_elements}    ${gre_port_id}
+    [Documentation]    Succeeds if the groups for the vpn service are present
+    Switch Connection    ${conn_id}
+    Write    dpctl dump-groups -O OpenFlow13
+    ${output}=    Read Until    mininet>
+    Log    ${output}
+    Should Contain X Times    ${output}    actions=output:${gre_port_id}    1
+    : FOR    ${i}    IN    @{group_elements}
+    \    Should Contain    ${output}    actions=pop_mpls:0x0800,set_field:${i}
+
+Ensure Flows Are Removed
+    [Arguments]    ${conn_id}
+    [Documentation]    Succeeds if the flows are removed from the switch
+    Switch Connection    ${conn_id}
+    Write    dpctl dump-flows -O OpenFlow13
+    ${output}=    Read Until    mininet>
+    Log    ${output}
+    Should Not contain    ${output}    goto_table:20
+    Should Not contain    ${output}    goto_table:21
+    Should Not contain    ${output}    table=20
+    Should Not contain    ${output}    table=21
+
+Ensure Groups Are Removed
+    [Arguments]    ${conn_id}
+    [Documentation]    Succeeds if the group entries are removed from switch
+    Switch Connection    ${conn_id}
+    Write    dpctl dump-groups -O OpenFlow13
+    ${output}=    Read Until    mininet>
+    Log    ${output}
+    Should Not Contain    ${output}    actions=output:
+    Should Not Contain    ${output}    actions=pop_mpls:0x0800
diff --git a/test/csit/suites/vpnservice/__init__.robot b/test/csit/suites/vpnservice/__init__.robot
new file mode 100644 (file)
index 0000000..001bc65
--- /dev/null
@@ -0,0 +1,63 @@
+*** Settings ***
+Documentation     Test suite for Inventory Scalability
+Suite Setup       Start Suite
+Suite Teardown    Stop Suite
+Library           SSHLibrary
+Library           ../../libraries/Common.py
+Variables         ../../variables/Variables.py
+Resource          ../../libraries/Utils.txt
+
+*** Variables ***
+${start1}         sudo mn \ --controller=remote,ip=${CONTROLLER} --custom custom.py --topo Switch1 --switch ovsk,protocols=OpenFlow13
+${start2}         sudo mn \ --controller=remote,ip=${CONTROLLER} --custom custom.py --topo Switch2 --switch ovsk,protocols=OpenFlow13
+
+*** Keywords ***
+Start Suite
+    [Documentation]    Test suit for vpn service using mininet OF13 and OVS 2.3.1
+    Log    Start the tests
+    Clean Mininet System
+    ${mininet1_conn_id_1}=    Open Connection    ${MININET}    prompt=${LINUX_PROMPT}    timeout=30s
+    Set Global Variable    ${mininet1_conn_id_1}
+    Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/id_rsa    any
+    Execute Command    sudo ovs-vsctl set-manager ptcp:6644
+    Put File    ${CURDIR}/custom.py
+    Write    ${start1}
+    Read Until    mininet>
+    ${mininet1_conn_id_2}=    Open Connection    ${MININET}    prompt=${LINUX_PROMPT}    timeout= 30s
+    Set Global Variable    ${mininet1_conn_id_2}
+    Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/id_rsa    any
+    Execute Command    sudo ovs-vsctl add-port s1 s1-gre1 -- set interface s1-gre1 type=gre options:remote_ip=${MININET1} options:local_ip=${MININET}
+    ${output}    Execute Command    sudo ovs-vsctl show
+    Log    ${output}
+    Execute Command    sudo ovs-ofctl add-flow s1 -O OpenFlow13 arp,actions=FLOOD
+    ${mininet2_conn_id_1}=    Open Connection    ${MININET1}    prompt=${LINUX_PROMPT}    timeout=30s
+    Set Global Variable    ${mininet2_conn_id_1}
+    Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/id_rsa    any
+    Execute Command    sudo ovs-vsctl set-manager ptcp:6644
+    Put File    ${CURDIR}/custom.py
+    Write    ${start2}
+    Read Until    mininet>
+    ${mininet2_conn_id_2}=    Open Connection    ${MININET1}    prompt=${LINUX_PROMPT}    timeout= 30s
+    Set Global Variable    ${mininet2_conn_id_2}
+    Login With Public Key    ${MININET_USER}    ${USER_HOME}/.ssh/id_rsa    any
+    Execute Command    sudo ovs-vsctl add-port s2 s2-gre1 -- set interface s2-gre1 type=gre options:remote_ip=${MININET} options:local_ip=${MININET1}
+    ${output}    Execute Command    sudo ovs-vsctl show
+    Log    ${output}
+    Execute Command    sudo ovs-ofctl add-flow s2 -O OpenFlow13 arp,actions=FLOOD
+
+Stop Suite
+    Log    Stop the tests
+    Switch Connection    ${mininet1_conn_id_1}
+    Read
+    Write    exit
+    Read Until    ${LINUX_PROMPT}
+    Close Connection
+    Switch Connection    ${mininet1_conn_id_2}
+    Close Connection
+    Switch Connection    ${mininet2_conn_id_1}
+    Read
+    Write    exit
+    Read Until    ${LINUX_PROMPT}
+    Close Connection
+    Switch Connection    ${mininet2_conn_id_2}
+    Close Connection
diff --git a/test/csit/suites/vpnservice/custom.py b/test/csit/suites/vpnservice/custom.py
new file mode 100755 (executable)
index 0000000..64746be
--- /dev/null
@@ -0,0 +1,40 @@
+"""Topology description for configuring vpnservice for hosts on 2 switches
+
+     MININET                  MININET1
+   -------------    gre     -------------
+   | h1-----s1 |------------| s2------h3|
+   |        |  |            | |         |
+   |        |  |            | |         |
+   |        h2 |            | h4        |
+   -------------            -------------
+1)The topology consits of switch s1 in one VM connected to hosts h1,h2.Switch s2 in another VM connected to hosts h3,h4.
+2)GRE tunnel is configured between s1 and s2 using ovs-vsctl commands.
+3)h1 and h3 will be configured for vpn instance testVpn1 and h2,h4 for testVpn2.
+"""
+
+from mininet.topo import Topo
+
+
+class Switch1(Topo):
+    """Single switch s1 connected to n=2 hosts."""
+    def __init__(self):
+        Topo.__init__(self)
+        switch = self.addSwitch('s1')
+        n = 2
+        for h in range(n):
+            host = self.addHost('h%s' % (h + 1), mac="00:00:00:00:00:0"+str(h+1), ip="10.0.0."+str(h+1))
+            self.addLink(host, switch)
+
+
+class Switch2(Topo):
+    """Single switch s2 connected to n=2 hosts."""
+    def __init__(self):
+        Topo.__init__(self)
+        switch = self.addSwitch('s2')
+        n = 2
+        for h in range(n):
+            host = self.addHost('h%s' % (h + 3), mac="00:00:00:00:00:0"+str(h+3), ip="10.0.0."+str(h+3))
+            self.addLink(host, switch)
+
+topos = {'Switch1': (lambda: Switch1()),
+         'Switch2': (lambda: Switch2())}
diff --git a/test/csit/variables/vpnservice/configureSwitches.py b/test/csit/variables/vpnservice/configureSwitches.py
new file mode 100644 (file)
index 0000000..434766e
--- /dev/null
@@ -0,0 +1,131 @@
+import json
+
+
+def get_variables(mininet1_ip, mininet2_ip):
+    vpn_instances = {
+        "vpn-instance": [
+            {
+                "description": "Test VPN Instance 1",
+                "vpn-instance-name": "testVpn1",
+                "ipv4-family": {
+                    "route-distinguisher": "100:1",
+                    "export-route-policy": "300:1",
+                    "import-route-policy": "200:1",
+                    "apply-label": {
+                        "apply-label-per-route": "true"
+                    }
+                }
+            },
+            {
+                "description": "Test VPN Instance 2",
+                "vpn-instance-name": "testVpn2",
+                "ipv4-family": {
+                    "route-distinguisher": "400:1",
+                    "export-route-policy": "500:1",
+                    "import-route-policy": "600:1",
+                    "apply-label": {
+                        "apply-label-per-route": "true"
+                    }
+                }
+            }
+        ]
+    }
+    ietf_interfaces = {
+        "interface": [
+            {
+                "name": "s1-eth1",
+                "type": "iana-if-type:l2vlan",
+                "odl-interface:of-port-id": "openflow:1:1",
+                "enabled": "true"
+            },
+            {
+                "name": "s1-eth2",
+                "type": "iana-if-type:l2vlan",
+                "odl-interface:of-port-id": "openflow:1:2",
+                "enabled": "true"
+            },
+            {
+                "name": "s2-eth1",
+                "type": "iana-if-type:l2vlan",
+                "odl-interface:of-port-id": "openflow:2:1",
+                "enabled": "true"
+            },
+            {
+                "name": "s2-eth2",
+                "type": "iana-if-type:l2vlan",
+                "odl-interface:of-port-id": "openflow:2:2",
+                "enabled": "true"
+            },
+            {
+                "enabled": "true",
+                "odl-interface:of-port-id": "openflow:1:3",
+                "description": "VM Port mpls",
+                "name": "s1-gre1",
+                "type": "odl-interface:l3tunnel",
+                "odl-interface:tunnel-type": "odl-interface:tunnel-type-gre",
+                "odl-interface:local-ip": mininet1_ip,
+                "odl-interface:remote-ip": mininet2_ip
+            },
+            {
+                "enabled": "true",
+                "odl-interface:of-port-id": "openflow:2:3",
+                "description": "VM Port mpls",
+                "name": "s2-gre1",
+                "type": "odl-interface:l3tunnel",
+                "odl-interface:tunnel-type": "odl-interface:tunnel-type-gre",
+                "odl-interface:local-ip": mininet2_ip,
+                "odl-interface:remote-ip": mininet1_ip
+            }
+        ]
+    }
+    vpn_interfaces = {
+        "vpn-interface": [
+            {
+                "odl-l3vpn:adjacency": [
+                    {
+                        "odl-l3vpn:ip_address": "10.0.0.1",
+                        "odl-l3vpn:mac_address": "00:00:00:00:00:01"
+                    }
+                ],
+                "vpn-instance-name": "testVpn1",
+                "name": "s1-eth1"
+            },
+            {
+                "odl-l3vpn:adjacency": [
+                    {
+                        "odl-l3vpn:ip_address": "10.0.0.2",
+                        "odl-l3vpn:mac_address": "00:00:00:00:00:02"
+                    }
+                ],
+                "vpn-instance-name": "testVpn2",
+                "name": "s1-eth2"
+            },
+            {
+                "odl-l3vpn:adjacency": [
+                    {
+                        "odl-l3vpn:ip_address": "10.0.0.3",
+                        "odl-l3vpn:mac_address": "00:00:00:00:00:03"
+                    }
+                ],
+                "vpn-instance-name": "testVpn1",
+                "name": "s2-eth1"
+            },
+            {
+                "odl-l3vpn:adjacency": [
+                    {
+                        "odl-l3vpn:ip_address": "10.0.0.4",
+                        "odl-l3vpn:mac_address": "00:00:00:00:00:04"
+                    }
+                ],
+                "vpn-instance-name": "testVpn2",
+                "name": "s2-eth2"
+            }
+        ]
+    }
+    vpn_inst_data = json.dumps(vpn_instances)
+    ietf_int_data = json.dumps(ietf_interfaces)
+    vpn_int_data = json.dumps(vpn_interfaces)
+    variables = {'vpn_instances': vpn_inst_data,
+                 'ietf_interfaces': ietf_int_data,
+                 'vpn_interfaces': vpn_int_data}
+    return variables