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