2 Documentation This suite is a common keywords file for genius project.
5 Library OperatingSystem
6 Library RequestsLibrary
9 Resource ClusterManagement.robot
10 Resource CompareStream.robot
11 Resource DataModels.robot
12 Resource KarafKeywords.robot
13 Resource ODLTools.robot
15 Resource ToolsSystem.robot
17 Resource VpnOperations.robot
18 Resource ../variables/Variables.robot
19 Resource ../variables/netvirt/Variables.robot
24 ${genius_config_dir} ${CURDIR}/../variables/genius
25 ${Bridge} ${INTEGRATION_BRIDGE}
26 ${DEFAULT_MONITORING_INTERVAL} Tunnel Monitoring Interval (for VXLAN tunnels): 1000
27 @{GENIUS_DIAG_SERVICES} OPENFLOW IFM ITM DATASTORE OVSDB
29 ${port_name} br-int-eth1
32 ${DEFAULT_TRANSPORT_ZONE} default-transport-zone
33 ${SET_LOCAL_IP} sudo ovs-vsctl set O . other_config:local_ip=
34 ${REMOVE_LOCAL_IP} sudo ovs-vsctl remove O . other_config local_ip
35 ${odl_stream_check } ${Stream_dict}[${ODL_STREAM}] <= ${Stream_dict}[neon]
40 [Documentation] Create Rest Session to http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
42 RequestsLibrary.Create Session
44 ... http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
46 ... headers=${HEADERS}
50 [Documentation] Delete all sessions
51 RequestsLibrary.Delete All Sessions
55 [Documentation] Initial setup for Genius test suites
56 Run_Keyword_If_At_Least_Oxygen
57 ... Wait Until Keyword Succeeds
60 ... ClusterManagement.Check Status Of Services Is OPERATIONAL
61 ... @{GENIUS_DIAG_SERVICES}
62 KarafKeywords.Setup_Karaf_Keywords
63 ToolsSystem.Get Tools System Nodes Data
64 ${karaf_debug_enabled} = BuiltIn.Get_Variable_Value ${KARAF_DEBUG} ${False}
65 IF ${karaf_debug_enabled}
66 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set DEBUG org.opendaylight.genius
68 Genius.Set Switch Configuration
69 ${check} = BuiltIn.Wait Until Keyword Succeeds
72 ... Check Port Status Is ESTABLISHED
73 ... ${ODL_OF_PORT_6653}
74 ... @{TOOLS_SYSTEM_ALL_IPS}
75 ${check} = BuiltIn.Wait Until Keyword Succeeds
78 ... Check Port Status Is ESTABLISHED
80 ... @{TOOLS_SYSTEM_ALL_IPS}
82 @{SWITCH_DATA} = Collections.Combine Lists ${DPN_ID_LIST} ${TOOLS_SYSTEM_ALL_IPS}
83 BuiltIn.Set Suite Variable @{SWITCH_DATA}
84 ${substr} = Should Match Regexp ${TOOLS_SYSTEM_1_IP} [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
85 ${SUBNET} = Catenate ${substr}0
86 BuiltIn.Set Suite Variable ${SUBNET}
89 [Documentation] stops all connections and deletes all the bridges available on OVS
90 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
91 SSHLibrary.Switch Connection ${TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}]
92 SSHLibrary.Execute Command sudo ovs-vsctl del-br ${Bridge}
93 SSHLibrary.Execute Command sudo ovs-vsctl del-manager
95 SSHLibrary.Close Connection
98 Check Port Status Is ESTABLISHED
99 [Documentation] This keyword will check whether ports are established or not on OVS
100 [Arguments] ${port} @{tools_ips}
101 FOR ${tools_ip} IN @{tools_ips}
102 ${check_establishment} = Utils.Run Command On Remote System And Log
104 ... netstat -anp | grep ${port}
105 BuiltIn.Should Contain ${check_establishment} ESTABLISHED
107 RETURN ${check_establishment}
110 [Documentation] This keyword creates VTEPs between OVS
111 [Arguments] ${vlan_id} ${gateway_ip}
112 ${body} = Genius.Set Json ${vlan_id} ${gateway_ip} ${SUBNET} @{TOOLS_SYSTEM_ALL_IPS}
113 ${resp} = RequestsLibrary.Put Request
115 ... ${CONFIG_API}/itm:transport-zones/transport-zone/TZA
117 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
120 [Documentation] Sets Json with the values passed for it.
121 [Arguments] ${vlan} ${gateway_ip} ${subnet} @{tools_ips}
122 IF ${odl_stream_check }
123 ${body} = OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan_below_sodium.json
125 ${body} = OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan_sodium_and_above.json
127 IF ${odl_stream_check }
128 ${body} = String.Replace String ${body} 1.1.1.1 ${subnet}
130 ${body} = BuiltIn.Set Variable ${body}
132 IF ${odl_stream_check }
133 ${body} = String.Replace String ${body} "vlan-id": 0 "vlan-id": ${vlan}
135 ${body} = BuiltIn.Set Variable ${body}
137 IF ${odl_stream_check }
138 ${body} = String.Replace String ${body} "gateway-ip": "0.0.0.0" "gateway-ip": "${gateway_ip}"
140 ${body} = BuiltIn.Set Variable ${body}
142 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
143 ${body} = String.Replace String
145 ... "dpn-id": 10${tool_system_index}
146 ... "dpn-id": ${DPN_ID_LIST[${tool_system_index}]}
147 ${body} = String.Replace String
149 ... "ip-address": "${tool_system_index+2}.${tool_system_index+2}.${tool_system_index+2}.${tool_system_index+2}"
150 ... "ip-address": "${tools_ips}[${tool_system_index}]"
153 RETURN ${body} # returns complete json that has been updated
156 [Documentation] This keyword builds the list of DPN ids after configuring OVS bridges on each of the TOOLS_SYSTEM_IPs.
157 @{DPN_ID_LIST} = BuiltIn.Create List
158 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
159 ${output} = Utils.Run Command On Remote System And Log
161 ... sudo ovs-ofctl show -O Openflow13 ${Bridge} | head -1 | awk -F "dpid:" '{ print $2 }'
162 ${dpn_id} = Utils.Run Command On Remote System And Log ${tools_ip} echo \$\(\(16\#${output}\)\)
163 Collections.Append To List ${DPN_ID_LIST} ${dpn_id}
165 BuiltIn.Set Suite Variable @{DPN_ID_LIST}
168 [Documentation] Run at end of BFD suite
169 Genius.Delete All Vteps
173 [Documentation] This will delete vtep.
174 ${resp} = RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/
175 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
176 BuiltIn.Wait Until Keyword Succeeds 30 5 Genius.Verify Tunnel Delete on DS tun
179 [Documentation] Genius test case setup
180 BuiltIn.Run Keyword And Ignore Error KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
183 [Arguments] ${data_models} ${test_name}=${SUITE_NAME}.${TEST_NAME} ${fail}=${FAIL_ON_EXCEPTIONS}
184 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
185 OVSDB.Get DumpFlows And Ovsconfig ${TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}] ${Bridge}
187 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${ODL_SYSTEM_IP} ${data_models}
188 KarafKeywords.Fail If Exceptions Found During Test ${test_name} fail=${fail}
189 ODLTools.Get All test_name=${test_name}
192 [Arguments] ${data_models}
193 Genius.Genius Test Teardown ${data_models} test_name=${SUITE_NAME} fail=False
195 ITM Direct Tunnels Start Suite
196 [Documentation] start suite for itm scalability
197 ClusterManagement.ClusterManagement_Setup
198 ClusterManagement.Stop_Members_From_List_Or_All
199 FOR ${controller_index} IN RANGE ${NUM_ODL_SYSTEM}
200 Utils.Run Command On Remote System And Log
201 ... ${ODL_SYSTEM_${controller_index+1}_IP}
202 ... sed -i -- 's/<itm-direct-tunnels>false/<itm-direct-tunnels>true/g' ${GENIUS_IFM_CONFIG_FLAG}
204 ClusterManagement.Start_Members_From_List_Or_All
205 Genius.Genius Suite Setup
207 ITM Direct Tunnels Stop Suite
208 [Documentation] Stop suite for ITM Direct Tunnels.
209 FOR ${controller_index} IN RANGE ${NUM_ODL_SYSTEM}
210 Utils.Run Command On Remote System And Log
211 ... ${ODL_SYSTEM_${controller_index+1}_IP}
212 ... sed -i -- 's/<itm-direct-tunnels>true/<itm-direct-tunnels>false/g' ${GENIUS_IFM_CONFIG_FLAG}
214 Genius.Genius Suite Teardown
216 Ovs Interface Verification
217 [Documentation] Checks whether the created Interface is seen on OVS or not.
218 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
219 Genius.Ovs Verification For Each Dpn ${tools_ip} ${TOOLS_SYSTEM_ALL_IPS}
223 [Documentation] It returns the created ITM Transport zone with the passed values during the creation is done.
224 [Arguments] ${itm_created[0]} ${switch_data}=${SWITCH_DATA}
225 Collections.Append To List ${switch_data} ${itm_created[0]}
226 Utils.Check For Elements At URI ${TUNNEL_TRANSPORTZONE}/transport-zone/${itm_created[0]} ${switch_data}
228 Check Tunnel Delete On OVS
229 [Documentation] Verifies the Tunnel is deleted from OVS.
230 [Arguments] ${tunnel_list}
231 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
232 ${output} = Utils.Run Command On Remote System ${tools_ip} sudo ovs-vsctl show
233 Genius.Verify Deleted Tunnels on OVS ${tunnel_list} ${output}
236 Check Table0 Entry In a Dpn
237 [Documentation] Checks the Table 0 entry in the OVS when flows are dumped.
238 [Arguments] ${tools_ip} ${bridgename} ${port_numbers}
239 ${check} = Utils.Run Command On Remote System And Log
241 ... sudo ovs-ofctl -OOpenFlow13 dump-flows ${bridgename}
242 ${num_ports} = BuiltIn.Get Length ${port_numbers}
243 FOR ${port_index} IN RANGE ${num_ports}
244 BuiltIn.Should Contain ${check} in_port=${port_numbers}[${port_index}]
247 Verify Tunnel Status As Up
248 [Documentation] Verify that the number of tunnels are UP
249 [Arguments] ${no_of_switches}=${NUM_TOOLS_SYSTEM}
250 ${no_of_tunnels} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
251 ${lines_of_state_up} = String.Get Lines Containing String ${no_of_tunnels} ${STATE_UP}
252 ${actual_tunnel_count} = String.Get Line Count ${lines_of_state_up}
253 ${expected_tunnel_count} = BuiltIn.Evaluate ${no_of_switches}*(${no_of_switches}-1)
254 BuiltIn.Should Be Equal As Strings ${actual_tunnel_count} ${expected_tunnel_count}
257 [Documentation] Verifies if all tunnels in the input, has the expected status(UP/DOWN/UNKNOWN)
258 [Arguments] ${tunnel_status} ${tunnel_names}
259 ${tep_result} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
260 ${number_of_tunnels} = BuiltIn.Get Length ${tunnel_names}
261 FOR ${each_tunnel} IN RANGE ${number_of_tunnels}
262 ${tunnel} = Collections.Get From List ${tunnel_names} ${each_tunnel}
263 ${tep_output} = String.Get Lines Containing String ${tep_result} ${tunnel}
264 BuiltIn.Should Contain ${tep_output} ${tunnel_status}
268 [Documentation] Retrieves the list of tunnel ports present on OVS
269 [Arguments] ${connection_id}
270 SSHLibrary.Switch Connection ${connection_id}
271 ${ovs_result} = Utils.Write Commands Until Expected Prompt
272 ... sudo ovs-vsctl show
273 ... ${DEFAULT_LINUX_PROMPT_STRICT}
274 @{tunnel_names} = BuiltIn.Create List
275 ${tunnels} = String.Get Lines Matching Regexp ${ovs_result} Interface "tun.*" True
276 @{tunnels_list} = String.Split To Lines ${tunnels}
277 FOR ${tun} IN @{tunnels_list}
278 ${tun_list} = Get Regexp Matches ${tun} tun.*\\w
279 Collections.Append To List ${tunnel_names} @{tun_list}
281 ${items_in_list} = BuiltIn.Get Length ${tunnel_names}
282 RETURN @{tunnel_names}
285 [Documentation] This keyword returns tunnel interface name between source DPN and destination DPN.
286 ... Statements are executed depending on whether it is itm tunnel state(default) or dpn tep state.
287 [Arguments] ${src} ${dst} ${type} ${config_api_type}=${EMPTY}
288 IF '${config_api_type}' == '${EMPTY}'
289 ${resp} = RequestsLibrary.Get Request
291 ... ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/${type}/
293 ${resp} = RequestsLibrary.Get Request
295 ... ${CONFIG_API}/itm-state:dpn-teps-state/dpns-teps/${src}/remote-dpns/${dst}/
297 BuiltIn.Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
298 BuiltIn.Log ${resp.text}
299 ${respjson} = RequestsLibrary.To Json ${resp.text} pretty_print=True
300 ${json} = Utils.Json Parse From String ${resp.text}
301 BuiltIn.Should Contain ${resp.text} ${dst}
302 IF '${config_api_type}' == '${EMPTY}'
303 BuiltIn.Should Contain ${resp.text} ${src}
305 IF "tunnel-interface-names" in "${json}"
306 ${tunnel_interface_name} = Genius.Get Tunnel Interface Name
307 ... ${json["internal-tunnel"][0]}
308 ... tunnel-interface-names
310 ${tunnel_interface_name} = Set Variable ${None}
312 IF '${config_api_type}' != '${EMPTY}'
313 ${tunnel_name_output} ${tunnel_name} = BuiltIn.Should Match Regexp
315 ... "tunnel-name":"(tun[\\w\\d]+)"
317 ${tunnel_name_output} ${tunnel_name} = Set Variable ${None} ${None}
319 ${tunnel} = BuiltIn.Set Variable If
320 ... '${config_api_type}' == '${EMPTY}'
321 ... ${tunnel_interface_name}
325 Get Tunnel Interface Name
326 [Documentation] This keyword extracts tunnel interface name from json given as input.
327 [Arguments] ${json} ${expected_tunnel_interface_name}
328 ${tunnels} = Collections.Get From Dictionary ${json} ${expected_tunnel_interface_name}
331 Verify Tunnel Delete on DS
332 [Documentation] This keyword confirms that specified tunnel is not present by giving command from karaf console.
333 [Arguments] ${tunnel}
334 ${output} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
335 BuiltIn.Should Not Contain ${output} ${tunnel}
338 [Documentation] Start suite for service recovery.
340 Genius.Create Vteps ${NO_VLAN} ${gateway_ip}
341 BuiltIn.Wait Until Keyword Succeeds 60s 5s Genius.Verify Tunnel Status As Up
342 Genius.Genius Suite Debugs ${data_models}
345 [Documentation] Stop suite for service recovery.
346 Genius.Delete All Vteps
347 Genius.Genius Suite Debugs ${data_models}
348 Genius.Genius Suite Teardown
350 Verify Tunnel Monitoring Status
351 [Arguments] ${tunnel_monitor_status}
352 ${output} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW}
353 BuiltIn.Should Contain ${output} ${tunnel_monitor_status}
355 Set Switch Configuration
356 [Documentation] This keyword will set manager,controller,tap port,bridge on each OVS
357 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
358 SSHLibrary.Switch Connection ${TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}]
359 SSHLibrary.Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
360 SSHLibrary.Execute Command sudo ovs-vsctl add-br ${Bridge}
361 SSHLibrary.Execute Command sudo ovs-vsctl set bridge ${Bridge} protocols=OpenFlow13
362 SSHLibrary.Execute Command sudo ovs-vsctl set-controller ${Bridge} tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT_6653}
363 SSHLibrary.Execute Command sudo ifconfig ${Bridge} up
364 SSHLibrary.Execute Command
365 ... sudo ovs-vsctl add-port ${Bridge} tap${tool_system_index}ed70586-6c -- set Interface tap${tool_system_index}ed70586-6c type=tap
366 SSHLibrary.Execute Command sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
367 SSHLibrary.Execute Command sudo ovs-vsctl show
370 Ovs Verification For Each Dpn
371 [Documentation] This keyword will verify whether local and remote ip are present on the tunnels available on OVS
372 [Arguments] ${tools_system_ip} ${tools_ips}
373 ${ovs_output} = Utils.Run Command On Remote System And Log ${tools_system_ip} sudo ovs-vsctl show
374 @{updated_tools_ip_list} = BuiltIn.Create List @{tools_ips}
375 Collections.Remove Values From List ${updated_tools_ip_list} ${tools_system_ip}
376 BuiltIn.Log Many @{updated_tools_ip_list}
377 ${num_tool_ips} = BuiltIn.Get Length ${updated_tools_ip_list}
378 FOR ${num} IN RANGE ${num_tool_ips}
379 ${tools_ip} = Collections.Get From List ${updated_tools_ip_list} ${num}
380 BuiltIn.Should Contain ${ovs_output} ${tools_ip}
384 [Documentation] The keyword fetches the list of operational tunnels from ODL
385 ${no_of_tunnels} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
386 ${tunnels} = String.Get Regexp Matches ${no_of_tunnels} tun[\\w\\d]+
387 BuiltIn.Log ${tunnels}
390 Verify Table0 Entry After fetching Port Number
391 [Documentation] This keyword will get the port number and checks the table0 entry for each dpn
392 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
393 ${check} = Utils.Run Command On Remote System And Log
395 ... sudo ovs-ofctl -O OpenFlow13 show ${Bridge}
396 ${port_numbers} = String.Get Regexp Matches ${check} (\\d+).tun.* 1
397 Genius.Check Table0 Entry In a Dpn ${tools_ip} ${Bridge} ${port_numbers}
400 Verify Deleted Tunnels On OVS
401 [Documentation] This will verify whether tunnel is deleted.
402 [Arguments] ${tunnel_list} ${resp_data}
403 BuiltIn.Log ${resp_data}
404 FOR ${tunnel} IN @{tunnel_list}
405 BuiltIn.Should Not Contain ${resp_data} ${tunnel}
408 Verify Response Code Of Dpn End Point Config API
409 [Documentation] This keyword will verify response code from itm-state: dpn endpoints config api for each dpn
410 [Arguments] ${dpn_list}=${DPN_ID_LIST}
411 FOR ${dpn} IN @{dpn_list}
412 BuiltIn.Wait Until Keyword Succeeds
415 ... Utils.Get Data From URI
417 ... ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${dpn}/
420 Get Tunnel Between DPNs
421 [Documentation] This keyword will Get All the Tunnels available on DPN's
422 [Arguments] ${tunnel_type} ${config_api_type} ${src_dpn_id} @{dst_dpn_ids}
423 FOR ${dst_dpn_id} IN @{dst_dpn_ids}
424 ${tunnel} = BuiltIn.Wait Until Keyword Succeeds 30 10 Genius.Get Tunnel ${src_dpn_id}
425 ... ${dst_dpn_id} ${tunnel_type} ${config_api_type}
428 Update Dpn id List And Get Tunnels
429 [Documentation] Update the exisisting dpn id list to form different combination of dpn ids such that tunnel formation between all dpns is verified.
430 [Arguments] ${tunnel_type} ${config_api_type}=${EMPTY} ${dpn_ids}=${DPN_ID_LIST}
431 FOR ${dpn_id} IN @{dpn_ids}
432 @{dpn_ids_updated} = BuiltIn.Create List @{dpn_ids}
433 Collections.Remove Values From List ${dpn_ids_updated} ${dpn_id}
434 BuiltIn.Log Many ${dpn_ids_updated}
435 Genius.Get Tunnel Between DPNs ${tunnel_type} ${config_api_type} ${dpn_id} @{dpn_ids_updated}