2 Documentation Test suite for Tunnel Monitoring. More test cases to be added in subsequent patches.
3 Suite Setup Start Suite
4 Suite Teardown Stop Suite
5 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
6 Test Teardown Get Test Teardown Debugs
7 Library OperatingSystem
8 Library RequestsLibrary
9 Resource ../../../libraries/CompareStream.robot
10 Resource ../../../libraries/OpenStackOperations.robot
11 Resource ../../../libraries/DevstackUtils.robot
12 Resource ../../../libraries/VpnOperations.robot
13 Resource ../../../libraries/SetupUtils.robot
14 Resource ../../../libraries/KarafKeywords.robot
15 Resource ../../../libraries/OVSDB.robot
16 Resource ../../../variables/netvirt/Variables.robot
17 Resource ../../../variables/Variables.robot
22 ${STATE_ENABLE} ENABLED
23 ${STATE_DISABLE} DISABLE
24 ${BFD_ENABLED_FALSE} false
25 ${BFD_ENABLED_TRUE} true
26 ${PING_REGEXP} , 0% packet loss
27 ${VAR_BASE} ${CURDIR}/../../../variables/netvirt
30 TC00 Verify Tunnels Are Present
31 [Documentation] Verify if tunnels are present. If not then create new tunnel.
32 ${output}= ITM Get Tunnels
34 ${count}= Get Count ${output} tunnel_port
36 Run Keyword If ${count} == 0 Create Tunnel
38 TC01 Verify That Default Tunnel Type Is Set To BFD
39 [Documentation] Verify that the default tunnel type is set to BFD if both the devices support BFD
40 Log Verifying ITM tunnel through REST
41 ${output}= ITM Get Tunnels
43 Log Verifying the BFD based tunnel configuration
44 ${output}= Issue Command On Karaf Console ${TEP_SHOW}
46 Should Contain ${output} ${TUNNEL_MONITOR_ON}
47 Should Contain ${output} ${MONITORING_INTERVAL}
48 Should Contain ${output} ${INTERVAL_1000}
49 Log Verifying the tunnel state with show state command
50 Wait Until Keyword Succeeds 30s 5s Verify Tunnel Status as UP
51 Log Verifying the default configuration i.e BFD, tunnel monitoring enabled
52 ${resp} RequestsLibrary.Get Request session ${TUNNEL_MONITOR_URL}
53 Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
55 Should Contain ${resp.content} ${BFD}
56 Should Contain ${resp.content} ${BFD_ENABLED_TRUE}
57 Log Verifying the default monitor interval
58 ${resp} RequestsLibrary.Get Request session ${MONITOR_INTERVAL_URL}
59 Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
61 Should Contain ${resp.content} ${TMI_1000}
62 Log Verifying the VXLAN Interface
63 Wait Until Keyword Succeeds 180s 10s Verify VXLAN interface
64 Log Verify Flows are present
65 Wait Until Keyword Succeeds 30s 5s Verify Flows Are Present ${OS_COMPUTE_1_IP}
66 Wait Until Keyword Succeeds 30s 5s Verify Flows Are Present ${OS_COMPUTE_2_IP}
67 Log Verify Ping Between VMs on different Compute Nodes
68 Wait Until Keyword Succeeds 30s 5s Verify Ping
70 TC02 Verify that Tunnel Monitoring can be disabled and monitor interval can be configured through REST
71 [Documentation] Verify that Tunnel Monitoring can be disabled and monitor interval can be configured through REST
72 Log Verifying ITM tunnel are present and tunnel status
73 ${output}= ITM Get Tunnels
75 Wait Until Keyword Succeeds 10s 5s Verify Tunnel Status as UP
76 Log Verifying the BFD based tunnel configuration is on
77 ${output}= Issue Command On Karaf Console ${TEP_SHOW}
79 Should Contain ${output} ${TUNNEL_MONITOR_ON}
80 Log Disabling the tunnel monitoring from REST
81 TemplatedRequests.Put_As_Json_Templated folder=${VAR_BASE}/disable_tunnel_monitoring session=session
82 Log Verifying the tunnel monitoring after disable
83 ${resp}= RequestsLibrary.Get Request session ${TUNNEL_MONITOR_URL}
85 Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
86 Should Contain ${resp.content} ${BFD_ENABLED_FALSE}
87 Should Contain ${resp.content} ${BFD}
88 Log Verifying the default tunnel monitoring is off
89 ${output}= Issue Command On Karaf Console ${TEP_SHOW}
91 Should Contain ${output} ${TUNNEL_MONITOR_OFF}
92 Wait Until Keyword Succeeds 10s 5s Verify Tunnel Status as UP
93 Log Verifying the default monitoring interval i.e 1000ms via REST
94 ${resp}= RequestsLibrary.Get Request session ${MONITOR_INTERVAL_URL}
96 Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
97 Should Contain ${resp.content} ${TMI_1000}
98 Log Change and verify the default tunnel monitoring interval after monitoring is disabled
99 TemplatedRequests.Put_As_Json_Templated folder=${VAR_BASE}/monitor_interval mapping={"int":"2000"} session=session
100 ${resp}= RequestsLibrary.Get Request session ${MONITOR_INTERVAL_URL}
102 Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
103 Should Contain ${resp.content} ${TMI_2000}
105 TC03 Verify that the monitoring interval value boundaries with Monitoring Enabled
106 [Documentation] Verify that the monitoring interval value boundaries with Monitoring Enabled
107 Log Verifying ITM tunnel are present and tunnel status
108 ${output}= ITM Get Tunnels
110 Wait Until Keyword Succeeds 10s 5s Verify Tunnel Status as UP
111 Log Enabling the tunnel monitoring from REST
112 TemplatedRequests.Put_As_Json_Templated folder=${VAR_BASE}/enable_tunnel_monitoring session=session
113 Log Verifying the tunnel monitoring is enabled
114 ${resp}= RequestsLibrary.Get Request session ${TUNNEL_MONITOR_URL}
116 Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
117 Should Contain ${resp.content} ${BFD_ENABLED_TRUE}
118 Should Contain ${resp.content} ${BFD}
119 Log Verifying the tunnel status
120 ${output}= Issue Command On Karaf Console ${TEP_SHOW}
122 Should Contain ${output} ${TUNNEL_MONITOR_ON}
123 Log Changing and verifying the tunnel monitoring interval to 1000ms
124 TemplatedRequests.Put_As_Json_Templated folder=${VAR_BASE}/monitor_interval mapping={"int":"1000"} session=session
125 ${resp}= RequestsLibrary.Get Request session ${MONITOR_INTERVAL_URL}
127 Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
128 Should Contain ${resp.content} ${TMI_1000}
129 Log Setting the tunnel monitoring interval to 30000ms
130 TemplatedRequests.Put_As_Json_Templated folder=${VAR_BASE}/monitor_interval mapping={"int":"30000"} session=session
131 Log Verifying the tunnel monitoring interval to 30000ms
132 Wait Until Keyword Succeeds 10s 1s Check Tunnel Monitoring ${TMI_30000}
133 Log Verifying the tunnel monitoring interval to greater than 30000ms cannot be set
134 ${resp}= RequestsLibrary.Put Request session ${MONITOR_INTERVAL_NEW} data=${INTERVAL_31000}
135 Should Be Equal As Strings ${resp.status_code} ${RESP_ERROR_CODE}
136 Wait Until Keyword Succeeds 10s 1s Check Tunnel Monitoring ${TMI_30000}
137 Log Verifying the tunnel monitoring interval to 50ms cannot be set
138 ${resp}= RequestsLibrary.Put Request session ${MONITOR_INTERVAL_NEW} data=${INTERVAL_50}
139 Should Be Equal As Strings ${resp.status_code} ${RESP_ERROR_CODE}
140 Wait Until Keyword Succeeds 10s 1s Check Tunnel Monitoring ${TMI_30000}
141 Log Verifying the tunnel monitoring interval to 0ms cannot be set
142 ${resp}= RequestsLibrary.Put Request session ${MONITOR_INTERVAL_NEW} data=${INTERVAL_0}
143 Should Be Equal As Strings ${resp.status_code} ${RESP_ERROR_CODE}
144 Wait Until Keyword Succeeds 10s 1s Check Tunnel Monitoring ${TMI_30000}
145 Log Verifying the tunnel monitoring interval to a negative value cannot be set
146 ${resp}= RequestsLibrary.Put Request session ${MONITOR_INTERVAL_NEW} data=${INTERVAL_NEG}
147 Should Be Equal As Strings ${resp.status_code} ${RESP_ERROR_CODE}
148 Wait Until Keyword Succeeds 10s 1s Check Tunnel Monitoring ${TMI_30000}
152 [Documentation] Run before the suite execution
153 DevstackUtils.Devstack Suite Setup
154 SetupUtils.Setup_Utils_For_Setup_And_Teardown
159 [Documentation] Run after the tests execution
161 Close All Connections
164 [Documentation] Clean the already existing tunnels and tep interfaces
165 ${resp} RequestsLibrary.Delete Request session ${TUNNEL_TRANSPORTZONE}
167 ${resp} RequestsLibrary.Delete Request session ${TUNNEL_INTERFACES}
171 [Documentation] Create Two Networks, Two Subnets, Four Ports And Four VMs
172 Log Create two networks
173 Create Network ${NETWORKS[0]}
174 Create Network ${NETWORKS[1]}
175 ${NET_LIST} List Networks
176 Should Contain ${NET_LIST} ${NETWORKS[0]}
177 Should Contain ${NET_LIST} ${NETWORKS[1]}
178 Wait Until Keyword Succeeds 3s 1s Check For Elements At URI ${NETWORK_URL} ${NETWORKS}
179 Log Create two subnets for previously created networks
180 Create SubNet ${NETWORKS[0]} ${SUBNETS[0]} ${SUBNET_CIDR[0]}
181 Create SubNet ${NETWORKS[1]} ${SUBNETS[1]} ${SUBNET_CIDR[1]}
182 ${SUB_LIST} List Subnets
183 Should Contain ${SUB_LIST} ${SUBNETS[0]}
184 Should Contain ${SUB_LIST} ${SUBNETS[1]}
185 Wait Until Keyword Succeeds 3s 1s Check For Elements At URI ${SUBNETWORK_URL} ${SUBNETS}
186 Log Create four ports under previously created subnets
187 Create Port ${NETWORKS[0]} ${PORT_LIST[0]} sg=sg-vpnservice
188 Create Port ${NETWORKS[0]} ${PORT_LIST[1]} sg=sg-vpnservice
189 Create Port ${NETWORKS[1]} ${PORT_LIST[2]} sg=sg-vpnservice
190 Create Port ${NETWORKS[1]} ${PORT_LIST[3]} sg=sg-vpnservice
191 Wait Until Keyword Succeeds 3s 1s Check For Elements At URI ${PORT_URL} ${PORT_LIST}
192 Log Create VM Instances
193 Create Vm Instance With Port On Compute Node ${PORT_LIST[0]} ${VM_INSTANCES_NET1[0]} ${OS_COMPUTE_1_IP} sg=sg-vpnservice
194 Create Vm Instance With Port On Compute Node ${PORT_LIST[1]} ${VM_INSTANCES_NET1[1]} ${OS_COMPUTE_2_IP} sg=sg-vpnservice
195 Create Vm Instance With Port On Compute Node ${PORT_LIST[2]} ${VM_INSTANCES_NET2[0]} ${OS_COMPUTE_1_IP} sg=sg-vpnservice
196 Create Vm Instance With Port On Compute Node ${PORT_LIST[3]} ${VM_INSTANCES_NET2[1]} ${OS_COMPUTE_2_IP} sg=sg-vpnservice
197 : FOR ${VM} IN @{VM_INSTANCES_NET1} @{VM_INSTANCES_NET2}
198 \ Wait Until Keyword Succeeds 25s 5s Verify VM Is ACTIVE ${VM}
199 ${VM_IP_NET1} ${VM_IP_NET2} Wait Until Keyword Succeeds 180s 10s Verify VMs received IP
200 Set Suite Variable ${VM_IP_NET2}
201 Set Suite Variable ${VM_IP_NET1}
202 [Teardown] Run Keywords Show Debugs @{VM_INSTANCES_NET1} @{VM_INSTANCES_NET2}
203 ... AND Get Suite Teardown Debugs
205 Verify VMs received IP
206 [Documentation] Verify VM received IP
207 ${VM_IP_NET1} ${DHCP_IP1} Verify VMs Received DHCP Lease @{VM_INSTANCES_NET1}
209 ${VM_IP_NET2} ${DHCP_IP2} Verify VMs Received DHCP Lease @{VM_INSTANCES_NET2}
211 Should Not Contain ${VM_IP_NET2} None
212 Should Not Contain ${VM_IP_NET1} None
213 [Return] ${VM_IP_NET1} ${VM_IP_NET2}
216 [Documentation] Verify Ping among VMs
217 ${output}= Execute Command on VM Instance @{NETWORKS}[0] ${VM_IP_NET1[0]} ping -c 3 ${VM_IP_NET1[1]}
218 Should Contain ${output} ${PING_REGEXP}
219 ${output}= Execute Command on VM Instance @{NETWORKS}[1] ${VM_IP_NET2[0]} ping -c 3 ${VM_IP_NET2[1]}
220 Should Contain ${output} ${PING_REGEXP}
221 ${output}= Execute Command on VM Instance @{NETWORKS}[0] ${VM_IP_NET1[1]} ping -c 3 ${VM_IP_NET1[0]}
222 Should Contain ${output} ${PING_REGEXP}
223 ${output}= Execute Command on VM Instance @{NETWORKS}[1] ${VM_IP_NET2[1]} ping -c 3 ${VM_IP_NET2[0]}
224 Should Contain ${output} ${PING_REGEXP}
226 Verify Flows Are Present
228 [Documentation] Verify Flows Are Present
229 ${flow_output}= Run Command On Remote System ${ip} sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
231 ${resp}= Should Contain ${flow_output} table=50
233 ${resp}= Should Match regexp ${flow_output} table=0.*goto_table:36
234 ${resp}= Should Match regexp ${flow_output} table=0.*goto_table:17
235 ${table51_output} = Get Lines Containing String ${flow_output} table=51
236 Log ${table51_output}
237 @{table51_output}= Split To Lines ${table51_output} 0 -1
238 : FOR ${line} IN @{table51_output}
240 \ ${resp}= Should Match Regexp ${line} ${MAC_REGEX}
242 Check Tunnel Monitoring
243 [Arguments] ${TMI_INTERVAL}
244 [Documentation] Check the tunnel monitoring interval through REST
245 ${resp} RequestsLibrary.Get Request session ${MONITOR_INTERVAL_URL}
247 Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
248 Should Contain ${resp.content} ${TMI_INTERVAL}
251 [Documentation] Create tunnels betwee the 2 compute nodes and Openstack controller.
252 Log If ODL version is Boron or higher then ITM tunnel should be auto configured. If not then the suite should fail. For ODL version Beryllium or lower, ITM tunnel should be created.
253 CompareStream.Run_Keyword_If_At_Least_Boron BuiltIn.Fail Tunnel should be auto configured for ${ODL_STREAM}
254 ${node_1_dpid}= Get DPID ${OS_COMPUTE_1_IP}
255 ${node_2_dpid}= Get DPID ${OS_COMPUTE_2_IP}
256 ${node_3_dpid}= Get DPID ${OS_CONTROL_NODE_IP}
257 ${node_1_adapter}= Get Ethernet Adapter ${OS_COMPUTE_1_IP}
258 ${node_2_adapter}= Get Ethernet Adapter ${OS_COMPUTE_2_IP}
259 ${node_3_adapter}= Get Ethernet Adapter ${OS_CONTROL_NODE_IP}
260 ${first_two_octets} ${third_octet} ${last_octet}= Split String From Right ${OS_COMPUTE_1_IP} . 2
261 ${subnet}= Set Variable ${first_two_octets}.0.0/16
262 ${gateway}= Get Default Gateway ${OS_COMPUTE_1_IP}
263 ${gateway1}= Get Default Gateway ${OS_CONTROL_NODE_IP}
264 ${gateway2}= Get Default Gateway ${OS_COMPUTE_2_IP}
265 Issue Command On Karaf Console tep:add ${node_1_dpid} ${node_1_adapter} 0 ${OS_COMPUTE_1_IP} ${subnet} null TZA
266 Issue Command On Karaf Console tep:add ${node_2_dpid} ${node_2_adapter} 0 ${OS_COMPUTE_2_IP} ${subnet} null TZA
267 Issue Command On Karaf Console tep:add ${node_3_dpid} ${node_3_adapter} 0 ${OS_CONTROL_NODE_IP} ${subnet} null TZA
268 Issue Command On Karaf Console tep:commit
269 ${output}= Issue Command On Karaf Console ${TEP_SHOW}
271 Wait Until Keyword Succeeds 30s 5s Verify Tunnel Status as UP
274 [Documentation] Delete the created VMs, ports, subnet and networks
275 Log Delete the VM instances
276 ${VM_INSTANCES} = Create List @{VM_INSTANCES_NET1} @{VM_INSTANCES_NET2}
277 : FOR ${VmInstance} IN @{VM_INSTANCES}
278 \ Delete Vm Instance ${VmInstance}
279 Log Delete neutron ports
280 : FOR ${Port} IN @{PORT_LIST}
281 \ Delete Port ${Port}
283 : FOR ${Subnet} IN @{SUBNETS}
284 \ Delete SubNet ${Subnet}
286 : FOR ${Network} IN @{NETWORKS}
287 \ Delete Network ${Network}