Step 1: Move vm scripts to the right place
[integration/test.git] / test / csit / suites / ovsdb / Southbound_Domain / 050__Vxlan_Extension_Tunnel_Test.robot
1 *** Settings ***
2 Documentation     Test suite for Connection Manager
3 Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           OperatingSystem
6 Library           String
7 Library           Collections
8 Library           SSHLibrary
9 Library           RequestsLibrary
10 Library           ../../../libraries/Common.py
11 Variables         ../../../variables/Variables.py
12 Resource          ../../../libraries/Utils.txt
13 Resource          ../../../libraries/OVSDB.robot
14
15 *** Variables ***
16 ${OVSDB_PORT}     6634
17 ${OVSDB_CONFIG_DIR}    ${CURDIR}/../../../variables/ovsdb
18 @{node_list1}     ovsdb://${MININET1}:${OVSDB_PORT}    ${MININET1}    ${OVSDB_PORT}    ovsdb://${MININET}:${OVSDB_PORT}    ${MININET}    ${OVSDB_PORT}    br-int
19 ${start1}         sudo mn --controller=remote,ip=${CONTROLLER} --switch=ovsk,protocols=OpenFlow13 --custom ovsdb.py --topo host,1
20 ${start2}         sudo mn --controller=remote,ip=${CONTROLLER} --switch=ovsk,protocols=OpenFlow13 --custom ovsdb.py --topo host,2
21
22 *** Test Cases ***
23 Make the OVS instance to listen for connection
24     [Tags]    Southbound
25     Run Command On Remote System    ${MININET1}    sudo ovs-vsctl del-manager
26     Run Command On Remote System    ${MININET1}    sudo ovs-vsctl set-manager ptcp:6634
27     Run Command On Remote System    ${MININET}    sudo ovs-vsctl del-manager
28     Run Command On Remote System    ${MININET}    sudo ovs-vsctl set-manager ptcp:6634
29
30 Connect controller to OVSDB Node1 and OVSDB Node2
31     [Documentation]    Initiate the connection to OVSDB node from controller
32     [Tags]    Southbound
33     Connect To Ovsdb Node    ${MININET1}
34     Connect To Ovsdb Node    ${MININET}
35
36 Get Operational Topology from OVSDB Node1 and OVSDB Node2
37     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes
38     [Tags]    Southbound
39     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${node_list1}
40
41 Delete the integration Bridge from OVSDB node 1 and 2 and Verify it
42     [Documentation]    This request will delete the integation bridge node from the OVSDB as we don't need it and verify the operation.
43     [Tags]    Southbound
44     Delete Bridge From Ovsdb Node    ${MININET}    br-int
45     Delete Bridge From Ovsdb Node    ${MININET1}    br-int
46     @{list}    Create List    br-int
47     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}
48
49 Start the Mininet and create custom topology
50     [Documentation]    This will start mininet with custom topology on both the Virtual Machines
51     [Tags]    Southbound
52     ${conn_id1}    Start Mininet    ${MININET1}    ${start1}    ${OVSDB_CONFIG_DIR}/ovsdb.py
53     Set Global Variable    ${conn_id1}
54     ${conn_id2}    Start Mininet    ${MININET}    ${start2}    ${OVSDB_CONFIG_DIR}/ovsdb.py
55     Set Global Variable    ${conn_id2}
56
57 Get Operational Topology with custom topology
58     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes to make sure the mininet created custom topology
59     [Tags]    Southbound
60     @{list}    Create List    s1    s2
61     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
62
63 Add the bridge s1 in the config datastore of OVSDB Node1
64     [Documentation]    This request will add already operational bridge to the config data store of the OVSDB node.
65     [Tags]    Southbound
66     Add Bridge To Ovsdb Node    ${MININET1}    s1    0000000000000001
67
68 Add the bridge s2 in the config datastore of OVSDB Node2
69     [Documentation]    This request will add already operational bridge to the config data store of the OVSDB node.
70     [Tags]    Southbound
71     Add Bridge To Ovsdb Node    ${MININET}    s2    0000000000000002
72
73 Get Config Topology with s1 and s2 Bridges
74     [Documentation]    This will fetch the configuration topology from configuration data store to verify the bridge is added to the config data store
75     [Tags]    Southbound
76     @{list}    Create List    s1    s2
77     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${CONFIG_TOPO_API}    ${list}
78
79 Create Vxlan Port and attach to s1 Bridge
80     [Documentation]    This request will create vxlan port/interface for vxlan tunnel and attach it to the specific bridge s1 of OVSDB node 1
81     [Tags]    Southbound
82     Add Vxlan To Bridge    ${MININET}    s2    vxlanport    ${MININET1}    create_port_key.json
83
84 Create Vxlan Port and attach to s2 Bridge
85     [Documentation]    This request will create vxlan port/interface for vxlan tunnel and attach it to the specific bridge s2 of OVSDB node 2
86     [Tags]    Southbound
87     Add Vxlan To Bridge    ${MININET1}    s1    vxlanport    ${MININET}    create_port_key.json
88
89 Get Operational Topology with vxlan tunnel
90     [Documentation]    This request will fetch the operational topology from the connected OVSDB nodes to verify that the vxlan tunnel is created
91     [Tags]    Southbound
92     @{list}    Create List    vxlanport    ${MININET1}    ${MININET}
93     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
94
95 Add Flow1 Rule for s1 and verify
96     [Documentation]    This request will add flow to the switch and after that verify through the config datastore flow
97     [Tags]    Southbound
98     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/add_flow_rule3.xml
99     Set Suite Variable    ${body}
100     Log    URL is ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/1
101     ${resp}    RequestsLibrary.Put    session    ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/1    headers=${HEADERS_XML}    data=${body}
102     Log    ${resp.content}
103     Should Be Equal As Strings    ${resp.status_code}    200
104     ${resp}    RequestsLibrary.Get    session    ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/1    headers=${ACCEPT_XML}
105     Should Be Equal As Strings    ${resp.status_code}    200
106     compare xml    ${body}    ${resp.content}
107
108 Add Flow2 Rule for s1 and verify
109     [Documentation]    This request will add flow to the switch and after that verify through the config datastore flow
110     [Tags]    Southbound
111     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/add_flow_rule4.xml
112     Log    URL is ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/2
113     ${resp}    RequestsLibrary.Put    session    ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/2    headers=${HEADERS_XML}    data=${body}
114     Log    ${resp.content}
115     Should Be Equal As Strings    ${resp.status_code}    200
116     ${resp}    RequestsLibrary.Get    session    ${CONFIG_NODES_API}/node/openflow:1/table/0/flow/2    headers=${ACCEPT_XML}
117     Should Be Equal As Strings    ${resp.status_code}    200
118     compare xml    ${body}    ${resp.content}
119
120 Get Operational Topology to verify the flows successfully installed in the bridge s1
121     [Documentation]    This request will fetch the operational topology and verify that the flows has been installed in the switch
122     [Tags]    Southbound
123     @{list}    Create List    openflow:1
124     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
125
126 Add Flow1 Rule for s2 and verify
127     [Documentation]    This request will add flow to the switch and after that verify through the config datastore flow
128     [Tags]    Southbound
129     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/add_flow_rule3.xml
130     Log    URL is ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/1
131     ${resp}    RequestsLibrary.Put    session    ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/1    headers=${HEADERS_XML}    data=${body}
132     Log    ${resp.content}
133     Should Be Equal As Strings    ${resp.status_code}    200
134     ${resp}    RequestsLibrary.Get    session    ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/1    headers=${ACCEPT_XML}
135     Should Be Equal As Strings    ${resp.status_code}    200
136     compare xml    ${body}    ${resp.content}
137
138 Add Flow2 Rule for s2 and verify
139     [Documentation]    This request will add flow to the switch and after that verify through the config datastore flow
140     [Tags]    Southbound
141     ${body}    OperatingSystem.Get File    ${OVSDB_CONFIG_DIR}/add_flow_rule4.xml
142     Log    URL is ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/2
143     ${resp}    RequestsLibrary.Put    session    ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/2    headers=${HEADERS_XML}    data=${body}
144     Log    ${resp.content}
145     Should Be Equal As Strings    ${resp.status_code}    200
146     ${resp}    RequestsLibrary.Get    session    ${CONFIG_NODES_API}/node/openflow:2/table/0/flow/2    headers=${ACCEPT_XML}
147     Should Be Equal As Strings    ${resp.status_code}    200
148     compare xml    ${body}    ${resp.content}
149
150 Get Operational Topology to verify the flows successfully installed in the bridge s2
151     [Documentation]    This request will fetch the operational topology and verify that the flows has been installed in the switch
152     [Tags]    Southbound
153     @{list}    Create List    openflow:2
154     Wait Until Keyword Succeeds    8s    2s    Check For Elements At URI    ${OPERATIONAL_TOPO_API}    ${list}
155
156 Ping host2 to IP of host1
157     [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
158     Switch Connection    ${conn_id2}
159     SSHLibrary.Write    h2 ping -w 1 10.0.0.1
160     ${result}    Read Until    mininet>
161     Should Contain    ${result}    1 received, 0% packet loss
162
163 Cleanup work after test completed
164     [Documentation]    Cleanup/Shutdown work that should be done at the completion of all tests
165     Stop Mininet    ${conn_id2}
166     Stop Mininet    ${conn_id1}
167
168 Disconnect controller connection from the connected OVSDBs nodes
169     [Documentation]    This request will disconnect the controller from the connected OVSDB node for clean startup for next suite.
170     [Tags]    Southbound
171     Disconnect From Ovsdb Node    ${MININET}
172     Disconnect From Ovsdb Node    ${MININET1}
173
174 Verify that the operational topology is clean
175     [Documentation]    This request will verify the operational toplogy after the mininet is cleaned.
176     [Tags]    Southbound
177     @{list}    Create List    ${MININET}    ${MININET1}    s1    s2
178     Wait Until Keyword Succeeds    8s    2s    Check For Elements Not At URI    ${OPERATIONAL_TOPO_API}    ${list}