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
69 \ SSHLibrary.Write exit
70 \ SSHLibrary.Close Connection
72 Check Port Status Is ESTABLISHED
73 [Arguments] ${port} @{tools_ips}
74 [Documentation] This keyword will check whether ports are established or not on OVS
75 : FOR ${tools_ip} IN @{tools_ips}
76 \ ${check_establishment} = Utils.Run Command On Remote System And Log ${tools_ip} netstat -anp | grep ${port}
77 \ BuiltIn.Should Contain ${check_establishment} ESTABLISHED
78 [Return] ${check_establishment}
81 [Arguments] ${vlan_id} ${gateway_ip}
82 [Documentation] This keyword creates VTEPs between OVS
83 ${body} = Genius.Set Json ${vlan_id} ${gateway_ip} ${SUBNET} @{TOOLS_SYSTEM_ALL_IPS}
84 ${resp} = RequestsLibrary.Put Request session ${CONFIG_API}/itm:transport-zones/transport-zone/TZA data=${body}
85 BuiltIn.Should Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
88 [Arguments] ${vlan} ${gateway_ip} ${subnet} @{tools_ips}
89 [Documentation] Sets Json with the values passed for it.
90 ${body} = BuiltIn.Run Keyword If ${odl_stream_check } OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan_below_sodium.json
91 ... ELSE OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan_sodium_and_above.json
92 ${body} = BuiltIn.Run Keyword If ${odl_stream_check } String.Replace String ${body} 1.1.1.1 ${subnet}
93 ... ELSE BuiltIn.Set Variable ${body}
94 ${body} = BuiltIn.Run Keyword If ${odl_stream_check } String.Replace String ${body} "vlan-id": 0 "vlan-id": ${vlan}
95 ... ELSE BuiltIn.Set Variable ${body}
96 ${body} = BuiltIn.Run Keyword If ${odl_stream_check } String.Replace String ${body} "gateway-ip": "0.0.0.0" "gateway-ip": "${gateway_ip}"
97 ... ELSE BuiltIn.Set Variable ${body}
98 : FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
99 \ ${body} String.Replace String ${body} "dpn-id": 10${tool_system_index} "dpn-id": ${DPN_ID_LIST[${tool_system_index}]}
100 \ ${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}]"
102 [Return] ${body} # returns complete json that has been updated
105 [Documentation] This keyword builds the list of DPN ids after configuring OVS bridges on each of the TOOLS_SYSTEM_IPs.
106 @{DPN_ID_LIST} = BuiltIn.Create List
107 : FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
108 \ ${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 }'
109 \ ${dpn_id} Utils.Run Command On Remote System And Log ${tools_ip} echo \$\(\(16\#${output}\)\)
110 \ Collections.Append To List ${DPN_ID_LIST} ${dpn_id}
111 BuiltIn.Set Suite Variable @{DPN_ID_LIST}
114 [Documentation] Run at end of BFD suite
115 Genius.Delete All Vteps
119 [Documentation] This will delete vtep.
120 ${resp} = RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/
121 BuiltIn.Should Be Equal As Strings ${resp.status_code} 200
122 BuiltIn.Wait Until Keyword Succeeds 30 5 Genius.Verify Tunnel Delete on DS tun
125 [Documentation] Genius test case setup
126 BuiltIn.Run Keyword And Ignore Error KarafKeywords.Log_Testcase_Start_To_Controller_Karaf
129 [Arguments] ${data_models} ${test_name}=${SUITE_NAME}.${TEST_NAME} ${fail}=${FAIL_ON_EXCEPTIONS}
130 : FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
131 \ OVSDB.Get DumpFlows And Ovsconfig @{TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}] ${Bridge}
132 BuiltIn.Run Keyword And Ignore Error DataModels.Get Model Dump ${ODL_SYSTEM_IP} ${data_models}
133 KarafKeywords.Fail If Exceptions Found During Test ${test_name} fail=${fail}
134 ODLTools.Get All test_name=${test_name}
137 [Arguments] ${data_models}
138 Genius.Genius Test Teardown ${data_models} test_name=${SUITE_NAME} fail=False
140 ITM Direct Tunnels Start Suite
141 [Documentation] start suite for itm scalability
142 ClusterManagement.ClusterManagement_Setup
143 ClusterManagement.Stop_Members_From_List_Or_All
144 : FOR ${controller_index} IN RANGE ${NUM_ODL_SYSTEM}
145 \ 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}
146 ClusterManagement.Start_Members_From_List_Or_All
147 Genius.Genius Suite Setup
149 ITM Direct Tunnels Stop Suite
150 [Documentation] Stop suite for ITM Direct Tunnels.
151 : FOR ${controller_index} IN RANGE ${NUM_ODL_SYSTEM}
152 \ 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}
153 Genius.Genius Suite Teardown
155 Ovs Interface Verification
156 [Documentation] Checks whether the created Interface is seen on OVS or not.
157 : FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
158 \ Genius.Ovs Verification For Each Dpn ${tools_ip} ${TOOLS_SYSTEM_ALL_IPS}
161 [Arguments] ${itm_created[0]} ${switch_data}=${SWITCH_DATA}
162 [Documentation] It returns the created ITM Transport zone with the passed values during the creation is done.
163 Collections.Append To List ${switch_data} ${itm_created[0]}
164 Utils.Check For Elements At URI ${TUNNEL_TRANSPORTZONE}/transport-zone/${itm_created[0]} ${switch_data}
166 Check Tunnel Delete On OVS
167 [Arguments] ${tunnel_list}
168 [Documentation] Verifies the Tunnel is deleted from OVS.
169 : FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
170 \ ${output} = Utils.Run Command On Remote System ${tools_ip} sudo ovs-vsctl show
171 \ Genius.Verify Deleted Tunnels on OVS ${tunnel_list} ${output}
173 Check Table0 Entry In a Dpn
174 [Arguments] ${tools_ip} ${bridgename} ${port_numbers}
175 [Documentation] Checks the Table 0 entry in the OVS when flows are dumped.
176 ${check} = Utils.Run Command On Remote System And Log ${tools_ip} sudo ovs-ofctl -OOpenFlow13 dump-flows ${bridgename}
177 ${num_ports} = BuiltIn.Get Length ${port_numbers}
178 : FOR ${port_index} IN RANGE ${num_ports}
179 \ BuiltIn.Should Contain ${check} in_port=@{port_numbers}[${port_index}]
181 Verify Tunnel Status As Up
182 [Arguments] ${no_of_switches}=${NUM_TOOLS_SYSTEM}
183 [Documentation] Verify that the number of tunnels are UP
184 ${no_of_tunnels} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
185 ${lines_of_state_up} = String.Get Lines Containing String ${no_of_tunnels} ${STATE_UP}
186 ${actual_tunnel_count} = String.Get Line Count ${lines_of_state_up}
187 ${expected_tunnel_count} = BuiltIn.Evaluate ${no_of_switches}*(${no_of_switches}-1)
188 BuiltIn.Should Be Equal As Strings ${actual_tunnel_count} ${expected_tunnel_count}
191 [Arguments] ${tunnel_status} ${tunnel_names}
192 [Documentation] Verifies if all tunnels in the input, has the expected status(UP/DOWN/UNKNOWN)
193 ${tep_result} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
194 ${number_of_tunnels} = BuiltIn.Get Length ${tunnel_names}
195 : FOR ${each_tunnel} IN RANGE ${number_of_tunnels}
196 \ ${tunnel} = Collections.Get From List ${tunnel_names} ${each_tunnel}
197 \ ${tep_output} = String.Get Lines Containing String ${tep_result} ${tunnel}
198 \ BuiltIn.Should Contain ${tep_output} ${tunnel_status}
201 [Arguments] ${connection_id}
202 [Documentation] Retrieves the list of tunnel ports present on OVS
203 SSHLibrary.Switch Connection ${connection_id}
204 ${ovs_result} = Utils.Write Commands Until Expected Prompt sudo ovs-vsctl show ${DEFAULT_LINUX_PROMPT_STRICT}
205 @{tunnel_names} = BuiltIn.Create List
206 ${tunnels} = String.Get Lines Matching Regexp ${ovs_result} Interface "tun.*" True
207 @{tunnels_list} = String.Split To Lines ${tunnels}
208 : FOR ${tun} IN @{tunnels_list}
209 \ ${tun_list} Get Regexp Matches ${tun} tun.*\\w
210 \ Collections.Append To List ${tunnel_names} @{tun_list}
211 ${items_in_list} = BuiltIn.Get Length ${tunnel_names}
212 [Return] @{tunnel_names}
215 [Arguments] ${src} ${dst} ${type} ${config_api_type}=${EMPTY}
216 [Documentation] This keyword returns tunnel interface name between source DPN and destination DPN.
217 ... Statements are executed depending on whether it is itm tunnel state(default) or dpn tep state.
218 ${resp} = BuiltIn.Run Keyword If '${config_api_type}' == '${EMPTY}' RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/${type}/
219 ... ELSE RequestsLibrary.Get Request session ${CONFIG_API}/itm-state:dpn-teps-state/dpns-teps/${src}/remote-dpns/${dst}/
220 BuiltIn.Should Be Equal As Strings ${resp.status_code} ${RESP_CODE}
221 BuiltIn.Log ${resp.content}
222 ${respjson} = RequestsLibrary.To Json ${resp.content} pretty_print=True
223 ${json} = Utils.Json Parse From String ${resp.content}
224 BuiltIn.Should Contain ${resp.content} ${dst}
225 BuiltIn.Run Keyword If '${config_api_type}' == '${EMPTY}' BuiltIn.Should Contain ${resp.content} ${src}
226 ${tunnel_interface_name} = BuiltIn.Run Keyword If "tunnel-interface-names" in "${json}" Genius.Get Tunnel Interface Name ${json["internal-tunnel"][0]} tunnel-interface-names
227 ${tunnel_name_output} ${tunnel_name} = BuiltIn.Run Keyword Unless '${config_api_type}' == '${EMPTY}' BuiltIn.Should Match Regexp ${resp.content} "tunnel-name":"(tun[\\w\\d]+)"
228 ${tunnel} = BuiltIn.Set Variable If '${config_api_type}' == '${EMPTY}' ${tunnel_interface_name} ${tunnel_name}
231 Get Tunnel Interface Name
232 [Arguments] ${json} ${expected_tunnel_interface_name}
233 [Documentation] This keyword extracts tunnel interface name from json given as input.
234 ${tunnels} = Collections.Get From Dictionary ${json} ${expected_tunnel_interface_name}
235 [Return] ${tunnels[0]}
237 Verify Tunnel Delete on DS
238 [Arguments] ${tunnel}
239 [Documentation] This keyword confirms that specified tunnel is not present by giving command from karaf console.
240 ${output} = KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
241 BuiltIn.Should Not Contain ${output} ${tunnel}
244 [Documentation] Start suite for service recovery.
246 Genius.Create Vteps ${NO_VLAN} ${gateway_ip}
247 BuiltIn.Wait Until Keyword Succeeds 60s 5s Genius.Verify Tunnel Status As Up
248 Genius.Genius Suite Debugs ${data_models}
251 [Documentation] Stop suite for service recovery.
252 Genius.Delete All Vteps
253 Genius.Genius Suite Debugs ${data_models}
254 Genius.Genius Suite Teardown
256 Verify Tunnel Monitoring Status
257 [Arguments] ${tunnel_monitor_status}
258 ${output}= KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW}
259 BuiltIn.Should Contain ${output} ${tunnel_monitor_status}
261 Set Switch Configuration
262 [Documentation] This keyword will set manager,controller,tap port,bridge on each OVS
263 : FOR ${tool_system_index} IN RANGE ${NUM_TOOLS_SYSTEM}
264 \ SSHLibrary.Switch Connection @{TOOLS_SYSTEM_ALL_CONN_IDS}[${tool_system_index}]
265 \ SSHLibrary.Login With Public Key ${TOOLS_SYSTEM_USER} ${USER_HOME}/.ssh/${SSH_KEY} any
266 \ SSHLibrary.Execute Command sudo ovs-vsctl add-br ${Bridge}
267 \ SSHLibrary.Execute Command sudo ovs-vsctl set bridge ${Bridge} protocols=OpenFlow13
268 \ SSHLibrary.Execute Command sudo ovs-vsctl set-controller ${Bridge} tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT_6653}
269 \ SSHLibrary.Execute Command sudo ifconfig ${Bridge} up
270 \ 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
271 \ SSHLibrary.Execute Command sudo ovs-vsctl set-manager tcp:${ODL_SYSTEM_IP}:${OVSDBPORT}
272 \ SSHLibrary.Execute Command sudo ovs-vsctl show
274 Ovs Verification For Each Dpn
275 [Arguments] ${tools_system_ip} ${tools_ips}
276 [Documentation] This keyword will verify whether local and remote ip are present on the tunnels available on OVS
277 ${ovs_output} = Utils.Run Command On Remote System And Log ${tools_system_ip} sudo ovs-vsctl show
278 @{updated_tools_ip_list} = BuiltIn.Create List @{tools_ips}
279 Collections.Remove Values From List ${updated_tools_ip_list} ${tools_system_ip}
280 BuiltIn.Log Many @{updated_tools_ip_list}
281 ${num_tool_ips} BuiltIn.Get Length ${updated_tools_ip_list}
282 : FOR ${num} IN RANGE ${num_tool_ips}
283 \ ${tools_ip} = Collections.Get From List ${updated_tools_ip_list} ${num}
284 \ BuiltIn.Should Contain ${ovs_output} ${tools_ip}
287 [Documentation] The keyword fetches the list of operational tunnels from ODL
288 ${no_of_tunnels} KarafKeywords.Issue Command On Karaf Console ${TEP_SHOW_STATE}
289 ${tunnels} = String.Get Regexp Matches ${no_of_tunnels} tun[\\w\\d]+
290 BuiltIn.Log ${tunnels}
293 Verify Table0 Entry After fetching Port Number
294 [Documentation] This keyword will get the port number and checks the table0 entry for each dpn
295 : FOR ${tools_ip} IN @{TOOLS_SYSTEM_ALL_IPS}
296 \ ${check} = Utils.Run Command On Remote System And Log ${tools_ip} sudo ovs-ofctl -O OpenFlow13 show ${Bridge}
297 \ ${port_numbers} = String.Get Regexp Matches ${check} (\\d+).tun.* 1
298 \ Genius.Check Table0 Entry In a Dpn ${tools_ip} ${Bridge} ${port_numbers}
300 Verify Deleted Tunnels On OVS
301 [Arguments] ${tunnel_list} ${resp_data}
302 [Documentation] This will verify whether tunnel is deleted.
303 BuiltIn.Log ${resp_data}
304 : FOR ${tunnel} IN @{tunnel_list}
305 \ BuiltIn.Should Not Contain ${resp_data} ${tunnel}
307 Verify Response Code Of Dpn End Point Config API
308 [Arguments] ${dpn_list}=${DPN_ID_LIST}
309 [Documentation] This keyword will verify response code from itm-state: dpn endpoints config api for each dpn
310 : FOR ${dpn} IN @{dpn_list}
311 \ BuiltIn.Wait Until Keyword Succeeds 40 5 Utils.Get Data From URI session ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${dpn}/
313 Get Tunnel Between DPNs
314 [Arguments] ${tunnel_type} ${config_api_type} ${src_dpn_id} @{dst_dpn_ids}
315 [Documentation] This keyword will Get All the Tunnels available on DPN's
316 : FOR ${dst_dpn_id} IN @{dst_dpn_ids}
317 \ ${tunnel} = BuiltIn.Wait Until Keyword Succeeds 30 10 Genius.Get Tunnel ${src_dpn_id}
318 \ ... ${dst_dpn_id} ${tunnel_type} ${config_api_type}
320 Update Dpn id List And Get Tunnels
321 [Arguments] ${tunnel_type} ${config_api_type}=${EMPTY} ${dpn_ids}=${DPN_ID_LIST}
322 [Documentation] Update the exisisting dpn id list to form different combination of dpn ids such that tunnel formation between all dpns is verified.
323 : FOR ${dpn_id} IN @{dpn_ids}
324 \ @{dpn_ids_updated} = BuiltIn.Create List @{dpn_ids}
325 \ Collections.Remove Values From List ${dpn_ids_updated} ${dpn_id}
326 \ BuiltIn.Log Many ${dpn_ids_updated}
327 \ Genius.Get Tunnel Between DPNs ${tunnel_type} ${config_api_type} ${dpn_id} @{dpn_ids_updated}