blob: 9f132bb7531c5ab3038a62987ed5d5bfbec4e849 [file] [log] [blame]
Sathyajith M S4f26ae72018-01-16 04:45:05 -06001*** 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 Selenium2Library 120 120
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.txt
21Resource ../../../lib/rest_client.robot
22Resource ../../../lib/state_manager.robot
23Variables ../data/resource_variables.py
24
25*** Variables ***
Sivas SRRc70e9ae2018-02-14 23:53:49 -060026${obmc_gui_url} https://${OPENBMC_HOST}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -060027
Sathyajith M S4f26ae72018-01-16 04:45:05 -060028${obmc_PowerOff_state} Off
29${obmc_PowerRunning_state} Running
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -060030${obmc_PowerStandby_state} Standby
Sathyajith M S4f26ae72018-01-16 04:45:05 -060031
Rahul Maheshwaridd38aef2018-11-15 23:33:10 -060032# Default GUI broswer and mode is set to "Firefox" and "headless"
33# respectively here.
34${GUI_BROWSER} ff
35${GUI_MODE} headless
36
Sathyajith M S4f26ae72018-01-16 04:45:05 -060037*** 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'
Sivas SRRa0113482018-02-22 22:27:05 -060044 ... 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
Sathyajith M S4f26ae72018-01-16 04:45:05 -060050 ... ELSE
Sivas SRRa0113482018-02-22 22:27:05 -060051 # Linux OS.
Sathyajith M S4f26ae72018-01-16 04:45:05 -060052 ... 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'
Sivas SRRa0113482018-02-22 22:27:05 -060061 ... Set Variable windows
62 ... ELSE
63 ... Run uname
Sathyajith M S4f26ae72018-01-16 04:45:05 -060064 [Return] ${op_system}
65
Sivas SRRa0113482018-02-22 22:27:05 -060066Launch Header Browser
Sathyajith M S4f26ae72018-01-16 04:45:05 -060067 [Documentation] Open the browser with the URL and
68 ... login on windows platform.
Rahul Maheshwaridd38aef2018-11-15 23:33:10 -060069 [Arguments] ${browser_type}=${GUI_BROWSER}
Sathyajith M S4f26ae72018-01-16 04:45:05 -060070
Sivas SRRa0113482018-02-22 22:27:05 -060071 # Description of argument(s):
72 # browser_type Type of browser (e.g. "firefox", "chrome", etc.).
Sathyajith M S2cdab0a2018-02-13 19:36:28 -060073
Sivas SRRa0113482018-02-22 22:27:05 -060074 ${BROWSER_ID}= Open Browser ${obmc_gui_url} ${browser_type}
Sathyajith M S4f26ae72018-01-16 04:45:05 -060075 Maximize Browser Window
76 Set Global Variable ${BROWSER_ID}
77
78Launch Headless Browser
79 [Documentation] Launch headless browser.
Rahul Maheshwaridd38aef2018-11-15 23:33:10 -060080 [Arguments] ${URL}=${obmc_gui_url} ${browser}=${GUI_BROWSER}
Sathyajith M S4f26ae72018-01-16 04:45:05 -060081
Rahul Maheshwari79e276c2018-06-11 01:23:15 -050082 # 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}
Sathyajith M S4f26ae72018-01-16 04:45:05 -060090 Set Window Size 1920 1080
91
Rahul Maheshwari79e276c2018-06-11 01:23:15 -050092 [Return] ${browser_ID}
93
Sathyajith M S4f26ae72018-01-16 04:45:05 -060094Login OpenBMC GUI
95 [Documentation] Perform login to open BMC GUI.
96 [Arguments] ${username}=${OPENBMC_USERNAME}
97 ... ${password}=${OPENBMC_PASSWORD}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -060098
Sathyajith M S4f26ae72018-01-16 04:45:05 -060099 # Description of argument(s):
100 # username The username.
101 # password The password.
102
Sivas SRRc70e9ae2018-02-14 23:53:49 -0600103 Go To ${obmc_gui_url}
Sivas SRRa6925352018-02-19 08:59:03 -0600104 Wait Until Element Is Enabled ${xpath_textbox_hostname}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600105 Input Text ${xpath_textbox_hostname} ${OPENBMC_HOST}
106 Input Text ${xpath_textbox_username} ${username}
107 Input Password ${xpath_textbox_password} ${password}
Sivas SRRffa42692018-01-17 05:17:35 -0600108 Click Element login__submit
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600109 Wait Until Element Is Enabled ${xpath_button_logout}
Sivas SRRffa42692018-01-17 05:17:35 -0600110 Page Should Contain Server information
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600111
112
113Test Setup Execution
114 [Documentation] Verify all the preconditions to be tested.
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600115 [Arguments] ${obmc_test_setup_state}=${OBMC_PowerOff_state}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600116
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600117 # Description of argument(s):
118 # obmc_test_setup The OpenBMC required state.
119
120 Rprint Timen ${TEST NAME} ==> [STARTED]
Rahul Maheshwari7872f052018-06-19 01:12:34 -0500121 Launch Browser And Login OpenBMC GUI
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600122 Log To Console Verifying the system state and stablity...
Rahul Maheshwari8b5b5a42018-11-30 01:41:35 -0600123
124 Click Button ${xpath_select_server_power}
125 ${obmc_current_state}= Get Text ${xpath_power_indicator}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600126 Rpvars obmc_current_state
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600127
128 ${obmc_state_status}= Run Keyword And Return Status
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600129 ... Should Contain ${obmc_current_state} ${obmc_test_setup_state}
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600130 Return From Keyword If '${obmc_state_status}' == 'True'
131
132 ${obmc_standby_state}= Run Keyword And Return Status
133 ... Should Contain ${obmc_current_state} ${obmc_standby_state}
134
135 Run Keyword If '${obmc_standby_state}' == 'True'
136 ... Reboot OpenBMC
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600137 Run Keyword If '${obmc_test_setup_state}' == '${obmc_PowerRunning_state}'
138 ... Power On OpenBMC
139 Run Keyword If '${obmc_test_setup_state}' == '${obmc_PowerOff_state}'
140 ... Power Off OpenBMC
141
142Power Off OpenBMC
143 [Documentation] Power off the OBMC system.
144
145 Log To Console Power Off OpenBMC...
146 Click Element ${xpath_display_server_power_status}
147 Execute JavaScript window.scrollTo(0, document.body.scrollHeight)
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600148 Click Button ${xpath_select_button_orderly_shutdown}
149 Click Yes Button ${xpath_select_button_orderly_shutdown_yes}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600150 Wait OpenBMC To Become Stable ${obmc_off_state}
151
152Power On OpenBMC
153 [Documentation] Power on the OBMC system.
154
155 Log To Console Power On OpenBMC...
156 Click Element ${xpath_display_server_power_status}
157 Click Button ${xpath_select_button_power_on }
158 Wait OpenBMC To Become Stable ${obmc_running_state}
159
160Reboot OpenBMC
161 [Documentation] Rebooting the OBMC system.
162
163 Log To Console Reboting the OpenBMC...
164 Click Element ${xpath_display_server_power_status}
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600165 Click Button ${xpath_select_button_orderly_shutdown}
166 Click Yes Button ${xpath_select_button_orderly_shutdown_yes}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600167 Wait OpenBMC To Become Stable ${obmc_off_state}
168
169Wait OpenBMC To Become Stable
170 [Documentation] Power off the OBMC.
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600171 [Arguments] ${obmc_expected_state} ${retry_time}=15 min
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600172 ... ${retry_interval}=45 sec
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600173
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600174 # Description of argument(s):
175 # OBMC_expected_state The OBMC state which is required for test.
176 # retry_time Total wait time after executing the command.
177 # retry_interval Time interval for to keep checking with in the
178 # above total wait time.
179
180 Wait Until Keyword Succeeds ${retry_time} ${retry_interval}
181 ... Wait Until Element Contains ${xpath_display_server_power_status}
182 ... ${obmc_expected_state}
183 Wait Until Keyword Succeeds ${retry_time} ${retry_interval}
184 ... Verify OpenBMC State From REST Interface ${obmc_expected_state}
185
186Verify OpenBMC State From REST Interface
187 [Documentation] Verify system state from REST Interface.
188 [Arguments] ${obmc_required_state}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600189
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600190 # Description of argument(s):
191 # obmc_required_state The OBMC state which is required for test.
192
193 ${obmc_current_state_REST}= Get Host State
194 Should Be Equal ${obmc_current_state_REST} ${obmc_required_state}
195
196Click Yes Button
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600197 [Documentation] Click the 'Yes' button.
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600198 [Arguments] ${xpath_button_yes}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600199
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600200 # Description of argument(s):
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600201 # xpath_button_yes The xpath of 'Yes' button.
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600202
203 Click Button ${xpath_button_yes}
204
205LogOut OpenBMC GUI
206 [Documentation] Log out of OpenBMC GUI.
207 SSHLibrary.Close All Connections
Sivas SRRae39abe2018-02-26 02:40:46 -0600208 # Passing direct id element "header" as an argument to Click Element.
Rahul Maheshwarid36b6ac2018-06-19 01:44:06 -0500209 Click Element ${xpath_button_logout}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600210 Wait Until Page Contains Element ${xpath_button_login}
211
212Test Teardown Execution
213 [Documentation] Do final closure activities of test case execution.
214 Rprint Pgm Footer
215 Print Dashes 0 100 1 =
216 LogOut OpenBMC GUI
Sivas SRRffa42692018-01-17 05:17:35 -0600217
Rahul Maheshwari1b5369b2018-06-11 00:57:03 -0500218
Sivas SRRffa42692018-01-17 05:17:35 -0600219Open Browser With URL
220 [Documentation] Open browser with specified URL and returns browser id.
Rahul Maheshwaridd38aef2018-11-15 23:33:10 -0600221 [Arguments] ${URL} ${browser}=ff ${mode}=${GUI_MODE}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600222
Sivas SRRffa42692018-01-17 05:17:35 -0600223 # Description of argument(s):
224 # URL Openbmc GUI URL to be open
Rahul Maheshwari79e276c2018-06-11 01:23:15 -0500225 # (e.g. https://openbmc-test.mybluemix.net/#/login).
226 # browser Browser used to open above URL
227 # (e.g. gc for google chrome, ff for firefox).
228 # mode Browser opening mode(e.g. headless, header).
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600229
Rahul Maheshwari79e276c2018-06-11 01:23:15 -0500230 ${browser_ID}= Run Keyword If '${mode}' == 'headless'
231 ... Launch Headless Browser ${URL} ${browser}
232 ... ELSE Open Browser ${URL} ${browser}
233
Sivas SRRffa42692018-01-17 05:17:35 -0600234 [Return] ${browser_ID}
235
Rahul Maheshwari1b5369b2018-06-11 00:57:03 -0500236
Sivas SRRffa42692018-01-17 05:17:35 -0600237Model Server Power Click Button
238 [Documentation] Click main server power in the header section.
239 [Arguments] ${div_element} ${anchor_element}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600240
Sivas SRRffa42692018-01-17 05:17:35 -0600241 # Description of argument(s):
242 # div_element Server power header divisional element
243 # (e.g. header_wrapper.)
244 # anchor_element Server power header anchor element
245 # (e.g. header_wrapper_elt.)
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600246
Sivas SRRffa42692018-01-17 05:17:35 -0600247 Wait Until Element Is Visible
248 ... //*[@id='header__wrapper']/div/div[${div_element}]/a[${anchor_element}]/span
249 Click Element
250 ... //*[@id='header__wrapper']/div/div[${div_element}]/a[${anchor_element}]/span
251
252Controller Server Power Click Button
253 [Documentation] Click main server power in the header section.
254 [Arguments] ${controller_element}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600255
Sivas SRRffa42692018-01-17 05:17:35 -0600256 # Description of argument(s):
257 # controller_element Server power controller element
258 # (e.g. power__power-on.)
259
Rahul Maheshwaridbbf1792018-10-31 05:36:29 -0500260 Click Element ${xpath_select_server_power}
Sivas SRRffa42692018-01-17 05:17:35 -0600261 Wait Until Element Is Visible ${controller_element}
262 Page Should Contain Button ${controller_element}
263 Click Element ${controller_element}
264
265Controller Power Operations Confirmation Click Button
266 [Documentation] Click Common Power Operations Confirmation.
267 [Arguments] ${main_element} ${sub_element} ${confirm_msg_elt} ${confirmation}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600268
Sivas SRRffa42692018-01-17 05:17:35 -0600269 # Description of argument(s):
270 # main_element Server power operations element
271 # (e.g. power_operations.)
272 # sub_element Server power operations sub element
273 # (e.g. warm_boot, shut_down.)
274 # confirm_msg_elt Server power operations confirm message element
275 # (e.g. confirm_msg.)
276 # confirmation Server power operations confirmation
277 # (e.g. yes.)
278
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500279 ${element_path}= Catenate //*[@id='power-operations']/div[${main_element}]/div[${sub_element}]
280 ... /confirm/div/div[${confirm_msg_elt}]/button[${confirmation}]
281 Click Element ${element_path.replace(" ","")}
282
Sivas SRRffa42692018-01-17 05:17:35 -0600283
284GUI Power On
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600285 [Documentation] Power on the host using GUI.
Sivas SRRffa42692018-01-17 05:17:35 -0600286
287 Model Server Power Click Button ${header_wrapper} ${header_wrapper_elt}
288 Page Should Contain Attempts to power on the server
289 Controller Server Power Click Button power__power-on
290 Page Should Contain Running
291
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600292Verify Display Content
293 [Documentation] Verify text content display.
294 [Arguments] ${display_text}
295
296 # Description of argument(s):
297 # display_text The text which is expected to be found on the web page.
298
299 Page Should Contain ${display_text}
300
301Warm Reboot openBMC
302 [Documentation] Warm reboot the OBMC system.
303
304 Log To Console Warm Reboting the OpenBMC...
305 Click Element ${xpath_select_button_warm_reboot}
306 Verify Warning Message Display Text ${xpath_warm_reboot_warning_message}
307 ... ${text_warm_reboot_warning_message}
308 Click Yes Button ${xpath_select_button_warm_reboot_yes}
309 Wait OpenBMC To Become Stable ${obmc_running_state}
310
311Click No Button
312 [Documentation] Click the 'No' button.
313 [Arguments] ${xpath_button_no}
314
315 # Description of argument(s):
316 # xpath_button_no The xpath of 'No' button.
317
318 Click Button ${xpath_button_no}
319
320Cold Reboot openBMC
321 [Documentation] Cold reboot the OBMC system.
322
323 Log To Console Cold Reboting the OpenBMC...
324 Click Element ${xpath_select_button_cold_reboot}
325 Verify Warning Message Display Text ${xpath_cold_reboot_warning_message}
326 ... ${text_cold_reboot_warning_message}
327 Click Yes Button ${xpath_select_button_cold_reboot_yes}
328 Wait OpenBMC To Become Stable ${obmc_running_state}
329
330Orderly Shutdown OpenBMC
331 [Documentation] Do orderly shutdown the OBMC system.
332
333 Log To Console Orderly Shutdown the OpenBMC...
334 Click Element ${xpath_select_button_orderly_shutdown}
335 Verify Warning Message Display Text ${xpath_orderly_shutdown_warning_message}
336 ... ${text_orderly_shutdown_warning_message}
337 Click Yes Button ${xpath_select_button_orderly_shutdown_yes}
338 Wait OpenBMC To Become Stable ${obmc_off_state}
339
340Immediate Shutdown openBMC
341 [Documentation] Do immediate shutdown the OBMC system.
342
343 Log To Console Immediate Shutdown the OpenBMC...
344 Click Element ${xpath_select_button_immediate_shutdown}
345 Verify Warning Message Display Text
346 ... ${xpath_immediate_shutdown_warning_message}
347 ... ${text_immediate_shutdown_warning_message}
348 Click Yes Button ${xpath_select_button_immediate_shutdown_yes}
349 Wait OpenBMC To Become Stable ${obmc_off_state}
350
351Verify Warning Message Display Text
352 [Documentation] Verify the warning message display text.
353 [Arguments] ${xpath_text_message} ${text_message}
354
355 # xpath_text_message Xpath of warning message display.
356 # text_message Content of the display message info.
357
358 Element Text Should Be ${xpath_text_message} ${text_message}
Sivas SRRca534e62018-02-20 02:22:02 -0600359
360
361Expected Initial Test State
362 [Documentation] Power on the host if "Running" expected, Power off the
363 ... host if "Off" expected as per the requirement of initial test state.
364 [Arguments] ${expectedState}
365 # Description of argument(s):
366 # expectedState Test initial host state.
367
368 Run Keyword If '${expectedState}' == 'Running'
Rahul Maheshwari23491692018-11-09 03:42:41 -0600369 ... REST Power On stack_mode=skip quiet=1
Sivas SRRca534e62018-02-20 02:22:02 -0600370
371 Run Keyword If '${expectedState}' == 'Off'
Rahul Maheshwari23491692018-11-09 03:42:41 -0600372 ... REST Power Off stack_mode=skip quiet=1
Sivas SRR008dcc62018-02-27 06:34:56 -0600373
374Launch Browser And Login OpenBMC GUI
375 [Documentation] Launch browser and log into openbmc GUI.
376
377 Open Browser With URL ${obmc_gui_url}
378 Login OpenBMC GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
379
380Logout And Close Browser
381 [Documentation] Logout from openbmc application and close the browser.
382
Rahul Maheshwari1a6945e2018-11-26 03:21:40 -0600383 Click Element //*[text()='Log out']
Sivas SRR008dcc62018-02-27 06:34:56 -0600384 Close Browser