REST API validations for power operations
Resolves openbmc/openbmc-test-automation#1201
Change-Id: I74c252e6222acf35f8620f2573d1a2b2d98385eb
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/gui/obmc_asmi/data/resource_variables.py b/gui/obmc_asmi/data/resource_variables.py
deleted file mode 100644
index 918e320..0000000
--- a/gui/obmc_asmi/data/resource_variables.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/python
-
-r"""
-Contains xpaths and related string constants applicable to all openBMC GUI
-menus.
-"""
-
-
-class resource_variables():
-
- xpath_textbox_hostname = "//*[@id='login__form']/input[1]"
- xpath_textbox_username = "//*[@id='username']"
- xpath_textbox_password = "//*[@id='password']"
- xpath_button_login = "//*[@id='login__submit']"
- xpath_button_logout = "//*[@id='header']/a"
- xpath_display_server_power_status = \
- "//*[@id='header__wrapper']/div/div[3]/a[3]/span"
- xpath_select_button_orderly_power_shutdown = \
- "//*[@id='power__soft-shutdown']"
- xpath_select_button_orderly_power_shutdown_yes = \
- "//*[@id='power-operations']/div[3]/div[5]/confirm/div/div[2]/" \
- "button[1]"
- xpath_select_button_power_on = "//*[@id='power__power-on']"
-
- xpath_openbmc_url = "http://localhost:8080/#/login"
- xpath_openbmc_ip = "//*[@id='login__form']/input[1]"
- openbmc_username = "root"
- openbmc_password = "0penBmc"
-
- obmc_off_state = "Off"
- obmc_quiesced_state = "Quiesced"
- obmc_running_state = "Running"
-
- # Power operation elements needed for power on.
- header_wrapper = "3"
- header_wrapper_elt = "3"
-
- # Power operation elements needed for power operations confirmation.
- power_operations = "3"
- warm_boot = "3"
- cold_boot = "4"
- shut_down = "5"
- power_off = "6"
- confirm_msg = "2"
- yes = "1"
- no = "2"
-
diff --git a/gui/obmc_gui/data/resource_variables.py b/gui/obmc_gui/data/resource_variables.py
index 086bec1..6fd1de6 100644
--- a/gui/obmc_gui/data/resource_variables.py
+++ b/gui/obmc_gui/data/resource_variables.py
@@ -13,6 +13,8 @@
xpath_textbox_password = "//*[@id='password']"
xpath_button_login = "//*[@id='login__submit']"
xpath_button_logout = "//*[@id='header']/a"
+ xpath_openbmc_url = "http://localhost:8080/#/login"
+ xpath_openbmc_ip = "//*[@id='login__form']/input[1]"
xpath_display_server_power_status = \
"//*[@id='header__wrapper']/div/div[3]/a[3]/span"
xpath_select_button_orderly_power_shutdown = \
@@ -25,3 +27,17 @@
obmc_off_state = "Off"
obmc_quiesced_state = "Quiesced"
obmc_running_state = "Running"
+
+ # Power operation elements needed for power on.
+ header_wrapper = "3"
+ header_wrapper_elt = "3"
+
+ # Power operation elements needed for power operations confirmation.
+ power_operations = "3"
+ warm_boot = "3"
+ cold_boot = "4"
+ shut_down = "5"
+ power_off = "6"
+ confirm_msg = "2"
+ yes = "1"
+ No = "2"
diff --git a/gui/obmc_gui/lib/resource.robot b/gui/obmc_gui/lib/resource.robot
index c77bd01..29b676a 100644
--- a/gui/obmc_gui/lib/resource.robot
+++ b/gui/obmc_gui/lib/resource.robot
@@ -23,7 +23,7 @@
Variables ../data/resource_variables.py
*** Variables ***
-${obmc_gui_url} http://localhost:8080/#/login
+${openbmc_gui_url} http://localhost:8080/#/login
# Default Browser.
${default_browser} chrome
@@ -58,7 +58,7 @@
[Documentation] Open the browser with the URL and
... login on windows platform.
- ${BROWSER_ID}= Open Browser ${obmc_gui_url} ${default_browser}
+ ${BROWSER_ID}= Open Browser ${openbmc_gui_url} ${default_browser}
Maximize Browser Window
Set Global Variable ${BROWSER_ID}
@@ -66,7 +66,7 @@
[Documentation] Launch headless browser.
Start Virtual Display 1920 1080
- ${BROWSER_ID}= Open Browser ${obmc_gui_url}
+ ${BROWSER_ID}= Open Browser ${openbmc_gui_url}
Set Global Variable ${BROWSER_ID}
Set Window Size 1920 1080
@@ -78,12 +78,13 @@
# username The username.
# password The password.
- Go To ${obmc_gui_url}
+ Go To ${openbmc_gui_url}
Input Text ${xpath_textbox_hostname} ${OPENBMC_HOST}
Input Text ${xpath_textbox_username} ${username}
Input Password ${xpath_textbox_password} ${password}
- Click Button ${xpath_button_login}
+ Click Element login__submit
Wait Until Element Is Enabled ${xpath_button_logout}
+ Page Should Contain Server information
Test Setup Execution
@@ -179,3 +180,63 @@
Rprint Pgm Footer
Print Dashes 0 100 1 =
LogOut OpenBMC GUI
+
+Open Browser With URL
+ [Documentation] Open browser with specified URL and returns browser id.
+ [Arguments] ${URL} ${browser}=gc
+ # Description of argument(s):
+ # URL Openbmc GUI URL to be open
+ # (e.g. https://openbmc-test.mybluemix.net/#/login )
+ # browser browser used to open above URL
+ # (e.g. gc for google chrome, ff for firefox)
+ ${browser_ID}= Open Browser ${URL} ${browser}
+ [Return] ${browser_ID}
+
+Model Server Power Click Button
+ [Documentation] Click main server power in the header section.
+ [Arguments] ${div_element} ${anchor_element}
+ # Description of argument(s):
+ # div_element Server power header divisional element
+ # (e.g. header_wrapper.)
+ # anchor_element Server power header anchor element
+ # (e.g. header_wrapper_elt.)
+ Wait Until Element Is Visible
+ ... //*[@id='header__wrapper']/div/div[${div_element}]/a[${anchor_element}]/span
+ Click Element
+ ... //*[@id='header__wrapper']/div/div[${div_element}]/a[${anchor_element}]/span
+
+Controller Server Power Click Button
+ [Documentation] Click main server power in the header section.
+ [Arguments] ${controller_element}
+ # Description of argument(s):
+ # controller_element Server power controller element
+ # (e.g. power__power-on.)
+
+ Wait Until Element Is Visible ${controller_element}
+ Page Should Contain Button ${controller_element}
+ Click Element ${controller_element}
+
+Controller Power Operations Confirmation Click Button
+ [Documentation] Click Common Power Operations Confirmation.
+ [Arguments] ${main_element} ${sub_element} ${confirm_msg_elt} ${confirmation}
+ # Description of argument(s):
+ # main_element Server power operations element
+ # (e.g. power_operations.)
+ # sub_element Server power operations sub element
+ # (e.g. warm_boot, shut_down.)
+ # confirm_msg_elt Server power operations confirm message element
+ # (e.g. confirm_msg.)
+ # confirmation Server power operations confirmation
+ # (e.g. yes.)
+
+ Click Element
+ ... //*[@id='power-operations']/div[${main_element}]/div[${sub_element}]/confirm/div/div[${confirm_msg_elt}]/button[${confirmation}]
+
+GUI Power On
+ [Documentation] Power on the Host using GUI.
+
+ Model Server Power Click Button ${header_wrapper} ${header_wrapper_elt}
+ Page Should Contain Attempts to power on the server
+ Controller Server Power Click Button power__power-on
+ Page Should Contain Running
+
diff --git a/gui/obmc_gui/test/gui_header/test_obmc_gui_power_operations.robot b/gui/obmc_gui/test/gui_header/test_obmc_gui_power_operations.robot
index edb8b99..14079ec 100644
--- a/gui/obmc_gui/test/gui_header/test_obmc_gui_power_operations.robot
+++ b/gui/obmc_gui/test/gui_header/test_obmc_gui_power_operations.robot
@@ -2,9 +2,10 @@
Documentation Test Open BMC GUI Power Operations under GUI Header.
+Resource ../../../../lib/state_manager.robot
Resource ../../lib/resource.robot
-Suite Setup Login OpenBMC GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
+Suite Setup Login OpenBMC GUI with failure enable
Suite Teardown Close Browser
*** Test Cases ***
@@ -13,85 +14,110 @@
[Documentation] Power on the host.
[Tags] Power_On_the_Host
+ Expected Initial Test State Off
GUI Power On
+ Wait Until Keyword Succeeds 10 min 10 sec Is Host Running
+ Wait Until Page Contains Running
-Click Immediate Power Off The Host And Press No
- [Documentation] Click Immediate power off the host button and press no
- ... button.
- [Tags] Click_Immediate_Power_Off_The_Host_And_Press_No
+Click Immediate Shutdown Then No
+ [Documentation] Click the "Immediate shutdown" button and then click the
+ ... "No" button.
+ [Tags] Click_Immediate_Shutdown_Then_No
+ Expected Initial Test State Running
Controller Server Power Click Button power__hard-shutdown
Controller Power Operations Confirmation Click Button ${power_operations}
... ${power_off} ${confirm_msg} ${no}
- Page Should Contain Running
-Click Immediate Power Off The Host And Press Yes
- [Documentation] Click Immediate power off the host button and press
- ... yes button.
- [Tags] Click_Immediate_Power_Off_The_Host_And_Press_Yes
+ Is Host Running
+ Wait Until Page Contains Running
- Controller Server Power Click Button power__hard-shutdown
- Controller Power Operations Confirmation Click Button ${power_operations}
- ... ${power_off} ${confirm_msg} ${yes}
- Page Should Contain Off
+Click Cold Reboot Then No
+ [Documentation] Click the "Cold reboot" button and then click the "No"
+ ... button.
+ [Tags] Click_Cold_Reboot_Then_No
-Click Cold Boot The Host And Press No
- [Documentation] Click cold boot the host button and press no button.
- [Tags] Click_Cold_Boot_The_Host_And_Press_No
-
- GUI Power On
+ Expected Initial Test State Running
Controller Server Power Click Button power__cold-boot
Controller Power Operations Confirmation Click Button ${power_operations}
... ${cold_boot} ${confirm_msg} ${no}
+
+ Is Host Running
Page Should Contain Running
-Click Cold Boot The Host And Press Yes
- [Documentation] Click Cold boot the host button and press yes button.
- [Tags] Click_Cold_Boot_the_Host_And_Press_Yes
+Click Warm Reboot Then No
+ [Documentation] Click the "Warm reboot" button and then click the "No"
+ ... button.
+ [Tags] Click_Warm_Reboot_Then_No
+ Expected Initial Test State Running
+ Controller Server Power Click Button power__warm-boot
+ Controller Power Operations Confirmation Click Button ${power_operations}
+ ... ${warm_boot} ${confirm_msg} ${no}
+ Is Host Running
+ Page Should Contain Running
+
+Click Orderly Shutdown Then No
+ [Documentation] Click the "Orderly shutdown" button and then click the
+ ... "No" button.
+ [Tags] Click_Orderly_Shutdown_Then_No
+
+ Expected Initial Test State Running
+ Controller Server Power Click Button power__soft-shutdown
+ Controller Power Operations Confirmation Click Button ${power_operations}
+ ... ${shut_down} ${confirm_msg} ${no}
+ Wait Until Keyword Succeeds 10 min 10 sec Is Host Running
+ Page Should Contain Running
+
+Click Warm Reboot Then Yes
+ [Documentation] Click the "Warm reboot" button and then click the "Yes"
+ ... button.
+ [Tags] Click_Warm_Reboot_Then_Yes
+
+ Expected Initial Test State Running
+ Controller Server Power Click Button power__warm-boot
+ Controller Power Operations Confirmation Click Button ${power_operations}
+ ... ${warm_boot} ${confirm_msg} ${yes}
+ Wait Until Keyword Succeeds 10 min 10 sec Is Host Running
+ Page Should Contain Running
+
+Click Cold Reboot Then Yes
+ [Documentation] Click the "Cold reboot" button and then click the "Yes"
+ ... button.
+ [Tags] Click_Cold_Reboot_Then_Yes
+
+ Expected Initial Test State Running
Controller Server Power Click Button power__cold-boot
Controller Power Operations Confirmation Click Button ${power_operations}
... ${cold_boot} ${confirm_msg} ${yes}
Page Should Contain Standby
+ Wait Until Keyword Succeeds 10 min 10 sec Is Host Running
Page Should Contain Running
-Click Warm Boot The Host And Press No
- [Documentation] Click warm boot the host button and press no button.
- [Tags] Click_Warm_Boot_The_Host_And_Press_No
+Click Orderly Shutdown Then Yes
+ [Documentation] Click the "Orderly shutdown" button and then click the
+ ... "Yes" button.
+ [Tags] Click_Orderly_Shutdown_Then_Yes
- Controller Server Power Click Button power__warm-boot
- Controller Power Operations Confirmation Click Button ${power_operations}
- ... ${warm_boot} ${confirm_msg} ${no}
- Page Should Contain Running
-
-Click Warm Boot The Host And Press Yes
- [Documentation] Click warm boot the host button and press yes button.
- [Tags] Click_Warm_Boot_The_Host_And_Press_Yes
-
- Controller Server Power Click Button power__warm-boot
- Controller Power Operations Confirmation Click Button ${power_operations}
- ... ${warm_boot} ${confirm_msg} ${yes}
- Page Should Contain Running
-
-Click Orderly Shutdown The Host And Press No
- [Documentation] Press orderly shutdown the host button and press no
- ... button.
- [Tags] Click_Orderly_Shutdown_The_Host_And_Press_No
-
- Controller Server Power Click Button power__soft-shutdown
- Controller Power Operations Confirmation Click Button ${power_operations}
- ... ${shut_down} ${confirm_msg} ${no}
- Page Should Contain Running
-
-Click Orderly Shutdown The Host And Press Yes
- [Documentation] Press orderly shutdown the host button and press yes
- ... button.
- [Tags] Click_Orderly_Shutdown_The_Host_And_Press_Yes
-
+ Expected Initial Test State Running
Controller Server Power Click Button power__soft-shutdown
Controller Power Operations Confirmation Click Button ${power_operations}
... ${shut_down} ${confirm_msg} ${yes}
Page Should Contain Off
+ Wait Until Keyword Succeeds 6 min 10 sec Is Host Off
+
+Click Immediate Shutdown Then Yes
+ [Documentation] Click "Immediate shutdown" button and then click the "Yes"
+ ... button.
+ [Tags] Click_Immediate_Shutdown_Then_Yes
+
+ Expected Initial Test State Running
+ Controller Server Power Click Button power__hard-shutdown
+ Controller Power Operations Confirmation Click Button ${power_operations}
+ ... ${power_off} ${confirm_msg} ${yes}
+
+ Wait Until Page Contains Off
+ Wait Until Keyword Succeeds 6 min 10 sec Is Host Off
OpenBMC GUI Logoff
[Documentation] Log out from openBMC GUI.
@@ -101,6 +127,26 @@
Log To Console ${xpath_openbmc_url}
Click Element header
+*** Keywords ***
+
+Expected Initial Test State
+ [Documentation] Power on the host if "Running" expected, Power off the
+ ... host if "Off" expected as per the requirement of initial test state.
+ [Arguments] ${expectedState}
+ # Description of argument(s):
+ # expectedState Test initial host state.
+
+ Run Keyword If '${expectedState}' == 'Running'
+ ... Initiate Host Boot
+
+ Run Keyword If '${expectedState}' == 'Off'
+ ... Initiate Host PowerOff
+
+Login OpenBMC GUI with failure enable
+
+ Open Browser With URL ${xpath_openbmc_url}
+ Login OpenBMC GUI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
+