blob: 088f645bc0752cf9d0201d27d47686db549d595b [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# Default Browser.
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -060029${default_browser} ff
Sathyajith M S4f26ae72018-01-16 04:45:05 -060030
31${obmc_PowerOff_state} Off
32${obmc_PowerRunning_state} Running
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -060033${obmc_PowerStandby_state} Standby
Sathyajith M S4f26ae72018-01-16 04:45:05 -060034
35*** Keywords ***
36Launch OpenBMC GUI Browser
37 [Documentation] Launch the OpenBMC GUI URL on a browser.
38 # By default uses headless mode, otherwise, the GUI browser.
39
40 ${op_system}= Get Operating System
41 Run Keyword If '${op_system}' == 'windows'
Sivas SRRa0113482018-02-22 22:27:05 -060042 ... Launch Header Browser
43 ... ELSE IF '${op_system}' == 'Darwin'
44 # Mac OS is currently having some issues with firefox, so using
45 # chrome.
46 # TODO: Need to add support for other browsers. Issue #1280.
47 ... Launch Header Browser chrome
Sathyajith M S4f26ae72018-01-16 04:45:05 -060048 ... ELSE
Sivas SRRa0113482018-02-22 22:27:05 -060049 # Linux OS.
Sathyajith M S4f26ae72018-01-16 04:45:05 -060050 ... Launch Headless Browser
51
52Get Operating System
53 [Documentation] Identify platform/OS.
54
55 ${curdir_lower_case}= Convert To Lowercase ${CURDIR}
56 ${windows_platform}= Run Keyword And Return Status
57 ... Should Contain ${curdir_lower_case} c:\
58 ${op_system}= Run Keyword If '${windows_platform}' == 'True'
Sivas SRRa0113482018-02-22 22:27:05 -060059 ... Set Variable windows
60 ... ELSE
61 ... Run uname
Sathyajith M S4f26ae72018-01-16 04:45:05 -060062 [Return] ${op_system}
63
Sivas SRRa0113482018-02-22 22:27:05 -060064Launch Header Browser
Sathyajith M S4f26ae72018-01-16 04:45:05 -060065 [Documentation] Open the browser with the URL and
66 ... login on windows platform.
Sivas SRRa0113482018-02-22 22:27:05 -060067 [Arguments] ${browser_type}=${default_browser}
Sathyajith M S4f26ae72018-01-16 04:45:05 -060068
Sivas SRRa0113482018-02-22 22:27:05 -060069 # Description of argument(s):
70 # browser_type Type of browser (e.g. "firefox", "chrome", etc.).
Sathyajith M S2cdab0a2018-02-13 19:36:28 -060071
Sivas SRRa0113482018-02-22 22:27:05 -060072 ${BROWSER_ID}= Open Browser ${obmc_gui_url} ${browser_type}
Sathyajith M S4f26ae72018-01-16 04:45:05 -060073 Maximize Browser Window
74 Set Global Variable ${BROWSER_ID}
75
76Launch Headless Browser
77 [Documentation] Launch headless browser.
Rahul Maheshwari79e276c2018-06-11 01:23:15 -050078 [Arguments] ${URL}=${obmc_gui_url} ${browser}=${default_browser}
Sathyajith M S4f26ae72018-01-16 04:45:05 -060079
Rahul Maheshwari79e276c2018-06-11 01:23:15 -050080 # Description of argument(s):
81 # URL Openbmc GUI URL to be open
82 # (e.g. https://openbmc-test.mybluemix.net/#/login).
83 # browser Browser to open given URL in headless way
84 # (e.g. gc for google chrome, ff for firefox).
85
86 Start Virtual Display
87 ${browser_ID}= Open Browser ${URL}
Sathyajith M S4f26ae72018-01-16 04:45:05 -060088 Set Window Size 1920 1080
89
Rahul Maheshwari79e276c2018-06-11 01:23:15 -050090 [Return] ${browser_ID}
91
Sathyajith M S4f26ae72018-01-16 04:45:05 -060092Login OpenBMC GUI
93 [Documentation] Perform login to open BMC GUI.
94 [Arguments] ${username}=${OPENBMC_USERNAME}
95 ... ${password}=${OPENBMC_PASSWORD}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -060096
Sathyajith M S4f26ae72018-01-16 04:45:05 -060097 # Description of argument(s):
98 # username The username.
99 # password The password.
100
Sivas SRRc70e9ae2018-02-14 23:53:49 -0600101 Go To ${obmc_gui_url}
Sivas SRRa6925352018-02-19 08:59:03 -0600102 Wait Until Element Is Enabled ${xpath_textbox_hostname}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600103 Input Text ${xpath_textbox_hostname} ${OPENBMC_HOST}
104 Input Text ${xpath_textbox_username} ${username}
105 Input Password ${xpath_textbox_password} ${password}
Sivas SRRffa42692018-01-17 05:17:35 -0600106 Click Element login__submit
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600107 Wait Until Element Is Enabled ${xpath_button_logout}
Sivas SRRffa42692018-01-17 05:17:35 -0600108 Page Should Contain Server information
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600109
110
111Test Setup Execution
112 [Documentation] Verify all the preconditions to be tested.
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600113 [Arguments] ${obmc_test_setup_state}=${OBMC_PowerOff_state}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600114
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600115 # Description of argument(s):
116 # obmc_test_setup The OpenBMC required state.
117
118 Rprint Timen ${TEST NAME} ==> [STARTED]
Rahul Maheshwari7872f052018-06-19 01:12:34 -0500119 Launch Browser And Login OpenBMC GUI
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600120 Log To Console Verifying the system state and stablity...
121 ${obmc_current_state}= Get Text ${xpath_display_server_power_status}
122 Rpvars obmc_current_state
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600123
124 ${obmc_state_status}= Run Keyword And Return Status
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600125 ... Should Contain ${obmc_current_state} ${obmc_test_setup_state}
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600126 Return From Keyword If '${obmc_state_status}' == 'True'
127
128 ${obmc_standby_state}= Run Keyword And Return Status
129 ... Should Contain ${obmc_current_state} ${obmc_standby_state}
130
131 Run Keyword If '${obmc_standby_state}' == 'True'
132 ... Reboot OpenBMC
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600133 Run Keyword If '${obmc_test_setup_state}' == '${obmc_PowerRunning_state}'
134 ... Power On OpenBMC
135 Run Keyword If '${obmc_test_setup_state}' == '${obmc_PowerOff_state}'
136 ... Power Off OpenBMC
137
138Power Off OpenBMC
139 [Documentation] Power off the OBMC system.
140
141 Log To Console Power Off OpenBMC...
142 Click Element ${xpath_display_server_power_status}
143 Execute JavaScript window.scrollTo(0, document.body.scrollHeight)
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600144 Click Button ${xpath_select_button_orderly_shutdown}
145 Click Yes Button ${xpath_select_button_orderly_shutdown_yes}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600146 Wait OpenBMC To Become Stable ${obmc_off_state}
147
148Power On OpenBMC
149 [Documentation] Power on the OBMC system.
150
151 Log To Console Power On OpenBMC...
152 Click Element ${xpath_display_server_power_status}
153 Click Button ${xpath_select_button_power_on }
154 Wait OpenBMC To Become Stable ${obmc_running_state}
155
156Reboot OpenBMC
157 [Documentation] Rebooting the OBMC system.
158
159 Log To Console Reboting the OpenBMC...
160 Click Element ${xpath_display_server_power_status}
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600161 Click Button ${xpath_select_button_orderly_shutdown}
162 Click Yes Button ${xpath_select_button_orderly_shutdown_yes}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600163 Wait OpenBMC To Become Stable ${obmc_off_state}
164
165Wait OpenBMC To Become Stable
166 [Documentation] Power off the OBMC.
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600167 [Arguments] ${obmc_expected_state} ${retry_time}=15 min
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600168 ... ${retry_interval}=45 sec
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600169
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600170 # Description of argument(s):
171 # OBMC_expected_state The OBMC state which is required for test.
172 # retry_time Total wait time after executing the command.
173 # retry_interval Time interval for to keep checking with in the
174 # above total wait time.
175
176 Wait Until Keyword Succeeds ${retry_time} ${retry_interval}
177 ... Wait Until Element Contains ${xpath_display_server_power_status}
178 ... ${obmc_expected_state}
179 Wait Until Keyword Succeeds ${retry_time} ${retry_interval}
180 ... Verify OpenBMC State From REST Interface ${obmc_expected_state}
181
182Verify OpenBMC State From REST Interface
183 [Documentation] Verify system state from REST Interface.
184 [Arguments] ${obmc_required_state}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600185
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600186 # Description of argument(s):
187 # obmc_required_state The OBMC state which is required for test.
188
189 ${obmc_current_state_REST}= Get Host State
190 Should Be Equal ${obmc_current_state_REST} ${obmc_required_state}
191
192Click Yes Button
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600193 [Documentation] Click the 'Yes' button.
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600194 [Arguments] ${xpath_button_yes}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600195
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600196 # Description of argument(s):
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600197 # xpath_button_yes The xpath of 'Yes' button.
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600198
199 Click Button ${xpath_button_yes}
200
201LogOut OpenBMC GUI
202 [Documentation] Log out of OpenBMC GUI.
203 SSHLibrary.Close All Connections
Sivas SRRae39abe2018-02-26 02:40:46 -0600204 # Passing direct id element "header" as an argument to Click Element.
Rahul Maheshwarid36b6ac2018-06-19 01:44:06 -0500205 Click Element ${xpath_button_logout}
Sathyajith M S4f26ae72018-01-16 04:45:05 -0600206 Wait Until Page Contains Element ${xpath_button_login}
207
208Test Teardown Execution
209 [Documentation] Do final closure activities of test case execution.
210 Rprint Pgm Footer
211 Print Dashes 0 100 1 =
212 LogOut OpenBMC GUI
Sivas SRRffa42692018-01-17 05:17:35 -0600213
Rahul Maheshwari1b5369b2018-06-11 00:57:03 -0500214
Sivas SRRffa42692018-01-17 05:17:35 -0600215Open Browser With URL
216 [Documentation] Open browser with specified URL and returns browser id.
Rahul Maheshwari79e276c2018-06-11 01:23:15 -0500217 [Arguments] ${URL} ${browser}=ff ${mode}=headless
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600218
Sivas SRRffa42692018-01-17 05:17:35 -0600219 # Description of argument(s):
220 # URL Openbmc GUI URL to be open
Rahul Maheshwari79e276c2018-06-11 01:23:15 -0500221 # (e.g. https://openbmc-test.mybluemix.net/#/login).
222 # browser Browser used to open above URL
223 # (e.g. gc for google chrome, ff for firefox).
224 # mode Browser opening mode(e.g. headless, header).
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600225
Rahul Maheshwari79e276c2018-06-11 01:23:15 -0500226 ${browser_ID}= Run Keyword If '${mode}' == 'headless'
227 ... Launch Headless Browser ${URL} ${browser}
228 ... ELSE Open Browser ${URL} ${browser}
229
Sivas SRRffa42692018-01-17 05:17:35 -0600230 [Return] ${browser_ID}
231
Rahul Maheshwari1b5369b2018-06-11 00:57:03 -0500232
Sivas SRRffa42692018-01-17 05:17:35 -0600233Model Server Power Click Button
234 [Documentation] Click main server power in the header section.
235 [Arguments] ${div_element} ${anchor_element}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600236
Sivas SRRffa42692018-01-17 05:17:35 -0600237 # Description of argument(s):
238 # div_element Server power header divisional element
239 # (e.g. header_wrapper.)
240 # anchor_element Server power header anchor element
241 # (e.g. header_wrapper_elt.)
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600242
Sivas SRRffa42692018-01-17 05:17:35 -0600243 Wait Until Element Is Visible
244 ... //*[@id='header__wrapper']/div/div[${div_element}]/a[${anchor_element}]/span
245 Click Element
246 ... //*[@id='header__wrapper']/div/div[${div_element}]/a[${anchor_element}]/span
247
248Controller Server Power Click Button
249 [Documentation] Click main server power in the header section.
250 [Arguments] ${controller_element}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600251
Sivas SRRffa42692018-01-17 05:17:35 -0600252 # Description of argument(s):
253 # controller_element Server power controller element
254 # (e.g. power__power-on.)
255
256 Wait Until Element Is Visible ${controller_element}
257 Page Should Contain Button ${controller_element}
258 Click Element ${controller_element}
259
260Controller Power Operations Confirmation Click Button
261 [Documentation] Click Common Power Operations Confirmation.
262 [Arguments] ${main_element} ${sub_element} ${confirm_msg_elt} ${confirmation}
Sathyajith M S2cdab0a2018-02-13 19:36:28 -0600263
Sivas SRRffa42692018-01-17 05:17:35 -0600264 # Description of argument(s):
265 # main_element Server power operations element
266 # (e.g. power_operations.)
267 # sub_element Server power operations sub element
268 # (e.g. warm_boot, shut_down.)
269 # confirm_msg_elt Server power operations confirm message element
270 # (e.g. confirm_msg.)
271 # confirmation Server power operations confirmation
272 # (e.g. yes.)
273
Joy Onyerikwuf4a807b2018-06-20 08:43:54 -0500274 ${element_path}= Catenate //*[@id='power-operations']/div[${main_element}]/div[${sub_element}]
275 ... /confirm/div/div[${confirm_msg_elt}]/button[${confirmation}]
276 Click Element ${element_path.replace(" ","")}
277
Sivas SRRffa42692018-01-17 05:17:35 -0600278
279GUI Power On
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600280 [Documentation] Power on the host using GUI.
Sivas SRRffa42692018-01-17 05:17:35 -0600281
282 Model Server Power Click Button ${header_wrapper} ${header_wrapper_elt}
283 Page Should Contain Attempts to power on the server
284 Controller Server Power Click Button power__power-on
285 Page Should Contain Running
286
Sathyajith M Sf52d6fc2018-01-24 10:11:18 -0600287Verify Display Content
288 [Documentation] Verify text content display.
289 [Arguments] ${display_text}
290
291 # Description of argument(s):
292 # display_text The text which is expected to be found on the web page.
293
294 Page Should Contain ${display_text}
295
296Warm Reboot openBMC
297 [Documentation] Warm reboot the OBMC system.
298
299 Log To Console Warm Reboting the OpenBMC...
300 Click Element ${xpath_select_button_warm_reboot}
301 Verify Warning Message Display Text ${xpath_warm_reboot_warning_message}
302 ... ${text_warm_reboot_warning_message}
303 Click Yes Button ${xpath_select_button_warm_reboot_yes}
304 Wait OpenBMC To Become Stable ${obmc_running_state}
305
306Click No Button
307 [Documentation] Click the 'No' button.
308 [Arguments] ${xpath_button_no}
309
310 # Description of argument(s):
311 # xpath_button_no The xpath of 'No' button.
312
313 Click Button ${xpath_button_no}
314
315Cold Reboot openBMC
316 [Documentation] Cold reboot the OBMC system.
317
318 Log To Console Cold Reboting the OpenBMC...
319 Click Element ${xpath_select_button_cold_reboot}
320 Verify Warning Message Display Text ${xpath_cold_reboot_warning_message}
321 ... ${text_cold_reboot_warning_message}
322 Click Yes Button ${xpath_select_button_cold_reboot_yes}
323 Wait OpenBMC To Become Stable ${obmc_running_state}
324
325Orderly Shutdown OpenBMC
326 [Documentation] Do orderly shutdown the OBMC system.
327
328 Log To Console Orderly Shutdown the OpenBMC...
329 Click Element ${xpath_select_button_orderly_shutdown}
330 Verify Warning Message Display Text ${xpath_orderly_shutdown_warning_message}
331 ... ${text_orderly_shutdown_warning_message}
332 Click Yes Button ${xpath_select_button_orderly_shutdown_yes}
333 Wait OpenBMC To Become Stable ${obmc_off_state}
334
335Immediate Shutdown openBMC
336 [Documentation] Do immediate shutdown the OBMC system.
337
338 Log To Console Immediate Shutdown the OpenBMC...
339 Click Element ${xpath_select_button_immediate_shutdown}
340 Verify Warning Message Display Text
341 ... ${xpath_immediate_shutdown_warning_message}
342 ... ${text_immediate_shutdown_warning_message}
343 Click Yes Button ${xpath_select_button_immediate_shutdown_yes}
344 Wait OpenBMC To Become Stable ${obmc_off_state}
345
346Verify Warning Message Display Text
347 [Documentation] Verify the warning message display text.
348 [Arguments] ${xpath_text_message} ${text_message}
349
350 # xpath_text_message Xpath of warning message display.
351 # text_message Content of the display message info.
352
353 Element Text Should Be ${xpath_text_message} ${text_message}
Sivas SRRca534e62018-02-20 02:22:02 -0600354
355
356Expected Initial Test State
357 [Documentation] Power on the host if "Running" expected, Power off the
358 ... host if "Off" expected as per the requirement of initial test state.
359 [Arguments] ${expectedState}
360 # Description of argument(s):
361 # expectedState Test initial host state.
362
363 Run Keyword If '${expectedState}' == 'Running'
364 ... Initiate Host Boot
365
366 Run Keyword If '${expectedState}' == 'Off'
367 ... Initiate Host PowerOff
Sivas SRR008dcc62018-02-27 06:34:56 -0600368
369Launch Browser And Login OpenBMC GUI
370 [Documentation] Launch browser and log into openbmc GUI.
371
372 Open Browser With URL ${obmc_gui_url}
373 Login OpenBMC GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
374
375Logout And Close Browser
376 [Documentation] Logout from openbmc application and close the browser.
377
378 Click Element header
379 Close Browser