Added GUI testcase to config and verify static IP on BMC
Change-Id: I7a0106781273da96790630ef3f6ffbcf4d64a9ef
Signed-off-by: Anves Kumar rayankula <anvesr77@in.ibm.com>
diff --git a/gui/gui_test/server_config/test_obmc_gui_network_settings.robot b/gui/gui_test/server_config/test_obmc_gui_network_settings.robot
index 74f7f6b..2872595 100644
--- a/gui/gui_test/server_config/test_obmc_gui_network_settings.robot
+++ b/gui/gui_test/server_config/test_obmc_gui_network_settings.robot
@@ -29,6 +29,7 @@
${xpath_delete_static_ip} //*[@title="Delete IPv4 row"]
${xpath_input_dns_server} //*[@data-test-id="networkSettings-input-dnsAddress-0"]
${xpath_delete_dns_server} //*[@title="Delete DNS row"]
+${xpath_ip_table} //*[@aria-colcount="3"]
@{static_name_servers} 10.10.10.10
@{null_value} null
@@ -36,6 +37,9 @@
@{string_value} aa.bb.cc.dd
@{special_char_value} @@@.%%.44.11
+@{test_ipv4_addr} 10.7.7.7
+@{test_subnet_mask} 255.255.0.0
+
*** Test Cases ***
Verify Navigation To Network Settings Page
@@ -197,6 +201,15 @@
Delete DNS Server And Verify ${static_name_servers}
+Configure And Verify Static IP Address
+ [Documentation] Configure and verify static ip addresses.
+ [Setup] Test Setup Execution
+ [Tags] Configure_And_Verify_Static_IP_Address
+ [Teardown] Run Keywords Delete And Verify Static IP Address On BMC
+ ... AND Test Teardown Execution
+
+ Add Static IP Address And Verify ${test_ipv4_addr} ${test_subnet_mask}
+
Configure And Verify Invalid DNS Server
[Documentation] Configure invalid DNS server and verify error.
@@ -222,6 +235,8 @@
Click Element ${xpath_server_configuration}
Click Element ${xpath_select_network_settings}
Wait Until Keyword Succeeds 30 sec 10 sec Location Should Contain network-settings
+ ${host_name} ${BMC_IP}= Get Host Name IP host=${OPENBMC_HOST}
+ Set Suite Variable ${BMC_IP}
Configure Invalid Network Address And Verify
@@ -330,4 +345,123 @@
... ${static_name_servers}[${i}]
END
+Add Static IP Address And Verify
+ [Documentation] Add static IP on BMC and verify.
+ [Arguments] ${ip_addresses} ${subnet_masks} ${expected_status}=Valid format
+ # Description of argument(s):
+ # ip_addresses A list of IP address to be added (e.g. ["10.7.7.7"]).
+ # subnet_masks A list of Subnet mask for the IP to be added (e.g. ["255.255.0.0"]).
+ # expected_status Expected status while adding static ipv4 address
+ # .... (e.g. Invalid format / Field required).
+
+ ${ip_count}= Get Length ${ip_addresses}
+ FOR ${i} IN RANGE ${ip_count}
+ ${ip_location}= Evaluate ${i} + ${1}
+ Wait Until Element Is Enabled ${xpath_add_static_ip}
+ Click Button ${xpath_add_static_ip}
+ Wait Until Element Is Enabled //*[@data-test-id="networkSettings-input-staticIpv4-${ip_location}"]
+ Wait Until Element Is Enabled //*[@data-test-id="networkSettings-input-subnetMask-${ip_location}"]
+ Input Text //*[@data-test-id="networkSettings-input-staticIpv4-${ip_location}"] ${ip_addresses}[${i}]
+ Input Text //*[@data-test-id="networkSettings-input-subnetMask-${ip_location}"] ${subnet_masks}[${i}]
+ END
+
+ Click Button ${xpath_network_save_settings}
+ Run keyword if '${expected_status}' != 'Valid format'
+ ... Run keywords Page Should Contain ${expected_status} AND Return From Keyword
+ Wait Until Page Contains Element ${xpath_setting_success} timeout=15
+ Sleep ${NETWORK_TIMEOUT}s
+ Click Element ${xpath_refresh_button}
+ Verify IP And Netmask On BMC Using GUI ${ip_addresses} ${subnet_masks}
+
+Delete And Verify Static IP Address On BMC
+ [Documentation] Delete static IP address and verify
+
+ ${all_match_elements}= Get Element Count ${xpath_delete_static_ip}
+ FOR ${element} IN RANGE ${all_match_elements}
+ ${ip_location}= Evaluate ${element} + ${1}
+ Delete Static IPv4 Addresses Except BMC IP ${element}
+ ${status}= Run Keyword And Return Status Page Should Contain Textfield
+ ... //*[@data-test-id="networkSettings-input-staticIpv4-${ip_location}"]
+ Exit For Loop IF "${status}" == "${False}"
+ END
+
+ Click Button ${xpath_network_save_settings}
+ Wait Until Page Contains Element ${xpath_setting_success} timeout=15
+ ${all_match_elements}= Get Element Count ${xpath_delete_static_ip}
+ Should Be Equal ${all_match_elements} ${1}
+ Textfield Value Should Be ${xpath_static_input_ip0} ${BMC_IP}
+ Sleep ${NETWORK_TIMEOUT}s
+ Ping Host ${OPENBMC_HOST}
+ Validate Network Config On BMC
+
+Delete Static IPv4 Addresses Except BMC IP
+ [Documentation] Delete static IP addresses from IPv4 section on GUI except BMC IP.
+ [Arguments] ${element}
+
+ # Description of argument(s):
+ # element IP address location on GUI(e.g. 0 or 1).
+
+ ${ip_location}= Evaluate ${element} + ${1}
+ Wait Until Element Is Enabled //*[@data-test-id="networkSettings-input-staticIpv4-${element}"]
+ ${input_ip}= Get Value //*[@data-test-id="networkSettings-input-staticIpv4-${element}"]
+ Run Keyword If "${BMC_IP}" != "${input_ip}"
+ ... Click Button ${xpath_ip_table}/tbody/tr[${ip_location}]/td[3]/span/button
+
+ # Get delete ip elements.
+ ${delete_ip_elements}= Get Element Count ${xpath_delete_static_ip}
+
+ # Delete IP Address on BMC if avilable more than 1.
+ Run Keyword If ${delete_ip_elements} != ${1}
+ ... Delete Static IPv4 Addresses Except BMC IP ${element}
+
+Test Setup Execution
+ [Documentation] Get and delete existing IPv4 addresses and netmask if any..
+
+ ${ip_data}= Create List
+ ${netmask_data}= Create List
+
+ # Get all IPv4 addresses and netmask on BMC.
+ ${network_configurations}= Get Network Configuration
+ FOR ${network_configuration} IN @{network_configurations}
+ Continue For Loop If '${BMC_IP}' == '${network_configuration['Address']}'
+ Append To List ${ip_data} ${network_configuration['Address']}
+ Append To List ${netmask_data} ${network_configuration['SubnetMask']}
+ END
+ Set Suite Variable ${ip_data}
+ Set Suite Variable ${netmask_data}
+
+ # Delete existing static IPv4 addresses and netmask if avilable.
+ Run keyword if ${ip_data} == @{empty} and ${netmask_data} == @{empty}
+ ... Delete And Verify Static IP Address On BMC
+
+
+Test Teardown Execution
+ [Documentation] Restore existing IPv4 addresses and netmasks.
+
+ ${ip_length}= Get Length ${ip_data}
+ ${netmask_length}= Get Length ${netmask_data}
+
+ # Restore existing IPv4 addresses and netmasks if any..
+ Run keyword If ${ip_length} == ${0} and ${netmask_length} == ${0}
+ ... Add Static IP Address And Verify ${ip_data} ${netmask_data}
+
+
+Verify IP And Netmask On BMC Using GUI
+ [Documentation] Verify IP and netmask on GUI.
+ [Arguments] ${ip_addresses} ${subnet_masks}
+
+ # Description of argument(s):
+ # ip_addresses A list of IP address to be added (e.g. ["10.7.7.7"]).
+ # subnet_masks A list of Subnet mask for the IP to be added (e.g. ["255.255.0.0]").
+
+ ${ip_count}= Get Length ${ip_addresses}
+ FOR ${i} IN RANGE ${ip_count}
+ ${input_ip}= Get Value //*[@data-test-id="networkSettings-input-staticIpv4-${i}"]
+ Continue For Loop If '${BMC_IP}' == '${input_ip}'
+ Textfield Value Should Be //*[@data-test-id="networkSettings-input-staticIpv4-${i}"]
+ ... ${ip_addresses}[${i}]
+ Textfield Value Should Be //*[@data-test-id="networkSettings-input-subnetMask-${i}"]
+ ... ${subnet_masks}[${i}]
+ END
+ Validate Network Config On BMC