blob: 13900772bb2ba4a789083bed9dbbd0de543228a6 [file] [log] [blame]
Anusha Dathatri21ac59f2020-07-14 13:12:58 -05001*** Settings ***
2
3Documentation Test OpenBMC GUI "Network settings" sub-menu of
4... "Server configuration".
5
Rahul Maheshwari41747da2020-11-17 09:09:52 -06006Resource ../../lib/gui_resource.robot
Anves Kumar rayankula65e5ed22020-09-17 04:44:44 -05007Resource ../../../lib/bmc_network_utils.robot
Anusha Dathatri21ac59f2020-07-14 13:12:58 -05008
9Suite Setup Suite Setup Execution
10Suite Teardown Close Browser
11
12*** Variables ***
13
Anusha Dathatrie11a54d2020-08-31 08:35:47 -050014${xpath_network_setting_heading} //h1[text()="Network settings"]
15${xpath_interface} //h2[text()="Interface"]
16${xpath_system} //h2[text()="System"]
Anves Kumar rayankulabd101342021-05-06 06:36:14 -050017${xpath_static_ipv4} //h2[text()="IPV4"]
Anusha Dathatrie11a54d2020-08-31 08:35:47 -050018${xpath_static_dns} //h2[text()="Static DNS"]
19${xpath_hostname_input} //*[@data-test-id="networkSettings-input-hostname"]
20${xpath_network_save_settings} //button[@data-test-id="networkSettings-button-saveNetworkSettings"]
21${xpath_default_gateway_input} //*[@data-test-id="networkSettings-input-gateway"]
22${xpath_mac_address_input} //*[@data-test-id="networkSettings-input-macAddress"]
23${xpath_static_input_ip0} //*[@data-test-id="networkSettings-input-staticIpv4-0"]
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -060024${xpath_static_input_ip1} //*[@data-test-id="networkSettings-input-staticIpv4-1"]
Anusha Dathatrie11a54d2020-08-31 08:35:47 -050025${xpath_add_static_ip} //button[contains(text(),"Add static IP")]
26${xpath_setting_success} //*[contains(text(),"Successfully saved network settings.")]
27${xpath_add_dns_server} //button[contains(text(),"Add DNS server")]
Anves Kumar rayankula65e5ed22020-09-17 04:44:44 -050028${xpath_network_interface} //*[@data-test-id="networkSettings-select-interface"]
29${xpath_input_netmask_addr0} //*[@data-test-id="networkSettings-input-subnetMask-0"]
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -060030${xpath_input_netmask_addr1} //*[@data-test-id="networkSettings-input-subnetMask-1"]
Anves Kumar rayankula43d8fe82020-12-08 21:21:38 -060031${xpath_delete_static_ip} //*[@title="Delete IPv4 row"]
Anves Kumar rayankula4c884472020-11-24 05:03:45 -060032${xpath_input_dns_server} //*[@data-test-id="networkSettings-input-dnsAddress-0"]
33${xpath_delete_dns_server} //*[@title="Delete DNS row"]
Anves Kumar rayankulada394342021-01-17 23:51:16 -060034${xpath_ip_table} //*[@aria-colcount="3"]
Anves Kumar rayankula4c884472020-11-24 05:03:45 -060035
Anves Kumar rayankula4c884472020-11-24 05:03:45 -060036@{static_name_servers} 10.10.10.10
Anves Kumar rayankula89266292020-12-28 01:29:23 -060037@{null_value} null
38@{empty_dictionary} {}
39@{string_value} aa.bb.cc.dd
40@{special_char_value} @@@.%%.44.11
Anusha Dathatri21ac59f2020-07-14 13:12:58 -050041
Anves Kumar rayankulab2f73772021-05-11 04:58:25 -050042${test_ipv4_addr} 10.7.7.7
Anves Kumar rayankula14a8c982021-05-25 07:31:53 -050043${test_ipv4_addr2} 10.7.7.8
Anves Kumar rayankulab2f73772021-05-11 04:58:25 -050044${test_subnet_mask} 255.255.0.0
Anves Kumar rayankulada394342021-01-17 23:51:16 -060045
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -060046# Valid netmask is 4 bytes long and has continuous block of 1s.
47# Maximum valid value in each octet is 255 and least value is 0.
48# Maximum value of octet in netmask is 255.
Anves Kumar rayankulab2f73772021-05-11 04:58:25 -050049${alpha_netmask} ff.ff.ff.ff
50${out_of_range_netmask} 255.256.255.0
51${more_byte_netmask} 255.255.255.0.0
52${lowest_netmask} 128.0.0.0
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -060053
Anusha Dathatri21ac59f2020-07-14 13:12:58 -050054*** Test Cases ***
55
Anusha Dathatrie11a54d2020-08-31 08:35:47 -050056Verify Navigation To Network Settings Page
57 [Documentation] Verify navigation to network settings page.
58 [Tags] Verify_Navigation_To_Network_Settings_Page
59
60 Page Should Contain Element ${xpath_network_setting_heading}
61
62
63Verify Existence Of All Sections In Network Settings Page
64 [Documentation] Verify existence of all sections in network settings page.
65 [Tags] Verify_Existence_Of_All_Sections_In_Network_Settings_Page
66
67 Page Should Contain Element ${xpath_interface}
68 Page Should Contain Element ${xpath_system}
69 Page Should Contain Element ${xpath_static_ipv4}
70 Page Should Contain Element ${xpath_static_dns}
Anves Kumar rayankula43d8fe82020-12-08 21:21:38 -060071 Page Should Contain Button ${xpath_delete_static_ip}
Anusha Dathatrie11a54d2020-08-31 08:35:47 -050072
73
74Verify Existence Of All Buttons In Network Settings Page
75 [Documentation] Verify existence of all buttons in network settings page.
76 [Tags] Verify_Existence_Of_All_Buttons_In_Network_Settings_Page
77
78 Page Should Contain Element ${xpath_add_static_ip}
79 Page Should Contain Element ${xpath_add_dns_server}
80
81
Anusha Dathatri21ac59f2020-07-14 13:12:58 -050082Verify Network Settings From Server Configuration
83 [Documentation] Verify ability to select "Network Settings" sub-menu option
84 ... of "Server Configuration".
85 [Tags] Verify_Network_Settings_From_Server_Configuration
86
87 Page Should Contain IP address
88
89
90Verify Hostname Text Configuration
91 [Documentation] Verify hostname text is configurable from "network settings"
92 ... sub-menu.
93 [Tags] Verify_Hostname_Text_Configuration
94
Anves Kumar rayankula76c0a8a2020-11-17 03:36:32 -060095 Wait Until Element Is Enabled ${xpath_hostname_input}
Anusha Dathatri21ac59f2020-07-14 13:12:58 -050096 Input Text ${xpath_hostname_input} witherspoon1
97 Click Button ${xpath_network_save_settings}
98 Wait Until Page Contains Element ${xpath_setting_success} timeout=10
Anusha Dathatri21ac59f2020-07-14 13:12:58 -050099 Wait Until Keyword Succeeds 15 sec 5 sec Textfield Should Contain ${xpath_hostname_input}
100 ... witherspoon1
101
102
103Verify Default Gateway Editable
104 [Documentation] Verify default gateway text input allowed from "network
105 ... settings".
106 [Tags] Verify_Default_Gateway_Editable
Anves Kumar rayankula27603672021-01-21 04:26:08 -0600107 [Teardown] Click Element ${xpath_refresh_button}
Anusha Dathatri21ac59f2020-07-14 13:12:58 -0500108
109 Wait Until Page Contains Element ${xpath_default_gateway_input}
110 Input Text ${xpath_default_gateway_input} 10.6.6.7
111
112
113Verify MAC Address Editable
114 [Documentation] Verify MAC address text input allowed from "network
115 ... settings".
116 [Tags] Verify_MAC_Address_Editable
Anves Kumar rayankula27603672021-01-21 04:26:08 -0600117 [Teardown] Click Element ${xpath_refresh_button}
Anusha Dathatri21ac59f2020-07-14 13:12:58 -0500118
Anves Kumar rayankula27603672021-01-21 04:26:08 -0600119 Wait Until Element Is Enabled ${xpath_mac_address_input}
Anusha Dathatri21ac59f2020-07-14 13:12:58 -0500120 Input Text ${xpath_mac_address_input} AA:E2:84:14:28:79
121
122
123Verify Static IP Address Editable
124 [Documentation] Verify static IP address is editable.
125 [Tags] Verify_Static_IP_Address_Editable
Anves Kumar rayankula27603672021-01-21 04:26:08 -0600126 [Teardown] Click Element ${xpath_refresh_button}
Anusha Dathatri21ac59f2020-07-14 13:12:58 -0500127
128 ${exists}= Run Keyword And Return Status Wait Until Page Contains Element ${xpath_static_input_ip0}
129 Run Keyword If '${exists}' == '${False}'
130 ... Click Element ${xpath_add_static_ip}
131
132 Input Text ${xpath_static_input_ip0} ${OPENBMC_HOST}
133
134
Anves Kumar rayankula475811b2020-08-31 06:22:11 -0500135Verify System Section In Network Setting page
136 [Documentation] Verify hostname, MAC address and default gateway
Anves Kumar rayankulab172fbe2020-09-09 00:27:21 -0500137 ... under system section of network setting page.
Anves Kumar rayankula475811b2020-08-31 06:22:11 -0500138 [Tags] Verify_System_Section
139
Anves Kumar rayankulab172fbe2020-09-09 00:27:21 -0500140 ${host_name}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
Anves Kumar rayankulaba8a48e2020-10-05 06:18:09 -0500141 Textfield Value Should Be ${xpath_hostname_input} ${host_name}
Anves Kumar rayankula475811b2020-08-31 06:22:11 -0500142
143 ${mac_address}= Get BMC MAC Address
144 Textfield Value Should Be ${xpath_mac_address_input} ${mac_address}
145
146 ${default_gateway}= Get BMC Default Gateway
147 Textfield Value Should Be ${xpath_default_gateway_input} ${default_gateway}
148
149
Anves Kumar rayankula65e5ed22020-09-17 04:44:44 -0500150Verify Network Interface Details
151 [Documentation] Verify network interface name in network setting page.
152 [Tags] Verify_Network_Interface_Details
153
154 ${active_channel_config}= Get Active Channel Config
155 ${ethernet_interface_redfish}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
156 ${ethernet_interface_gui}= Get Text ${xpath_network_interface}
157 Should Contain ${ethernet_interface_gui} ${ethernet_interface_redfish}
158
159
160Verify Network Static IPv4 Details
161 [Documentation] Verify network static IPv4 details.
162 [Tags] Verify_Network_static_IPv4_Details
163
164 @{network_configurations}= Get Network Configuration
Anves Kumar rayankulad9b4df82021-05-09 09:07:46 -0500165 ${ip_addresses}= Get Static IPv4 Addresses From GUI
Anves Kumar rayankula65e5ed22020-09-17 04:44:44 -0500166 FOR ${network_configuration} IN @{network_configurations}
Anves Kumar rayankulad9b4df82021-05-09 09:07:46 -0500167 List Should Contain Value ${ip_addresses} ${network_configuration["Address"]}
Anves Kumar rayankula65e5ed22020-09-17 04:44:44 -0500168 END
169
170
Anves Kumar rayankula550eba92020-09-21 23:36:44 -0500171Configure Invalid Network Addresses And Verify
172 [Documentation] Configure invalid network addresses and verify.
173 [Tags] Configure_Invalid_Network_Addresses_And_Verify
174 [Template] Configure Invalid Network Address And Verify
175
176 # locator invalid_address
177 ${xpath_mac_address_input} A.A.A.A
178 ${xpath_default_gateway_input} a.b.c.d
179 ${xpath_static_input_ip0} a.b.c.d
180 ${xpath_input_netmask_addr0} 255.256.255.0
181
182
Anves Kumar rayankula43d8fe82020-12-08 21:21:38 -0600183Configure And Verify Empty Network Addresses
184 [Documentation] Configure and verify empty network addresses.
185 [Tags] Configure_And_Verify_Empty_Network_Addresses
186 [Template] Configure Invalid Network Address And Verify
187
188 # locator invalid_address expected_error
189 ${xpath_mac_address_input} ${empty} Field required
190 ${xpath_default_gateway_input} ${empty} Field required
191 ${xpath_static_input_ip0} ${empty} Field required
192 ${xpath_input_netmask_addr0} ${empty} Field required
193 ${xpath_hostname_input} ${empty} Field required
194
195
Anves Kumar rayankula4c884472020-11-24 05:03:45 -0600196Config And Verify DNS Server Via GUI
197 [Documentation] Configure DNS server and verify.
198 [Tags] Config_And_Verify_DNS_Server_Via_GUI
199 [Setup] DNS Test Setup Execution
200 [Teardown] Run Keywords Delete DNS Server And Verify ${static_name_servers}
201 ... AND DNS Test Teardown Execution
202
203 Add DNS Server And Verify ${static_name_servers}
204
205
206Delete And Verify DNS Server Via GUI
207 [Documentation] Delete DNS server and verify.
208 [Tags] Delete_And_Verify_DNS_Server_Via_GUI
209 [Setup] Run Keywords DNS Test Setup Execution AND
210 ... Add DNS Server And Verify ${static_name_servers}
211 [Teardown] DNS Test Teardown Execution
212
213 Delete DNS Server And Verify ${static_name_servers}
214
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600215Configure And Verify Static IP Address
216 [Documentation] Configure and verify static ip addresses.
217 [Setup] Test Setup Execution
218 [Tags] Configure_And_Verify_Static_IP_Address
219 [Teardown] Run Keywords Delete And Verify Static IP Address On BMC
220 ... AND Test Teardown Execution
221
222 Add Static IP Address And Verify ${test_ipv4_addr} ${test_subnet_mask}
223
Anves Kumar rayankula4c884472020-11-24 05:03:45 -0600224
Anves Kumar rayankula89266292020-12-28 01:29:23 -0600225Configure And Verify Invalid DNS Server
226 [Documentation] Configure invalid DNS server and verify error.
227 [Tags] Configure_And_Verify_Invalid_DNS_Server
228 [Template] Add DNS Server And Verify
229 [Setup] DNS Test Setup Execution
Anves Kumar rayankula27603672021-01-21 04:26:08 -0600230 [Teardown] Run Keywords Click Element ${xpath_refresh_button}
231 ... AND DNS Test Teardown Execution
Anves Kumar rayankula89266292020-12-28 01:29:23 -0600232
233 # invalid_ address expected_status
234 ${string_value} Invalid format
235 ${special_char_value} Invalid format
236 ${empty_dictionary} Field required
237 ${null_value} Invalid format
238
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600239Modify IP Address And Verify
240 [Documentation] Modify IP address and verify.
241 [Setup] Test Setup Execution
242 [Tags] Modify_IP_Address_And_Verify
243 [Teardown] Run Keywords Delete And Verify Static IP Address On BMC
244 ... AND Test Teardown Execution
245
Anves Kumar rayankula14a8c982021-05-25 07:31:53 -0500246 Add Static IP Address And Verify ${test_ipv4_addr} ${test_subnet_mask}
247 Update IP Address And Verify ${test_ipv4_addr} ${test_ipv4_addr2}
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600248
249
250Configure Netmask And Verify
251 [Documentation] Configure and verify netmask.
252 [Tags] Configure_And_Verify_Netmask
253 [Setup] Test Setup Execution
254 [Template] Add Static IP Address And Verify
255 [Teardown] Run Keywords Click Element ${xpath_refresh_button}
256 ... AND Delete And Verify Static IP Address On BMC
257 ... AND Test Teardown Execution
258
259 # ip_addresses subnet_masks expected_status
260 ${test_ipv4_addr} ${lowest_netmask} Valid format
261 ${test_ipv4_addr} ${more_byte_netmask} Invalid format
262 ${test_ipv4_addr} ${alpha_netmask} Invalid format
263 ${test_ipv4_addr} ${out_of_range_netmask} Invalid format
Anves Kumar rayankula89266292020-12-28 01:29:23 -0600264
Anusha Dathatri21ac59f2020-07-14 13:12:58 -0500265*** Keywords ***
266
267Suite Setup Execution
268 [Documentation] Do test case setup tasks.
269
270 Launch Browser And Login GUI
271 Click Element ${xpath_server_configuration}
272 Click Element ${xpath_select_network_settings}
273 Wait Until Keyword Succeeds 30 sec 10 sec Location Should Contain network-settings
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600274 ${host_name} ${BMC_IP}= Get Host Name IP host=${OPENBMC_HOST}
275 Set Suite Variable ${BMC_IP}
Anusha Dathatri21ac59f2020-07-14 13:12:58 -0500276
Anves Kumar rayankula550eba92020-09-21 23:36:44 -0500277
Anves Kumar rayankula550eba92020-09-21 23:36:44 -0500278Configure Invalid Network Address And Verify
279 [Documentation] Configure invalid network address And verify.
Anves Kumar rayankula43d8fe82020-12-08 21:21:38 -0600280 [Arguments] ${locator} ${invalid_address} ${expected_error}=Invalid format
Anves Kumar rayankula27603672021-01-21 04:26:08 -0600281 [Teardown] Click Element ${xpath_refresh_button}
Anves Kumar rayankula550eba92020-09-21 23:36:44 -0500282
283 # Description of the argument(s):
284 # locator Xpath to identify an HTML element on a web page.
285 # invalid_address Invalid address to be added.
Anves Kumar rayankula43d8fe82020-12-08 21:21:38 -0600286 # expected_error Expected error optionally provided in testcase
287 # .... (e.g. Invalid format / Field required)
Anves Kumar rayankula550eba92020-09-21 23:36:44 -0500288
Anves Kumar rayankula43d8fe82020-12-08 21:21:38 -0600289 Wait Until Element Is Enabled ${locator}
290 Clear Element Text ${locator}
Anves Kumar rayankula550eba92020-09-21 23:36:44 -0500291 Input Text ${locator} ${invalid_address}
Anves Kumar rayankula55481152020-10-21 07:51:07 -0500292 Click Element ${xpath_network_save_settings}
Anves Kumar rayankula43d8fe82020-12-08 21:21:38 -0600293 Page Should Contain ${expected_error}
Anves Kumar rayankula550eba92020-09-21 23:36:44 -0500294
Anves Kumar rayankula4c884472020-11-24 05:03:45 -0600295
296Add DNS Server And Verify
297 [Documentation] Add DNS server on BMC and verify it via BMC CLI.
Anves Kumar rayankula27603672021-01-21 04:26:08 -0600298 [Arguments] ${static_name_servers} ${expected_status}=Valid format
Anves Kumar rayankula4c884472020-11-24 05:03:45 -0600299
300 # Description of the argument(s):
301 # static_name_servers A list of static name server IPs to be
302 # configured on the BMC.
Anves Kumar rayankula89266292020-12-28 01:29:23 -0600303 # expected_status Expected status while adding DNS server address
304 # ... (e.g. Invalid format / Field required).
Anves Kumar rayankula4c884472020-11-24 05:03:45 -0600305
306 Wait Until Page Contains Element ${xpath_add_dns_server}
307 ${length}= Get Length ${static_name_servers}
308 FOR ${i} IN RANGE ${length}
309 Click Button ${xpath_add_dns_server}
310 Input Text //*[@data-test-id="networkSettings-input-dnsAddress-${i}"]
311 ... ${static_name_servers}[${i}]
312 END
313
314 Click Button ${xpath_network_save_settings}
Anves Kumar rayankula89266292020-12-28 01:29:23 -0600315 Run keyword if '${expected_status}' != 'Valid format'
316 ... Run keywords Page Should Contain ${expected_status} AND Return From Keyword
Anves Kumar rayankula4c884472020-11-24 05:03:45 -0600317
Anves Kumar rayankula89266292020-12-28 01:29:23 -0600318 Wait Until Page Contains Element ${xpath_setting_success} timeout=15
Anves Kumar rayankula4c884472020-11-24 05:03:45 -0600319 Sleep ${NETWORK_TIMEOUT}s
320 Verify Static Name Server Details On GUI ${static_name_servers}
321 # Check if newly added DNS server is configured on BMC.
322 ${cli_name_servers}= CLI Get Nameservers
323 List Should Contain Sub List ${cli_name_servers} ${static_name_servers}
324
325
326Delete DNS Server And Verify
327 [Documentation] Delete static name servers.
328 [Arguments] ${static_name_servers}
329
330 # Description of the argument(s):
331 # static_name_servers A list of static name server IPs to be
332 # configured on the BMC.
333
334 ${length}= Get Length ${static_name_servers}
335 FOR ${i} IN RANGE ${length}
336 ${status}= Run Keyword And Return Status
337 ... Page Should Contain Element ${xpath_delete_dns_server}
338 Exit For Loop If "${status}" == "False"
339 Wait Until Element Is Enabled ${xpath_delete_dns_server}
340 Click Button ${xpath_delete_dns_server}
341 END
342
343 Click Button ${xpath_network_save_settings}
344 Wait Until Page Contains Element ${xpath_setting_success} timeout=15
345
346 Sleep ${NETWORK_TIMEOUT}s
347 Page Should Not Contain Element ${xpath_input_dns_server}
348 # Check if all name servers deleted on BMC.
349 ${nameservers}= CLI Get Nameservers
350 Should Be Empty ${nameservers}
351
352
353DNS Test Setup Execution
354 [Documentation] Do DNS test setup execution.
355
356 ${original_name_server}= CLI Get Nameservers
357 Set Suite Variable ${original_name_server}
358 Run Keyword If ${original_name_server} != @{EMPTY}
359 ... Delete DNS Server And Verify ${original_name_server}
360
361
362DNS Test Teardown Execution
363 [Documentation] Do DNS test teardown execution.
364
365 Run Keyword If ${original_name_server} != @{EMPTY}
366 ... Add DNS Server And Verify ${original_name_server}
367
368
369Verify Static Name Server Details On GUI
370 [Documentation] Verify static name servers on GUI.
371 [Arguments] ${static_name_servers}
372
373 # Description of the argument(s):
374 # static_name_servers A list of static name server IPs to be
375 # configured on the BMC.
376
377 ${length}= Get Length ${static_name_servers}
378 FOR ${i} IN RANGE ${length}
379 Page Should Contain Element //*[@data-test-id="networkSettings-input-dnsAddress-${i}"]
380 Textfield Value Should Be //*[@data-test-id="networkSettings-input-dnsAddress-${i}"]
381 ... ${static_name_servers}[${i}]
382 END
383
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600384Add Static IP Address And Verify
385 [Documentation] Add static IP on BMC and verify.
Anves Kumar rayankulab2f73772021-05-11 04:58:25 -0500386 [Arguments] ${ip_address} ${subnet_mask} ${expected_status}=Valid format
Anves Kumar rayankula89266292020-12-28 01:29:23 -0600387
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600388 # Description of argument(s):
Anves Kumar rayankulab2f73772021-05-11 04:58:25 -0500389 # ip_address IP address to be added (e.g. 10.7.7.7).
390 # subnet_masks Subnet mask for the IP to be added (e.g. 255.255.0.0).
391 # expected_status Expected status while adding static ipv4 address
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600392 # .... (e.g. Invalid format / Field required).
393
Anves Kumar rayankulab2f73772021-05-11 04:58:25 -0500394 ${available_ip_addresses}= Get Static IPv4 Addresses From GUI
395
396 # New IP address location is GUI is equivalent to the available IP address
397 # in Redfish. i.e. if two IP address are available in GUI then location
398 # on IP address in GUI is also 2.
399 ${location}= Get Length ${available_ip_addresses}
400 Wait Until Element Is Enabled ${xpath_add_static_ip}
401 Click Button ${xpath_add_static_ip}
402
403 Input Text
404 ... //*[@data-test-id="networkSettings-input-staticIpv4-${location}"] ${ip_address}
405 Input Text
406 ... //*[@data-test-id="networkSettings-input-subnetMask-${location}"] ${subnet_mask}
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600407
408 Click Button ${xpath_network_save_settings}
409 Run keyword if '${expected_status}' != 'Valid format'
410 ... Run keywords Page Should Contain ${expected_status} AND Return From Keyword
411 Wait Until Page Contains Element ${xpath_setting_success} timeout=15
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600412 Click Element ${xpath_refresh_button}
Anves Kumar rayankulab2f73772021-05-11 04:58:25 -0500413 Wait Until Page Contains Element ${xpath_static_input_ip0}
414 Validate Network Config On BMC
415 ${ip_addresses}= Get Static IPv4 Addresses From GUI
416 Should Contain ${ip_addresses} ${ip_address}
417
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600418
419Delete And Verify Static IP Address On BMC
420 [Documentation] Delete static IP address and verify
421
422 ${all_match_elements}= Get Element Count ${xpath_delete_static_ip}
423 FOR ${element} IN RANGE ${all_match_elements}
424 ${ip_location}= Evaluate ${element} + ${1}
425 Delete Static IPv4 Addresses Except BMC IP ${element}
426 ${status}= Run Keyword And Return Status Page Should Contain Textfield
427 ... //*[@data-test-id="networkSettings-input-staticIpv4-${ip_location}"]
428 Exit For Loop IF "${status}" == "${False}"
429 END
430
431 Click Button ${xpath_network_save_settings}
432 Wait Until Page Contains Element ${xpath_setting_success} timeout=15
433 ${all_match_elements}= Get Element Count ${xpath_delete_static_ip}
434 Should Be Equal ${all_match_elements} ${1}
435 Textfield Value Should Be ${xpath_static_input_ip0} ${BMC_IP}
436 Sleep ${NETWORK_TIMEOUT}s
437 Ping Host ${OPENBMC_HOST}
438 Validate Network Config On BMC
439
440Delete Static IPv4 Addresses Except BMC IP
441 [Documentation] Delete static IP addresses from IPv4 section on GUI except BMC IP.
442 [Arguments] ${element}
443
444 # Description of argument(s):
445 # element IP address location on GUI(e.g. 0 or 1).
446
447 ${ip_location}= Evaluate ${element} + ${1}
448 Wait Until Element Is Enabled //*[@data-test-id="networkSettings-input-staticIpv4-${element}"]
449 ${input_ip}= Get Value //*[@data-test-id="networkSettings-input-staticIpv4-${element}"]
450 Run Keyword If "${BMC_IP}" != "${input_ip}"
451 ... Click Button ${xpath_ip_table}/tbody/tr[${ip_location}]/td[3]/span/button
452
453 # Get delete ip elements.
454 ${delete_ip_elements}= Get Element Count ${xpath_delete_static_ip}
455
George Keishinga53c3412021-04-06 11:09:42 -0500456 # Delete IP Address on BMC if available more than 1.
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600457 Run Keyword If ${delete_ip_elements} != ${1}
458 ... Delete Static IPv4 Addresses Except BMC IP ${element}
459
460Test Setup Execution
461 [Documentation] Get and delete existing IPv4 addresses and netmask if any..
462
463 ${ip_data}= Create List
464 ${netmask_data}= Create List
465
466 # Get all IPv4 addresses and netmask on BMC.
467 ${network_configurations}= Get Network Configuration
468 FOR ${network_configuration} IN @{network_configurations}
469 Continue For Loop If '${BMC_IP}' == '${network_configuration['Address']}'
470 Append To List ${ip_data} ${network_configuration['Address']}
471 Append To List ${netmask_data} ${network_configuration['SubnetMask']}
472 END
473 Set Suite Variable ${ip_data}
474 Set Suite Variable ${netmask_data}
475
George Keishinga53c3412021-04-06 11:09:42 -0500476 # Delete existing static IPv4 addresses and netmask if available.
anvesr77dd83e252021-03-08 22:17:51 -0600477 Run Keyword If ${ip_data} != @{empty} and ${netmask_data} != @{empty}
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600478 ... Delete And Verify Static IP Address On BMC
479
480
481Test Teardown Execution
482 [Documentation] Restore existing IPv4 addresses and netmasks.
483
484 ${ip_length}= Get Length ${ip_data}
485 ${netmask_length}= Get Length ${netmask_data}
486
487 # Restore existing IPv4 addresses and netmasks if any..
anvesr77dd83e252021-03-08 22:17:51 -0600488 Run Keyword If ${ip_length} != ${0} and ${netmask_length} != ${0}
Anves Kumar rayankulada394342021-01-17 23:51:16 -0600489 ... Add Static IP Address And Verify ${ip_data} ${netmask_data}
490
491
492Verify IP And Netmask On BMC Using GUI
493 [Documentation] Verify IP and netmask on GUI.
494 [Arguments] ${ip_addresses} ${subnet_masks}
495
496 # Description of argument(s):
497 # ip_addresses A list of IP address to be added (e.g. ["10.7.7.7"]).
498 # subnet_masks A list of Subnet mask for the IP to be added (e.g. ["255.255.0.0]").
499
500 ${ip_count}= Get Length ${ip_addresses}
501 FOR ${i} IN RANGE ${ip_count}
502 ${input_ip}= Get Value //*[@data-test-id="networkSettings-input-staticIpv4-${i}"]
503 Continue For Loop If '${BMC_IP}' == '${input_ip}'
504 Textfield Value Should Be //*[@data-test-id="networkSettings-input-staticIpv4-${i}"]
505 ... ${ip_addresses}[${i}]
506 Textfield Value Should Be //*[@data-test-id="networkSettings-input-subnetMask-${i}"]
507 ... ${subnet_masks}[${i}]
508 END
509 Validate Network Config On BMC
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600510
511
512Update IP Address And Verify
Anves Kumar rayankula14a8c982021-05-25 07:31:53 -0500513 [Documentation] Update and verify static IP address on BMC.
514 [Arguments] ${ip} ${new_ip}
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600515
516 # Description of argument(s):
517 # ip IP address to be replaced (e.g. "10.7.7.7").
518 # new_ip New IP address to be configured.
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600519
Anves Kumar rayankula14a8c982021-05-25 07:31:53 -0500520 ${ip_addresses}= Get Static IPv4 Addresses From GUI
521 Should Contain ${ip_addresses} ${ip} msg=${ip} does not exist on BMC
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600522
Anves Kumar rayankula14a8c982021-05-25 07:31:53 -0500523 FOR ${location} IN RANGE len(${ip_addresses})
524 ${gui_ip}= Get Value //*[@data-test-id="networkSettings-input-staticIpv4-${location}"]
525 Run Keyword If '${gui_ip}' == '${ip}'
526 ... Run Keywords
527 ... Clear Element Text //*[@data-test-id="networkSettings-input-staticIpv4-${location}"]
528 ... AND Input Text
529 ... //*[@data-test-id="networkSettings-input-staticIpv4-${location}"] ${new_ip}
530 ... AND Exit For Loop
531 END
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600532 Click Button ${xpath_network_save_settings}
533 Wait Until Page Contains Element ${xpath_setting_success} timeout=15
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600534 Click Element ${xpath_refresh_button}
Anves Kumar rayankula14a8c982021-05-25 07:31:53 -0500535 Wait Until Page Contains Element ${xpath_static_input_ip0}
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600536 Validate Network Config On BMC
Anves Kumar rayankula14a8c982021-05-25 07:31:53 -0500537 ${ip_addresses}= Get Static IPv4 Addresses From GUI
538 Should Contain ${ip_addresses} ${new_ip}
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600539
540
Anves Kumar rayankulaef4d34f2021-02-12 03:26:42 -0600541Verfiy IP On BMC
542 [Documentation] Verify only one static IPv4 address.
543 [Arguments] ${ip} ${subnet_mask}
544
545 # Description of argument(s):
546 # ip IP address which needs to be verified (e.g. "10.7.7.7").
547 # subnet_mask Netmask value which needs to be verified.(e.g. "255.255.0.0").
548
549 ${get_ip}= Get Value ${xpath_static_input_ip0}
550 ${get_netmask}= Get Value ${xpath_input_netmask_addr0}
551 Should Be Equal ${get_ip} ${ip}
552 Should Be Equal ${get_netmask} ${subnet_mask}
Anves Kumar rayankulad9b4df82021-05-09 09:07:46 -0500553
554
555Get Static IPv4 Addresses From GUI
556 [Documentation] Get static IPV4 addresses from GUI.
557
558 ${availble_ip_addresses}= Get Network Configuration
559 ${static_ipv4_addresses}= Create List
560
561 FOR ${locator} IN RANGE len(${availble_ip_addresses})
562 ${ip_address}= Get value //*[@data-test-id="networkSettings-input-staticIpv4-${locator}"]
563 Append To List ${static_ipv4_addresses} ${ip_address}
564 END
565
566 [Return] ${static_ipv4_addresses}