2 Documentation This suite is a common keywords file for genius project.
5 Library OperatingSystem
6 Library RequestsLibrary
9 Resource ClusterManagement.robot
10 Resource DataModels.robot
11 Resource KarafKeywords.robot
12 Resource ODLTools.robot
14 Resource ToolsSystem.robot
16 Resource VpnOperations.robot
17 Resource ../variables/Variables.robot
18 Resource ../variables/netvirt/Variables.robot
23 ${genius_config_dir} ${CURDIR}/../variables/genius
24 ${Bridge} ${INTEGRATION_BRIDGE}
25 ${DEFAULT_MONITORING_INTERVAL} Tunnel Monitoring Interval (for VXLAN tunnels): 1000
26 @{GENIUS_DIAG_SERVICES} OPENFLOW IFM ITM DATASTORE OVSDB
28 ${port_name} br-int-eth1
31 ${DEFAULT_TRANSPORT_ZONE} default-transport-zone
32 ${SET_LOCAL_IP} sudo ovs-vsctl set O . other_config:local_ip=
33 ${REMOVE_LOCAL_IP} sudo ovs-vsctl remove O . other_config local_ip
34 ${odl_stream_check } ${Stream_dict}[${ODL_STREAM}] <= ${Stream_dict}[neon]
39 [Documentation] Create Rest Session to http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
41 RequestsLibrary.Create Session
43 ... http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
45 ... headers=${HEADERS}
49 [Documentation] Delete all sessions
50 RequestsLibrary.Delete All Sessions
54 [Documentation] Initial setup for Genius test suites
55 Wait Until Keyword Succeeds
58 ... ClusterManagement.Check Status Of Services Is OPERATIONAL
59 ... @{GENIUS_DIAG_SERVICES}
60 KarafKeywords.Setup_Karaf_Keywords
61 ToolsSystem.Get Tools System Nodes Data
62 ${karaf_debug_enabled} = BuiltIn.Get_Variable_Value ${KARAF_DEBUG} ${False}
63 IF ${karaf_debug_enabled}
64 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set DEBUG org.opendaylight.genius
66 Genius.Set Switch Configuration
67 ${check} = BuiltIn.Wait Until Keyword Succeeds
70 ... Check Port Status Is ESTABLISHED
71 ... ${ODL_OF_PORT_6653}
72 ... @{TOOLS_SYSTEM_ALL_IPS}
73 ${check} = BuiltIn.Wait Until Keyword Succeeds
76 ... Check Port Status Is ESTABLISHED
78 ... @{TOOLS_SYSTEM_ALL_IPS}
80 @{SWITCH_DATA} = Collections.Combine Lists ${DPN_ID_LIST} ${TOOLS_SYSTEM_ALL_IPS}
81 BuiltIn.Set Suite Variable @{SWITCH_DATA}
82 ${substr} = Should Match Regexp ${TOOLS_SYSTEM_1_IP} [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
83 ${SUBNET} = Catenate ${substr}0
84 BuiltIn.Set Suite Variable ${SUBNET}
87 [Documentation] stops all connections and deletes all the bridges available on OVS
88 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
89 SSHLibrary.Switch Connection ${TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}]
90 SSHLibrary.Execute Command sudo ovs-vsctl del-br ${Bridge}
91 SSHLibrary.Execute Command sudo ovs-vsctl del-manager
93 SSHLibrary.Close Connection
96 Check Port Status Is ESTABLISHED
97 [Documentation] This keyword will check whether ports are established or not on OVS
98 [Arguments] ${port} @{tools_ips}
99 FOR ${tools_ip} IN @{tools_ips}
100 ${check_establishment} = Utils.Run Command On Remote System And Log
102 ... netstat -anp | grep ${port}
103 BuiltIn.Should Contain ${check_establishment} ESTABLISHED
105 RETURN ${check_establishment}
108 [Documentation] This keyword creates VTEPs between OVS
109 [Arguments] ${vlan_id} ${gateway_ip}
110 ${body} = Genius.Set Json ${vlan_id} ${gateway_ip} ${SUBNET} @{TOOLS_SYSTEM_ALL_IPS}
111 ${resp} = RequestsLibrary.Put Request
113 ... ${CONFIG_API}/itm:transport-zones/transport-zone/TZA
115 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
118 [Documentation] Sets Json with the values passed for it.
119 [Arguments] ${vlan} ${gateway_ip} ${subnet} @{tools_ips}
120 IF ${odl_stream_check }
121 ${body} = OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan_below_sodium.json
123 ${body} = OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan_sodium_and_above.json
125 IF ${odl_stream_check }
126 ${body} = String.Replace String ${body} 1.1.1.1 ${subnet}
128 ${body} = BuiltIn.Set Variable ${body}
130 IF ${odl_stream_check }
131 ${body} = String.Replace String ${body} "vlan-id": 0 "vlan-id": ${vlan}
133 ${body} = BuiltIn.Set Variable ${body}
135 IF ${odl_stream_check }
136 ${body} = String.Replace String ${body} "gateway-ip": "0.0.0.0" "gateway-ip": "${gateway_ip}"
138 ${body} = BuiltIn.Set Variable ${body}
140 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
141 ${body} = String.Replace String
143 ... "dpn-id": 10${tool_system_index}
144 ... "dpn-id": ${DPN_ID_LIST[${tool_system_index}]}
145 ${body} = String.Replace String
147 ... "ip-address": "${tool_system_index+2}.${tool_system_index+2}.${tool_system_index+2}.${tool_system_index+2}"
148 ... "ip-address": "${tools_ips}[${tool_system_index}]"
151 RETURN ${body} # returns complete json that has been updated
154 [Documentation] This keyword builds the list of DPN ids after configuring OVS bridges on each of the TOOLS_SYSTEM_IPs.
155 @{DPN_ID_LIST} = BuiltIn.Create List
156 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
157 ${output} = Utils.Run Command On Remote System And Log
159 ... sudo ovs-ofctl show -O Openflow13 ${Bridge} | head -1 | awk -F "dpid:" '{ print $2 }'
160 ${dpn_id} = Utils.Run Command On Remote System And Log ${tools_ip} echo \$\(\(16\#${output}\)\)
161 Collections.Append To List ${DPN_ID_LIST} ${dpn_id}
163 BuiltIn.Set Suite Variable @{DPN_ID_LIST}
166 [Documentation] Run at end of BFD suite
167 Genius.Delete All Vteps
171 [Documentation] This will delete vtep.
172 ${resp} = RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/
173 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
174 BuiltIn.Wait Until Keyword Succeeds 30 5 Genius.Verify Tunnel Delete on DS tun
177 [Documentation] Genius test case setup
178 BuiltIn.Run Keyword And Ignore Error KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
181 [Arguments] ${data_models} ${test_name}=${SUITE_NAME}.${TEST_NAME} ${fail}=${FAIL_ON_EXCEPTIONS}
182 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
183 OVSDB.Get DumpFlows And Ovsconfig ${TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}] ${Bridge}
185 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${ODL_SYSTEM_IP} ${data_models}
186 KarafKeywords.Fail If Exceptions Found During Test ${test_name} fail=${fail}
187 ODLTools.Get All test_name=${test_name}
190 [Arguments] ${data_models}
191 Genius.Genius Test Teardown ${data_models} test_name=${SUITE_NAME} fail=False
193 ITM Direct Tunnels Start Suite
194 [Documentation] start suite for itm scalability
195 ClusterManagement.ClusterManagement_Setup
196 ClusterManagement.Stop_Members_From_List_Or_All
197 FOR ${controller_index} IN RANGE ${NUM_ODL_SYSTEM}
198 Utils.Run Command On Remote System And Log
199 ... ${ODL_SYSTEM_${controller_index+1}_IP}
200 ... sed -i -- 's/<itm-direct-tunnels>false/<itm-direct-tunnels>true/g' ${GENIUS_IFM_CONFIG_FLAG}
202 ClusterManagement.Start_Members_From_List_Or_All
203 Genius.Genius Suite Setup
205 ITM Direct Tunnels Stop Suite
206 [Documentation] Stop suite for ITM Direct Tunnels.
207 FOR ${controller_index} IN RANGE ${NUM_ODL_SYSTEM}
208 Utils.Run Command On Remote System And Log
209 ... ${ODL_SYSTEM_${controller_index+1}_IP}
210 ... sed -i -- 's/<itm-direct-tunnels>true/<itm-direct-tunnels>false/g' ${GENIUS_IFM_CONFIG_FLAG}
212 Genius.Genius Suite Teardown
214 Ovs Interface Verification
215 [Documentation] Checks whether the created Interface is seen on OVS or not.
216 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
217 Genius.Ovs Verification For Each Dpn ${tools_ip} ${TOOLS_SYSTEM_ALL_IPS}
221 [Documentation] It returns the created ITM Transport zone with the passed values during the creation is done.
222 [Arguments] ${itm_created[0]} ${switch_data}=${SWITCH_DATA}
223 Collections.Append To List ${switch_data} ${itm_created[0]}
224 Utils.Check For Elements At URI ${TUNNEL_TRANSPORTZONE}/transport-zone/${itm_created[0]} ${switch_data}
226 Check Tunnel Delete On OVS
227 [Documentation] Verifies the Tunnel is deleted from OVS.
228 [Arguments] ${tunnel_list}
229 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
230 ${output} = Utils.Run Command On Remote System ${tools_ip} sudo ovs-vsctl show
231 Genius.Verify Deleted Tunnels on OVS ${tunnel_list} ${output}
234 Check Table0 Entry In a Dpn
235 [Documentation] Checks the Table 0 entry in the OVS when flows are dumped.
236 [Arguments] ${tools_ip} ${bridgename} ${port_numbers}
237 ${check} = Utils.Run Command On Remote System And Log
239 ... sudo ovs-ofctl -OOpenFlow13 dump-flows ${bridgename}
240 ${num_ports} = BuiltIn.Get Length ${port_numbers}
241 FOR ${port_index} IN RANGE ${num_ports}
242 BuiltIn.Should Contain ${check} in_port=${port_numbers}[${port_index}]
245 Verify Tunnel Status As Up
246 [Documentation] Verify that the number of tunnels are UP
247 [Arguments] ${no_of_switches}=${NUM_TOOLS_SYSTEM}
248 ${no_of_tunnels} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
249 ${lines_of_state_up} = String.Get Lines Containing String ${no_of_tunnels} ${STATE_UP}
250 ${actual_tunnel_count} = String.Get Line Count ${lines_of_state_up}
251 ${expected_tunnel_count} = BuiltIn.Evaluate ${no_of_switches}*(${no_of_switches}-1)
252 BuiltIn.Should Be Equal As Strings ${actual_tunnel_count} ${expected_tunnel_count}
255 [Documentation] Verifies if all tunnels in the input, has the expected status(UP/DOWN/UNKNOWN)
256 [Arguments] ${tunnel_status} ${tunnel_names}
257 ${tep_result} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
258 ${number_of_tunnels} = BuiltIn.Get Length ${tunnel_names}
259 FOR ${each_tunnel} IN RANGE ${number_of_tunnels}
260 ${tunnel} = Collections.Get From List ${tunnel_names} ${each_tunnel}
261 ${tep_output} = String.Get Lines Containing String ${tep_result} ${tunnel}
262 BuiltIn.Should Contain ${tep_output} ${tunnel_status}
266 [Documentation] Retrieves the list of tunnel ports present on OVS
267 [Arguments] ${connection_id}
268 SSHLibrary.Switch Connection ${connection_id}
269 ${ovs_result} = Utils.Write Commands Until Expected Prompt
270 ... sudo ovs-vsctl show
271 ... ${DEFAULT_LINUX_PROMPT_STRICT}
272 @{tunnel_names} = BuiltIn.Create List
273 ${tunnels} = String.Get Lines Matching Regexp ${ovs_result} Interface "tun.*" True
274 @{tunnels_list} = String.Split To Lines ${tunnels}
275 FOR ${tun} IN @{tunnels_list}
276 ${tun_list} = Get Regexp Matches ${tun} tun.*\\w
277 Collections.Append To List ${tunnel_names} @{tun_list}
279 ${items_in_list} = BuiltIn.Get Length ${tunnel_names}
280 RETURN @{tunnel_names}
283 [Documentation] This keyword returns tunnel interface name between source DPN and destination DPN.
284 ... Statements are executed depending on whether it is itm tunnel state(default) or dpn tep state.
285 [Arguments] ${src} ${dst} ${type} ${config_api_type}=${EMPTY}
286 IF '${config_api_type}' == '${EMPTY}'
287 ${resp} = RequestsLibrary.Get Request
289 ... ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/${type}/
291 ${resp} = RequestsLibrary.Get Request
293 ... ${CONFIG_API}/itm-state:dpn-teps-state/dpns-teps/${src}/remote-dpns/${dst}/
295 BuiltIn.Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
296 BuiltIn.Log ${resp.text}
297 ${respjson} = RequestsLibrary.To Json ${resp.text} pretty_print=True
298 ${json} = Utils.Json Parse From String ${resp.text}
299 BuiltIn.Should Contain ${resp.text} ${dst}
300 IF '${config_api_type}' == '${EMPTY}'
301 BuiltIn.Should Contain ${resp.text} ${src}
303 IF "tunnel-interface-names" in "${json}"
304 ${tunnel_interface_name} = Genius.Get Tunnel Interface Name
305 ... ${json["internal-tunnel"][0]}
306 ... tunnel-interface-names
308 ${tunnel_interface_name} = Set Variable ${None}
310 IF '${config_api_type}' != '${EMPTY}'
311 ${tunnel_name_output} ${tunnel_name} = BuiltIn.Should Match Regexp
313 ... "tunnel-name":"(tun[\\w\\d]+)"
315 ${tunnel_name_output} ${tunnel_name} = Set Variable ${None} ${None}
317 ${tunnel} = BuiltIn.Set Variable If
318 ... '${config_api_type}' == '${EMPTY}'
319 ... ${tunnel_interface_name}
323 Get Tunnel Interface Name
324 [Documentation] This keyword extracts tunnel interface name from json given as input.
325 [Arguments] ${json} ${expected_tunnel_interface_name}
326 ${tunnels} = Collections.Get From Dictionary ${json} ${expected_tunnel_interface_name}
329 Verify Tunnel Delete on DS
330 [Documentation] This keyword confirms that specified tunnel is not present by giving command from karaf console.
331 [Arguments] ${tunnel}
332 ${output} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
333 BuiltIn.Should Not Contain ${output} ${tunnel}
336 [Documentation] Start suite for service recovery.
338 Genius.Create Vteps ${NO_VLAN} ${gateway_ip}
339 BuiltIn.Wait Until Keyword Succeeds 60s 5s Genius.Verify Tunnel Status As Up
340 Genius.Genius Suite Debugs ${data_models}
343 [Documentation] Stop suite for service recovery.
344 Genius.Delete All Vteps
345 Genius.Genius Suite Debugs ${data_models}
346 Genius.Genius Suite Teardown
348 Verify Tunnel Monitoring Status
349 [Arguments] ${tunnel_monitor_status}
350 ${output} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW}
351 BuiltIn.Should Contain ${output} ${tunnel_monitor_status}
353 Set Switch Configuration
354 [Documentation] This keyword will set manager,controller,tap port,bridge on each OVS
355 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
356 SSHLibrary.Switch Connection ${TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}]
357 SSHLibrary.Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
358 SSHLibrary.Execute Command sudo ovs-vsctl add-br ${Bridge}
359 SSHLibrary.Execute Command sudo ovs-vsctl set bridge ${Bridge} protocols=OpenFlow13
360 SSHLibrary.Execute Command sudo ovs-vsctl set-controller ${Bridge} tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT_6653}
361 SSHLibrary.Execute Command sudo ifconfig ${Bridge} up
362 SSHLibrary.Execute Command
363 ... sudo ovs-vsctl add-port ${Bridge} tap${tool_system_index}ed70586-6c -- set Interface tap${tool_system_index}ed70586-6c type=tap
364 SSHLibrary.Execute Command sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
365 SSHLibrary.Execute Command sudo ovs-vsctl show
368 Ovs Verification For Each Dpn
369 [Documentation] This keyword will verify whether local and remote ip are present on the tunnels available on OVS
370 [Arguments] ${tools_system_ip} ${tools_ips}
371 ${ovs_output} = Utils.Run Command On Remote System And Log ${tools_system_ip} sudo ovs-vsctl show
372 @{updated_tools_ip_list} = BuiltIn.Create List @{tools_ips}
373 Collections.Remove Values From List ${updated_tools_ip_list} ${tools_system_ip}
374 BuiltIn.Log Many @{updated_tools_ip_list}
375 ${num_tool_ips} = BuiltIn.Get Length ${updated_tools_ip_list}
376 FOR ${num} IN RANGE ${num_tool_ips}
377 ${tools_ip} = Collections.Get From List ${updated_tools_ip_list} ${num}
378 BuiltIn.Should Contain ${ovs_output} ${tools_ip}
382 [Documentation] The keyword fetches the list of operational tunnels from ODL
383 ${no_of_tunnels} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
384 ${tunnels} = String.Get Regexp Matches ${no_of_tunnels} tun[\\w\\d]+
385 BuiltIn.Log ${tunnels}
388 Verify Table0 Entry After fetching Port Number
389 [Documentation] This keyword will get the port number and checks the table0 entry for each dpn
390 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
391 ${check} = Utils.Run Command On Remote System And Log
393 ... sudo ovs-ofctl -O OpenFlow13 show ${Bridge}
394 ${port_numbers} = String.Get Regexp Matches ${check} (\\d+).tun.* 1
395 Genius.Check Table0 Entry In a Dpn ${tools_ip} ${Bridge} ${port_numbers}
398 Verify Deleted Tunnels On OVS
399 [Documentation] This will verify whether tunnel is deleted.
400 [Arguments] ${tunnel_list} ${resp_data}
401 BuiltIn.Log ${resp_data}
402 FOR ${tunnel} IN @{tunnel_list}
403 BuiltIn.Should Not Contain ${resp_data} ${tunnel}
406 Verify Response Code Of Dpn End Point Config API
407 [Documentation] This keyword will verify response code from itm-state: dpn endpoints config api for each dpn
408 [Arguments] ${dpn_list}=${DPN_ID_LIST}
409 FOR ${dpn} IN @{dpn_list}
410 BuiltIn.Wait Until Keyword Succeeds
413 ... Utils.Get Data From URI
415 ... ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${dpn}/
418 Get Tunnel Between DPNs
419 [Documentation] This keyword will Get All the Tunnels available on DPN's
420 [Arguments] ${tunnel_type} ${config_api_type} ${src_dpn_id} @{dst_dpn_ids}
421 FOR ${dst_dpn_id} IN @{dst_dpn_ids}
422 ${tunnel} = BuiltIn.Wait Until Keyword Succeeds 30 10 Genius.Get Tunnel ${src_dpn_id}
423 ... ${dst_dpn_id} ${tunnel_type} ${config_api_type}
426 Update Dpn id List And Get Tunnels
427 [Documentation] Update the exisisting dpn id list to form different combination of dpn ids such that tunnel formation between all dpns is verified.
428 [Arguments] ${tunnel_type} ${config_api_type}=${EMPTY} ${dpn_ids}=${DPN_ID_LIST}
429 FOR ${dpn_id} IN @{dpn_ids}
430 @{dpn_ids_updated} = BuiltIn.Create List @{dpn_ids}
431 Collections.Remove Values From List ${dpn_ids_updated} ${dpn_id}
432 BuiltIn.Log Many ${dpn_ids_updated}
433 Genius.Get Tunnel Between DPNs ${tunnel_type} ${config_api_type} ${dpn_id} @{dpn_ids_updated}