1*** Settings *** 2Documentation This is a resource file containing user-defined keywords for new Vue based OpenBMC GUI. 3 4Library XvfbRobot 5Library SeleniumLibrary 6Library SSHLibrary 30 Seconds 7Resource ../../lib/state_manager.robot 8Variables ../data/gui_variables.py 9 10 11*** Variables *** 12${OPENBMC_GUI_URL} https://${OPENBMC_HOST}:${HTTPS_PORT} 13${xpath_power_page} //*[@data-test-id='appHeader-container-power'] 14${xpath_power_shutdown} //*[@data-test-id='serverPowerOperations-button-shutDown'] 15${xpath_power_power_on} //*[@data-test-id='serverPowerOperations-button-powerOn'] 16${xpath_power_reboot} //*[@data-test-id='serverPowerOperations-button-reboot'] 17${xpath_confirm} //button[contains(text(),'Confirm')] 18 19# Default GUI browser and mode is set to "Firefox" and "headless" 20# respectively here. 21${GUI_BROWSER} ff 22${GUI_MODE} headless 23 24 25*** Keywords *** 26 27Open Browser With URL 28 [Documentation] Open browser with specified URL and returns browser id. 29 [Arguments] ${URL} ${browser}=ff ${mode}=${GUI_MODE} 30 31 # Description of argument(s): 32 # URL Openbmc GUI URL to be open 33 # (e.g. https://openbmc-test.mybluemix.net/#/login). 34 # browser Browser used to open above URL 35 # (e.g. gc for google chrome, ff for firefox). 36 # mode Browser opening mode(e.g. headless, header). 37 38 IF '${mode}' == 'headless' 39 ${browser_ID}= Launch Headless Browser ${URL} ${browser} 40 ELSE 41 ${browser_ID}= Open Browser ${URL} ${browser} 42 END 43 RETURN ${browser_ID} 44 45 46Launch Header Browser 47 [Documentation] Open the browser with the URL and 48 ... login on windows platform. 49 [Arguments] ${browser_type}=${GUI_BROWSER} 50 51 # Description of argument(s): 52 # browser_type Type of browser (e.g. "firefox", "chrome", etc.). 53 54 ${BROWSER_ID}= Open Browser ${OPENBMC_GUI_URL} ${browser_type} 55 Maximize Browser Window 56 Set Global Variable ${BROWSER_ID} 57 58 59Launch Headless Browser 60 [Documentation] Launch headless browser. 61 [Arguments] ${URL}=${OPENBMC_GUI_URL} ${browser}=${GUI_BROWSER} 62 63 # Description of argument(s): 64 # URL Openbmc GUI URL to be open 65 # (e.g. https://openbmc-test.mybluemix.net/#/login). 66 # browser Browser to open given URL in headless way 67 # (e.g. gc for google chrome, ff for firefox). 68 69 Start Virtual Display 70 ${browser_ID}= Open Browser ${URL} ${browser} 71 Set Window Size 1920 1080 72 73 RETURN ${browser_ID} 74 75 76Launch Browser And Login GUI 77 [Documentation] Launch browser and login to OpenBMC GUI, retry 2 attempts 78 ... in 1 minute time. 79 80 Wait Until Keyword Succeeds 195 sec 65 sec Retry Browser Login Attempts 81 82 83Retry Browser Login Attempts 84 [Documentation] Launch browser and login to OpenBMC GUI. 85 86 Open Browser With URL ${OPENBMC_GUI_URL} 87 Login GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 88 89 90Login GUI 91 [Documentation] Login to OpenBMC GUI. 92 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD} 93 94 # Description of argument(s): 95 # username The username to be used for login. 96 # password The password to be used for login. 97 98 Go To ${OPENBMC_GUI_URL} 99 Wait Until Element Is Enabled ${xpath_login_username_input} 100 Input Text ${xpath_login_username_input} ${username} 101 Input Password ${xpath_login_password_input} ${password} 102 Wait Until Element Is Enabled ${xpath_login_button} 103 Click Element ${xpath_login_button} 104 Wait Until Page Contains Operations timeout=60s 105 Wait Until Element Is Not Visible 106 ... ${xpath_page_loading_progress_bar} timeout=120s 107 108 109Launch Browser And Login GUI With Given User 110 [Documentation] Launch browser and login eBMC with specified user 111 ... credentials through GUI. 112 [Arguments] ${user_name} ${user_password} 113 114 # Description of argument(s): 115 # user_name User name to login to eBMC. 116 # user_password User password to login to eBMC. 117 118 Open Browser With URL ${OPENBMC_GUI_URL} 119 LOGIN GUI ${user_name} ${user_password} 120 121 122Logout GUI 123 [Documentation] Logout of OpenBMC GUI. 124 125 Click Element ${xpath_root_button_menu} 126 Click Element ${xpath_logout_button} 127 Wait Until Page Contains Element ${xpath_login_button} 128 129 130Generate Test Error Log 131 [Documentation] Generate test error log. 132 133 BMC Execute Command ${CMD_UNRECOVERABLE_ERROR} 134 135 136Set Timezone In Profile Settings Page 137 [Documentation] Set the given timezone in profile settings page. 138 [Arguments] ${timezone}=Default 139 140 # Description of argument(s): 141 # timezone Timezone to select (eg. Default or Browser_offset). 142 143 Wait Until Page Contains Element ${xpath_root_button_menu} 144 Click Element ${xpath_root_button_menu} 145 Click Element ${xpath_profile_settings} 146 Click Element At Coordinates ${xpath_default_UTC} 0 0 147 Click Element ${xpath_profile_save_button} 148 149 150Refresh GUI 151 [Documentation] Refresh GUI via refresh button in header. 152 153 Click Element ${xpath_refresh_button} 154 # Waiting for page to load fully after refresh. 155 Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=120s 156 157 158Refresh GUI And Verify Element Value 159 [Documentation] Refresh GUI using refresh button and verify that given element contains expected value. 160 [Arguments] ${element} ${expected_value} 161 162 # Description of argument(s): 163 # element Element whose value need to be checked. 164 # expected_value Expected value of for the given element. 165 166 # Refresh GUI. 167 Refresh GUI 168 169 # Check element value and verify that it contains expected value. 170 ${element_value}= Get Text ${element} 171 Log ${element_value} 172 Should Contain ${element_value} ${expected_value} 173 174 175Reboot BMC via GUI 176 [Documentation] Reboot BMC via GUI. 177 178 Click Element ${xpath_operations_menu} 179 Click Element ${xpath_reboot_bmc_sub_menu} 180 Click Button ${xpath_reboot_bmc_button} 181 Wait Until Keyword Succeeds 30 sec 10 sec Click Button ${xpath_confirm_bmc_reboot} 182 Wait Until Keyword Succeeds 2 min 10 sec Is BMC Unpingable 183 Wait For Host To Ping ${OPENBMC_HOST} 1 min 184 185 186Add DNS Servers And Verify 187 [Documentation] Login to GUI Network page,add DNS server on BMC 188 ... and verify it via BMC CLI. 189 [Arguments] ${dns_server} ${expected_status}=Valid format 190 191 # Description of the argument(s): 192 # dns_server A list of static name server IPs to be 193 # configured on the BMC. 194 # expected_status Expected status while adding DNS server address 195 # (e.g. Invalid format / Field required). 196 197 Wait Until Page Contains Element ${xpath_add_dns_ip_address_button} timeout=15sec 198 199 Click Button ${xpath_add_dns_ip_address_button} 200 Input Text ${xpath_input_static_dns} ${dns_server} 201 Click Button ${xpath_add_button} 202 IF '${expected_status}' != 'Valid format' 203 Page Should Contain ${expected_status} 204 Return From Keyword 205 END 206 207 Wait Until Page Contains Element ${xpath_add_dns_ip_address_button} timeout=10sec 208 Wait Until Page Contains ${dns_server} timeout=40sec 209 210 # Check if newly added DNS server is configured on BMC. 211 ${cli_name_servers}= CLI Get Nameservers 212 ${cmd_status}= Run Keyword And Return Status 213 ... List Should Contain Sub List ${cli_name_servers} ${dns_server} 214 IF '${expected_status}' == '${HTTP_OK}' 215 Should Be True ${cmd_status} == ${True} 216 ELSE 217 Should Not Be True ${cmd_status} 218 END 219 220 221Navigate To Server Power Page 222 [Documentation] Navigate To Server Power Page. 223 224 Click Element ${xpath_power_page} 225 Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=30s 226 227 228Power Off Server 229 [Documentation] Powering off server. 230 231 ${boot_state} ${host_state}= Redfish Get Boot Progress 232 IF '${host_state}' == 'Disabled' 233 Log To Console Server is already powered Off. 234 ELSE 235 Navigate To Server Power Page 236 Wait And Click Element ${xpath_power_shutdown} 237 Click Button ${xpath_confirm} 238 Wait Until Element Is Visible ${xpath_power_poweron} timeout=60 239 Verify And Close Information Message Via GUI 240 Wait Until Keyword Succeeds 5m 30s Check Boot Progress State Via Redfish None Disabled 241 END 242 243 244Power On Server 245 [Documentation] Powering on server. 246 247 ${boot_state} ${host_state}= Redfish Get Boot Progress 248 Log To Console Current boot state: ${boot_state} 249 250 IF '${boot_state}' == 'OSRunning' 251 Log To Console Server is already powered on. 252 ELSE 253 Navigate To Server Power Page 254 IF '${boot_state}' != 'None' 255 Power Off Server 256 END 257 Set BIOS Attribute pvm_stop_at_standby Disabled 258 Wait And Click Element ${xpath_power_power_on} 259 Wait Until Element Is Visible ${xpath_power_shutdown} timeout=60s 260 Verify And Close Information Message Via GUI 261 Wait Until Keyword Succeeds 15m 45s Check Boot Progress State Via Redfish OSRunning Enabled 262 END 263 264 265Check Boot Progress State Via Redfish 266 [Documentation] Checking boot progress state via redfish. 267 [Arguments] ${expected_boot_state} ${expected_host_state} 268 269 # Description of argument(s): 270 # expected_boot_state Expected Boot states are "OSRunning" and "None". 271 # expected_host_state Expected Host states are "Enabled" and "Disabled" 272 273 ${boot_state} ${host_state}= Redfish Get Boot Progress 274 Log To Console Current boot state: ${boot_state}, host state: ${host_state} 275 276 Should Be Equal As Strings ${boot_state} ${expected_boot_state} 277 ... msg=Boot state mismatch: expected '${expected_boot_state}', got '${boot_state}' 278 Should Be Equal As Strings ${host_state} ${expected_host_state} 279 ... msg=Host state mismatch: expected '${expected_host_state}', got '${host_state}' 280 281 282Verify And Close Information Message Via GUI 283 [Documentation] Verify and close Information message via GUI page. 284 285 Wait Until Element Is Visible ${xpath_close_information_message} timeout=5s 286 Page Should Contain Element ${xpath_information_message} 287 Click Element ${xpath_close_information_message} 288 289 290Reboot Server 291 [Documentation] Rebooting the server. 292 293 Navigate To Server Power Page 294 ${present}= Run Keyword And Return Status 295 ... Element Should Be Visible ${xpath_power_reboot} 296 IF ${present} 297 Click Element ${xpath_power_reboot} 298 Wait Until Element Is Visible ${xpath_confirm} timeout=30 299 Click Button ${xpath_confirm} 300 Wait Until Element Is Visible ${xpath_power_reboot} timeout=60 301 ELSE 302 Log To console Server is already powered Off, can't reboot. 303 END 304 305 306Verify Success Message On BMC GUI Page 307 [Documentation] Perform actions on the GUI and verify that a success message is displayed. 308 309 Wait Until Element Is Visible ${xpath_success_message} timeout=30 310 Page Should Contain Element ${xpath_success_message} 311 Wait Until Element Is Not Visible ${xpath_success_message} timeout=30 312 313 314Verify Error And Unauthorized Message On GUI 315 [Documentation] Perform operations on GUI with Readonly user and 316 ... verify Error and Unauthorized messages. 317 318 Wait Until Element Is Visible ${xpath_error_popup} 319 Page Should Contain Error 320 Page Should Contain Unauthorized 321 Click Element ${xpath_error_popup} 322 Click Element ${xpath_unauthorized_popup} 323 324 325Create Readonly User And Login To GUI 326 [Documentation] Logout current GUI sessions and Created Readonly_user 327 ... via Redfish and Login BMC GUI with Readonly user 328 329 # Logout current GUI session. 330 Logout GUI 331 332 # Created readonly_user via redfish and login BMC GUI with readonly 333 # user to perform test. 334 Redfish.Login 335 Redfish Create User readonly_user ${OPENBMC_PASSWORD} ReadOnly ${True} 336 Login GUI readonly_user ${OPENBMC_PASSWORD} 337 338 339Delete Readonly User And Logout Current GUI Session 340 [Documentation] Logout current GUI session and delete Readonly user, 341 ... Perform Login GUI with default user and password. 342 343 # Delete Read-only user and Logout current GUI session. 344 Logout GUI 345 Redfish.Delete /redfish/v1/AccountService/Accounts/readonly_user 346 Close Browser 347 348 # Login BMC GUI with default user. 349 Launch Browser And Login GUI 350 351 352Wait And Click Element 353 [Documentation] Wait until element is visible then click the element. 354 [Arguments] ${locator} ${wait_timeout}=10s 355 356 # Description of argument(s): 357 # locator xpath of the element. 358 # wait_timeout timeout for the locator to visible. 359 360 Wait Until Element Is Visible ${locator} timeout=${wait_timeout} 361 Click Element ${locator} 362 363 364Navigate To Required Sub Menu 365 [Documentation] Navigate to required sub menu from main menu. 366 [Arguments] ${xpath_main_menu} ${xpath_sub_menu} ${sub_menu_text} 367 368 # Description of argument(s): 369 # xpath_main_menu Locator of main menu. 370 # xpath_sub_menu Locator of sub menu. 371 # sub_menu_text Text of sub menu. 372 373 ${present}= Run Keyword And Return Status 374 ... Element Should Be Visible ${xpath_sub_menu} 375 376 IF not ${present} 377 Wait And Click Element ${xpath_main_menu} 378 END 379 Wait And Click Element ${xpath_sub_menu} wait_timeout=60s 380 Location Should Contain ${sub_menu_text} 381 Wait Until Element Is Not Visible ${xpath_page_loading_progress_bar} timeout=1min 382