2 Documentation This suite is a common keywords file for genius project.
4 Library OperatingSystem
5 Library RequestsLibrary
8 Resource ClusterManagement.robot
9 Resource CompareStream.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
22 ${genius_config_dir} ${CURDIR}/../variables/genius
23 ${Bridge} ${INTEGRATION_BRIDGE}
24 ${DEFAULT_MONITORING_INTERVAL} Tunnel Monitoring Interval (for VXLAN tunnels): 1000
25 @{GENIUS_DIAG_SERVICES} OPENFLOW IFM ITM DATASTORE OVSDB
27 ${port_name} br-int-eth1
30 ${DEFAULT_TRANSPORT_ZONE} default-transport-zone
31 ${SET_LOCAL_IP} sudo ovs-vsctl set O . other_config:local_ip=
32 ${REMOVE_LOCAL_IP} sudo ovs-vsctl remove O . other_config local_ip
33 ${odl_stream_check } ${Stream_dict}[${ODL_STREAM}] <= ${Stream_dict}[neon]
37 [Documentation] Create Rest Session to http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
39 RequestsLibrary.Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS} timeout=5
42 [Documentation] Delete all sessions
43 RequestsLibrary.Delete All Sessions
47 [Documentation] Initial setup for Genius test suites
48 Run_Keyword_If_At_Least_Oxygen Wait Until Keyword Succeeds 60 2 ClusterManagement.Check Status Of Services Is OPERATIONAL @{GENIUS_DIAG_SERVICES}
49 KarafKeywords.Setup_Karaf_Keywords
50 ToolsSystem.Get Tools System Nodes Data
51 ${karaf_debug_enabled} = BuiltIn.Get_Variable_Value ${KARAF_DEBUG} ${False}
52 BuiltIn.run_keyword_if ${karaf_debug_enabled} KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set DEBUG org.opendaylight.genius
53 Genius.Set Switch Configuration
54 ${check} = BuiltIn.Wait Until Keyword Succeeds 30 10 Check Port Status Is ESTABLISHED ${ODL_OF_PORT_6653} @{TOOLS_SYSTEM_ALL_IPS}
55 ${check} = BuiltIn.Wait Until Keyword Succeeds 30 10 Check Port Status Is ESTABLISHED ${OVSDBPORT} @{TOOLS_SYSTEM_ALL_IPS}
57 @{SWITCH_DATA} = Collections.Combine Lists ${DPN_ID_LIST} ${TOOLS_SYSTEM_ALL_IPS}
58 BuiltIn.Set Suite Variable @{SWITCH_DATA}
59 ${substr} Should Match Regexp ${TOOLS_SYSTEM_1_IP} [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
60 ${SUBNET} = Catenate ${substr}0
61 BuiltIn.Set Suite Variable ${SUBNET}
64 [Documentation] stops all connections and deletes all the bridges available on OVS
65 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
66 SSHLibrary.Switch Connection @{TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}]
67 SSHLibrary.Execute Command sudo ovs-vsctl del-br ${Bridge}
68 SSHLibrary.Execute Command sudo ovs-vsctl del-manager
70 SSHLibrary.Close Connection
73 Check Port Status Is ESTABLISHED
74 [Arguments] ${port} @{tools_ips}
75 [Documentation] This keyword will check whether ports are established or not on OVS
76 FOR ${tools_ip} IN @{tools_ips}
77 ${check_establishment} = Utils.Run Command On Remote System And Log ${tools_ip} netstat -anp | grep ${port}
78 BuiltIn.Should Contain ${check_establishment} ESTABLISHED
80 [Return] ${check_establishment}
83 [Arguments] ${vlan_id} ${gateway_ip}
84 [Documentation] This keyword creates VTEPs between OVS
85 ${body} = Genius.Set Json ${vlan_id} ${gateway_ip} ${SUBNET} @{TOOLS_SYSTEM_ALL_IPS}
86 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/itm:transport-zones/transport-zone/TZA data=${body}
87 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
90 [Arguments] ${vlan} ${gateway_ip} ${subnet} @{tools_ips}
91 [Documentation] Sets Json with the values passed for it.
92 ${body} = BuiltIn.Run Keyword If ${odl_stream_check } OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan_below_sodium.json
93 ... ELSE OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan_sodium_and_above.json
94 ${body} = BuiltIn.Run Keyword If ${odl_stream_check } String.Replace String ${body} 1.1.1.1 ${subnet}
95 ... ELSE BuiltIn.Set Variable ${body}
96 ${body} = BuiltIn.Run Keyword If ${odl_stream_check } String.Replace String ${body} "vlan-id": 0 "vlan-id": ${vlan}
97 ... ELSE BuiltIn.Set Variable ${body}
98 ${body} = BuiltIn.Run Keyword If ${odl_stream_check } String.Replace String ${body} "gateway-ip": "0.0.0.0" "gateway-ip": "${gateway_ip}"
99 ... ELSE BuiltIn.Set Variable ${body}
100 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
101 ${body} String.Replace String ${body} "dpn-id": 10${tool_system_index} "dpn-id": ${DPN_ID_LIST[${tool_system_index}]}
102 ${body} String.Replace String ${body} "ip-address": "${tool_system_index+2}.${tool_system_index+2}.${tool_system_index+2}.${tool_system_index+2}" "ip-address": "@{tools_ips}[${tool_system_index}]"
105 [Return] ${body} # returns complete json that has been updated
108 [Documentation] This keyword builds the list of DPN ids after configuring OVS bridges on each of the TOOLS_SYSTEM_IPs.
109 @{DPN_ID_LIST} = BuiltIn.Create List
110 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
111 ${output} Utils.Run Command On Remote System And Log ${tools_ip} sudo ovs-ofctl show -O Openflow13 ${Bridge} | head -1 | awk -F "dpid:" '{ print $2 }'
112 ${dpn_id} Utils.Run Command On Remote System And Log ${tools_ip} echo \$\(\(16\#${output}\)\)
113 Collections.Append To List ${DPN_ID_LIST} ${dpn_id}
115 BuiltIn.Set Suite Variable @{DPN_ID_LIST}
118 [Documentation] Run at end of BFD suite
119 Genius.Delete All Vteps
123 [Documentation] This will delete vtep.
124 ${resp} = RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/
125 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
126 BuiltIn.Wait Until Keyword Succeeds 30 5 Genius.Verify Tunnel Delete on DS tun
129 [Documentation] Genius test case setup
130 BuiltIn.Run Keyword And Ignore Error KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
133 [Arguments] ${data_models} ${test_name}=${SUITE_NAME}.${TEST_NAME} ${fail}=${FAIL_ON_EXCEPTIONS}
134 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
135 OVSDB.Get DumpFlows And Ovsconfig @{TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}] ${Bridge}
137 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${ODL_SYSTEM_IP} ${data_models}
138 KarafKeywords.Fail If Exceptions Found During Test ${test_name} fail=${fail}
139 ODLTools.Get All test_name=${test_name}
142 [Arguments] ${data_models}
143 Genius.Genius Test Teardown ${data_models} test_name=${SUITE_NAME} fail=False
145 ITM Direct Tunnels Start Suite
146 [Documentation] start suite for itm scalability
147 ClusterManagement.ClusterManagement_Setup
148 ClusterManagement.Stop_Members_From_List_Or_All
149 FOR ${controller_index} IN RANGE ${NUM_ODL_SYSTEM}
150 Utils.Run Command On Remote System And Log ${ODL_SYSTEM_${controller_index+1}_IP} sed -i -- 's/<itm-direct-tunnels>false/<itm-direct-tunnels>true/g' ${GENIUS_IFM_CONFIG_FLAG}
152 ClusterManagement.Start_Members_From_List_Or_All
153 Genius.Genius Suite Setup
155 ITM Direct Tunnels Stop Suite
156 [Documentation] Stop suite for ITM Direct Tunnels.
157 FOR ${controller_index} IN RANGE ${NUM_ODL_SYSTEM}
158 Utils.Run Command On Remote System And Log ${ODL_SYSTEM_${controller_index+1}_IP} sed -i -- 's/<itm-direct-tunnels>true/<itm-direct-tunnels>false/g' ${GENIUS_IFM_CONFIG_FLAG}
160 Genius.Genius Suite Teardown
162 Ovs Interface Verification
163 [Documentation] Checks whether the created Interface is seen on OVS or not.
164 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
165 Genius.Ovs Verification For Each Dpn ${tools_ip} ${TOOLS_SYSTEM_ALL_IPS}
169 [Arguments] ${itm_created[0]} ${switch_data}=${SWITCH_DATA}
170 [Documentation] It returns the created ITM Transport zone with the passed values during the creation is done.
171 Collections.Append To List ${switch_data} ${itm_created[0]}
172 Utils.Check For Elements At URI ${TUNNEL_TRANSPORTZONE}/transport-zone/${itm_created[0]} ${switch_data}
174 Check Tunnel Delete On OVS
175 [Arguments] ${tunnel_list}
176 [Documentation] Verifies the Tunnel is deleted from OVS.
177 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
178 ${output} = Utils.Run Command On Remote System ${tools_ip} sudo ovs-vsctl show
179 Genius.Verify Deleted Tunnels on OVS ${tunnel_list} ${output}
182 Check Table0 Entry In a Dpn
183 [Arguments] ${tools_ip} ${bridgename} ${port_numbers}
184 [Documentation] Checks the Table 0 entry in the OVS when flows are dumped.
185 ${check} = Utils.Run Command On Remote System And Log ${tools_ip} sudo ovs-ofctl -OOpenFlow13 dump-flows ${bridgename}
186 ${num_ports} = BuiltIn.Get Length ${port_numbers}
187 FOR ${port_index} IN RANGE ${num_ports}
188 BuiltIn.Should Contain ${check} in_port=@{port_numbers}[${port_index}]
191 Verify Tunnel Status As Up
192 [Arguments] ${no_of_switches}=${NUM_TOOLS_SYSTEM}
193 [Documentation] Verify that the number of tunnels are UP
194 ${no_of_tunnels} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
195 ${lines_of_state_up} = String.Get Lines Containing String ${no_of_tunnels} ${STATE_UP}
196 ${actual_tunnel_count} = String.Get Line Count ${lines_of_state_up}
197 ${expected_tunnel_count} = BuiltIn.Evaluate ${no_of_switches}*(${no_of_switches}-1)
198 BuiltIn.Should Be Equal As Strings ${actual_tunnel_count} ${expected_tunnel_count}
201 [Arguments] ${tunnel_status} ${tunnel_names}
202 [Documentation] Verifies if all tunnels in the input, has the expected status(UP/DOWN/UNKNOWN)
203 ${tep_result} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
204 ${number_of_tunnels} = BuiltIn.Get Length ${tunnel_names}
205 FOR ${each_tunnel} IN RANGE ${number_of_tunnels}
206 ${tunnel} = Collections.Get From List ${tunnel_names} ${each_tunnel}
207 ${tep_output} = String.Get Lines Containing String ${tep_result} ${tunnel}
208 BuiltIn.Should Contain ${tep_output} ${tunnel_status}
212 [Arguments] ${connection_id}
213 [Documentation] Retrieves the list of tunnel ports present on OVS
214 SSHLibrary.Switch Connection ${connection_id}
215 ${ovs_result} = Utils.Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
216 @{tunnel_names} = BuiltIn.Create List
217 ${tunnels} = String.Get Lines Matching Regexp ${ovs_result} Interface "tun.*" True
218 @{tunnels_list} = String.Split To Lines ${tunnels}
219 FOR ${tun} IN @{tunnels_list}
220 ${tun_list} Get Regexp Matches ${tun} tun.*\\w
221 Collections.Append To List ${tunnel_names} @{tun_list}
223 ${items_in_list} = BuiltIn.Get Length ${tunnel_names}
224 [Return] @{tunnel_names}
227 [Arguments] ${src} ${dst} ${type} ${config_api_type}=${EMPTY}
228 [Documentation] This keyword returns tunnel interface name between source DPN and destination DPN.
229 ... Statements are executed depending on whether it is itm tunnel state(default) or dpn tep state.
230 ${resp} = BuiltIn.Run Keyword If '${config_api_type}' == '${EMPTY}' RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/${type}/
231 ... ELSE RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:dpn-teps-state/dpns-teps/${src}/remote-dpns/${dst}/
232 BuiltIn.Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
233 BuiltIn.Log ${resp.content}
234 ${respjson} = RequestsLibrary.To Json ${resp.content} pretty_print=True
235 ${json} = Utils.Json Parse From String ${resp.content}
236 BuiltIn.Should Contain ${resp.text} ${dst}
237 BuiltIn.Run Keyword If '${config_api_type}' == '${EMPTY}' BuiltIn.Should Contain ${resp.text} ${src}
238 ${tunnel_interface_name} = BuiltIn.Run Keyword If "tunnel-interface-names" in "${json}" Genius.Get Tunnel Interface Name ${json["internal-tunnel"][0]} tunnel-interface-names
239 ${tunnel_name_output} ${tunnel_name} = BuiltIn.Run Keyword Unless '${config_api_type}' == '${EMPTY}' BuiltIn.Should Match Regexp ${resp.text} "tunnel-name":"(tun[\\w\\d]+)"
240 ${tunnel} = BuiltIn.Set Variable If '${config_api_type}' == '${EMPTY}' ${tunnel_interface_name} ${tunnel_name}
243 Get Tunnel Interface Name
244 [Arguments] ${json} ${expected_tunnel_interface_name}
245 [Documentation] This keyword extracts tunnel interface name from json given as input.
246 ${tunnels} = Collections.Get From Dictionary ${json} ${expected_tunnel_interface_name}
247 [Return] ${tunnels[0]}
249 Verify Tunnel Delete on DS
250 [Arguments] ${tunnel}
251 [Documentation] This keyword confirms that specified tunnel is not present by giving command from karaf console.
252 ${output} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
253 BuiltIn.Should Not Contain ${output} ${tunnel}
256 [Documentation] Start suite for service recovery.
258 Genius.Create Vteps ${NO_VLAN} ${gateway_ip}
259 BuiltIn.Wait Until Keyword Succeeds 60s 5s Genius.Verify Tunnel Status As Up
260 Genius.Genius Suite Debugs ${data_models}
263 [Documentation] Stop suite for service recovery.
264 Genius.Delete All Vteps
265 Genius.Genius Suite Debugs ${data_models}
266 Genius.Genius Suite Teardown
268 Verify Tunnel Monitoring Status
269 [Arguments] ${tunnel_monitor_status}
270 ${output}= KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW}
271 BuiltIn.Should Contain ${output} ${tunnel_monitor_status}
273 Set Switch Configuration
274 [Documentation] This keyword will set manager,controller,tap port,bridge on each OVS
275 FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
276 SSHLibrary.Switch Connection @{TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}]
277 SSHLibrary.Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
278 SSHLibrary.Execute Command sudo ovs-vsctl add-br ${Bridge}
279 SSHLibrary.Execute Command sudo ovs-vsctl set bridge ${Bridge} protocols=OpenFlow13
280 SSHLibrary.Execute Command sudo ovs-vsctl set-controller ${Bridge} tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT_6653}
281 SSHLibrary.Execute Command sudo ifconfig ${Bridge} up
282 SSHLibrary.Execute Command sudo ovs-vsctl add-port ${Bridge} tap${tool_system_index}ed70586-6c -- set Interface tap${tool_system_index}ed70586-6c type=tap
283 SSHLibrary.Execute Command sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
284 SSHLibrary.Execute Command sudo ovs-vsctl show
287 Ovs Verification For Each Dpn
288 [Arguments] ${tools_system_ip} ${tools_ips}
289 [Documentation] This keyword will verify whether local and remote ip are present on the tunnels available on OVS
290 ${ovs_output} = Utils.Run Command On Remote System And Log ${tools_system_ip} sudo ovs-vsctl show
291 @{updated_tools_ip_list} = BuiltIn.Create List @{tools_ips}
292 Collections.Remove Values From List ${updated_tools_ip_list} ${tools_system_ip}
293 BuiltIn.Log Many @{updated_tools_ip_list}
294 ${num_tool_ips} BuiltIn.Get Length ${updated_tools_ip_list}
295 FOR ${num} IN RANGE ${num_tool_ips}
296 ${tools_ip} = Collections.Get From List ${updated_tools_ip_list} ${num}
297 BuiltIn.Should Contain ${ovs_output} ${tools_ip}
301 [Documentation] The keyword fetches the list of operational tunnels from ODL
302 ${no_of_tunnels} KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
303 ${tunnels} = String.Get Regexp Matches ${no_of_tunnels} tun[\\w\\d]+
304 BuiltIn.Log ${tunnels}
307 Verify Table0 Entry After fetching Port Number
308 [Documentation] This keyword will get the port number and checks the table0 entry for each dpn
309 FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
310 ${check} = Utils.Run Command On Remote System And Log ${tools_ip} sudo ovs-ofctl -O OpenFlow13 show ${Bridge}
311 ${port_numbers} = String.Get Regexp Matches ${check} (\\d+).tun.* 1
312 Genius.Check Table0 Entry In a Dpn ${tools_ip} ${Bridge} ${port_numbers}
315 Verify Deleted Tunnels On OVS
316 [Arguments] ${tunnel_list} ${resp_data}
317 [Documentation] This will verify whether tunnel is deleted.
318 BuiltIn.Log ${resp_data}
319 FOR ${tunnel} IN @{tunnel_list}
320 BuiltIn.Should Not Contain ${resp_data} ${tunnel}
323 Verify Response Code Of Dpn End Point Config API
324 [Arguments] ${dpn_list}=${DPN_ID_LIST}
325 [Documentation] This keyword will verify response code from itm-state: dpn endpoints config api for each dpn
326 FOR ${dpn} IN @{dpn_list}
327 BuiltIn.Wait Until Keyword Succeeds 40 5 Utils.Get Data From URI session ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${dpn}/
330 Get Tunnel Between DPNs
331 [Arguments] ${tunnel_type} ${config_api_type} ${src_dpn_id} @{dst_dpn_ids}
332 [Documentation] This keyword will Get All the Tunnels available on DPN's
333 FOR ${dst_dpn_id} IN @{dst_dpn_ids}
334 ${tunnel} = BuiltIn.Wait Until Keyword Succeeds 30 10 Genius.Get Tunnel ${src_dpn_id}
335 ... ${dst_dpn_id} ${tunnel_type} ${config_api_type}
338 Update Dpn id List And Get Tunnels
339 [Arguments] ${tunnel_type} ${config_api_type}=${EMPTY} ${dpn_ids}=${DPN_ID_LIST}
340 [Documentation] Update the exisisting dpn id list to form different combination of dpn ids such that tunnel formation between all dpns is verified.
341 FOR ${dpn_id} IN @{dpn_ids}
342 @{dpn_ids_updated} = BuiltIn.Create List @{dpn_ids}
343 Collections.Remove Values From List ${dpn_ids_updated} ${dpn_id}
344 BuiltIn.Log Many ${dpn_ids_updated}
345 Genius.Get Tunnel Between DPNs ${tunnel_type} ${config_api_type} ${dpn_id} @{dpn_ids_updated}