1*** Settings *** 2Documentation This is a resource file of OpenBMC ASMI It contains the 3... user-defined keywords which are available to all gui modules 4 5Library String 6Library Collections 7Library DateTime 8Library XvfbRobot 9Library OperatingSystem 10Library SeleniumLibrary 11Library AngularJSLibrary 12Library SSHLibrary 30 Seconds 13Library Process 14Library supporting_libs.py 15Library ../../lib/gen_print.py 16Library ../../lib/gen_robot_print.py 17Library ../../lib/gen_valid.py 18Library ../../lib/gen_robot_ssh.py 19Library ../../lib/bmc_ssh_utils.py 20Resource ../../lib/resource.robot 21Resource ../../lib/rest_client.robot 22Resource ../../lib/state_manager.robot 23Variables ../data/resource_variables.py 24 25*** Variables *** 26${obmc_gui_url} https://${OPENBMC_HOST} 27 28${obmc_PowerOff_state} Off 29${obmc_PowerRunning_state} Running 30${obmc_PowerStandby_state} Standby 31 32# Default GUI broswer and mode is set to "Firefox" and "headless" 33# respectively here. 34${GUI_BROWSER} ff 35${GUI_MODE} headless 36 37*** Keywords *** 38Launch OpenBMC GUI Browser 39 [Documentation] Launch the OpenBMC GUI URL on a browser. 40 # By default uses headless mode, otherwise, the GUI browser. 41 42 ${op_system}= Get Operating System 43 Run Keyword If '${op_system}' == 'windows' 44 ... Launch Header Browser 45 ... ELSE IF '${op_system}' == 'Darwin' 46 # Mac OS is currently having some issues with firefox, so using 47 # chrome. 48 # TODO: Need to add support for other browsers. Issue #1280. 49 ... Launch Header Browser chrome 50 ... ELSE 51 # Linux OS. 52 ... Launch Headless Browser 53 54Get Operating System 55 [Documentation] Identify platform/OS. 56 57 ${curdir_lower_case}= Convert To Lowercase ${CURDIR} 58 ${windows_platform}= Run Keyword And Return Status 59 ... Should Contain ${curdir_lower_case} c:\ 60 ${op_system}= Run Keyword If '${windows_platform}' == 'True' 61 ... Set Variable windows 62 ... ELSE 63 ... Run uname 64 [Return] ${op_system} 65 66Launch Header Browser 67 [Documentation] Open the browser with the URL and 68 ... login on windows platform. 69 [Arguments] ${browser_type}=${GUI_BROWSER} 70 71 # Description of argument(s): 72 # browser_type Type of browser (e.g. "firefox", "chrome", etc.). 73 74 ${BROWSER_ID}= Open Browser ${obmc_gui_url} ${browser_type} 75 Maximize Browser Window 76 Set Global Variable ${BROWSER_ID} 77 78Launch Headless Browser 79 [Documentation] Launch headless browser. 80 [Arguments] ${URL}=${obmc_gui_url} ${browser}=${GUI_BROWSER} 81 82 # Description of argument(s): 83 # URL Openbmc GUI URL to be open 84 # (e.g. https://openbmc-test.mybluemix.net/#/login). 85 # browser Browser to open given URL in headless way 86 # (e.g. gc for google chrome, ff for firefox). 87 88 Start Virtual Display 89 ${browser_ID}= Open Browser ${URL} 90 Set Window Size 1920 1080 91 92 [Return] ${browser_ID} 93 94Login OpenBMC GUI 95 [Documentation] Perform login to open BMC GUI. 96 [Arguments] ${username}=${OPENBMC_USERNAME} 97 ... ${password}=${OPENBMC_PASSWORD} 98 99 # Description of argument(s): 100 # username The username. 101 # password The password. 102 103 Go To ${obmc_gui_url} 104 Wait Until Element Is Enabled ${xpath_textbox_hostname} 105 Input Text ${xpath_textbox_hostname} ${OPENBMC_HOST} 106 Input Text ${xpath_textbox_username} ${username} 107 Input Password ${xpath_textbox_password} ${password} 108 Click Element login__submit 109 Wait Until Element Is Enabled ${xpath_button_logout} 110 Page Should Contain Server information 111 112 113Test Setup Execution 114 [Documentation] Verify all the preconditions to be tested. 115 [Arguments] ${obmc_test_setup_state}=${OBMC_PowerOff_state} 116 117 # Description of argument(s): 118 # obmc_test_setup The OpenBMC required state. 119 120 Print Timen ${TEST NAME} ==> [STARTED] 121 Launch Browser And Login OpenBMC GUI 122 Log To Console Verifying the system state and stablity... 123 124 Click Element ${xpath_select_server_power} 125 Wait Until Page Does Not Contain Unreachable 126 ${obmc_current_state}= Get Text ${xpath_power_indicator} 127 Rpvars obmc_current_state 128 129 ${obmc_state_status}= Run Keyword And Return Status 130 ... Should Contain ${obmc_current_state} ${obmc_test_setup_state} 131 Return From Keyword If '${obmc_state_status}' == 'True' 132 133 ${obmc_standby_state}= Run Keyword And Return Status 134 ... Should Contain ${obmc_current_state} ${obmc_standby_state} 135 136 Run Keyword If '${obmc_standby_state}' == 'True' 137 ... Reboot OpenBMC 138 Run Keyword If '${obmc_test_setup_state}' == '${obmc_PowerRunning_state}' 139 ... Run Keywords Power On OpenBMC AND 140 ... Wait Until Keyword Succeeds 10 min 60 sec Is Host Running 141 Run Keyword If '${obmc_test_setup_state}' == '${obmc_PowerOff_state}' 142 ... Run Keywords Redfish.Login AND Redfish Power Off AND Redfish.Logout 143 144 145Power On OpenBMC 146 [Documentation] Power on the OBMC system. 147 148 Log To Console Power On OpenBMC... 149 Click Element ${xpath_select_server_power} 150 Click Button ${xpath_select_button_power_on } 151 Wait OpenBMC To Become Stable ${obmc_running_state} 152 153Reboot OpenBMC 154 [Documentation] Rebooting the OBMC system. 155 156 Log To Console Reboting the OpenBMC... 157 Click Element ${xpath_select_server_power} 158 Click Button ${xpath_select_button_orderly_shutdown} 159 Click Yes Button ${xpath_select_button_orderly_shutdown_yes} 160 Wait OpenBMC To Become Stable ${obmc_off_state} 161 162Wait OpenBMC To Become Stable 163 [Documentation] Power off the OBMC. 164 [Arguments] ${obmc_expected_state} ${retry_time}=15 min 165 ... ${retry_interval}=45 sec 166 167 # Description of argument(s): 168 # OBMC_expected_state The OBMC state which is required for test. 169 # retry_time Total wait time after executing the command. 170 # retry_interval Time interval for to keep checking with in the 171 # above total wait time. 172 173 Wait Until Keyword Succeeds ${retry_time} ${retry_interval} 174 ... Wait Until Element Contains ${xpath_select_server_power} 175 ... ${obmc_expected_state} 176 Wait Until Keyword Succeeds ${retry_time} ${retry_interval} 177 ... Verify OpenBMC State From REST Interface ${obmc_expected_state} 178 179Verify OpenBMC State From REST Interface 180 [Documentation] Verify system state from REST Interface. 181 [Arguments] ${obmc_required_state} 182 183 # Description of argument(s): 184 # obmc_required_state The OBMC state which is required for test. 185 186 ${obmc_current_state_REST}= Get Host State 187 Should Be Equal ${obmc_current_state_REST} ${obmc_required_state} 188 189Click Yes Button 190 [Documentation] Click the 'Yes' button. 191 [Arguments] ${xpath_button_yes} 192 193 # Description of argument(s): 194 # xpath_button_yes The xpath of 'Yes' button. 195 196 Click Button ${xpath_button_yes} 197 198LogOut OpenBMC GUI 199 [Documentation] Log out of OpenBMC GUI. 200 SSHLibrary.Close All Connections 201 Click Button ${xpath_button_user_action} 202 Click Element ${xpath_button_logout} 203 Wait Until Page Contains Element ${xpath_button_login} 204 205Test Teardown Execution 206 [Documentation] Do final closure activities of test case execution. 207 Print Pgm Footer 208 Print Dashes 0 100 1 = 209 Close Browser 210 211 212Open Browser With URL 213 [Documentation] Open browser with specified URL and returns browser id. 214 [Arguments] ${URL} ${browser}=ff ${mode}=${GUI_MODE} 215 216 # Description of argument(s): 217 # URL Openbmc GUI URL to be open 218 # (e.g. https://openbmc-test.mybluemix.net/#/login). 219 # browser Browser used to open above URL 220 # (e.g. gc for google chrome, ff for firefox). 221 # mode Browser opening mode(e.g. headless, header). 222 223 ${browser_ID}= Run Keyword If '${mode}' == 'headless' 224 ... Launch Headless Browser ${URL} ${browser} 225 ... ELSE Open Browser ${URL} ${browser} 226 227 [Return] ${browser_ID} 228 229 230Controller Server Power Click Button 231 [Documentation] Click main server power in the header section. 232 [Arguments] ${controller_element} 233 234 # Description of argument(s): 235 # controller_element Server power controller element 236 # (e.g. power__power-on.) 237 238 Click Element ${xpath_select_server_power} 239 Wait Until Element Is Visible ${controller_element} 240 Page Should Contain Button ${controller_element} 241 Click Element ${controller_element} 242 243 244GUI Power On 245 [Documentation] Power on the host using GUI. 246 247 Controller Server Power Click Button power__power-on 248 Wait Until Page Contains Running timeout=30s 249 250Verify Display Content 251 [Documentation] Verify text content display. 252 [Arguments] ${display_text} 253 254 # Description of argument(s): 255 # display_text The text which is expected to be found on the web page. 256 257 Page Should Contain ${display_text} 258 259 260Verify Warning Message Display Text 261 [Documentation] Verify the warning message display text. 262 [Arguments] ${xpath_text_message} ${text_message} 263 264 # xpath_text_message Xpath of warning message display. 265 # text_message Content of the display message info. 266 267 Element Should Contain ${xpath_text_message} ${text_message} 268 269 270Expected Initial Test State 271 [Documentation] Power on the host if "Running" expected, Power off the 272 ... host if "Off" expected as per the requirement of initial test state. 273 [Arguments] ${expectedState} 274 # Description of argument(s): 275 # expectedState Test initial host state. 276 277 Run Keyword If '${expectedState}' == 'Running' 278 ... REST Power On stack_mode=skip quiet=1 279 280 Run Keyword If '${expectedState}' == 'Off' 281 ... REST Power Off stack_mode=skip quiet=1 282 283Launch Browser And Login OpenBMC GUI 284 [Documentation] Launch browser and log into openbmc GUI. 285 286 Open Browser With URL ${obmc_gui_url} 287 Login OpenBMC GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 288 289Logout And Close Browser 290 [Documentation] Logout from openbmc application and close the browser. 291 292 Click Button ${xpath_button_user_action} 293 Click Button ${xpath_button_logout} 294 Close Browser 295 296 297Launch Browser And Login GUI 298 [Documentation] Launch browser and login to OpenBMC GUI. 299 300 Open Browser With URL ${obmc_gui_url} 301 Login GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 302 303 304Login GUI 305 [Documentation] Login to OpenBMC GUI. 306 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD} 307 308 # Description of argument(s): 309 # username The username to be used for login. 310 # password The password to be used for login. 311 312 Go To ${obmc_gui_url} 313 Wait Until Element Is Enabled ${xpath_textbox_username} 314 Input Text ${xpath_textbox_username} ${username} 315 Input Password ${xpath_textbox_password} ${password} 316 Click Element ${xpath_login_button} 317 Wait Until Page Contains Overview timeout=30s 318 319 320Logout GUI 321 [Documentation] Logout of OpenBMC GUI. 322 323 Click Element ${xpath_logout_button} 324 Wait Until Page Contains Element ${xpath_login_button} 325