1*** Settings ***
2
3Documentation  Test OpenBMC GUI "Server power operations" sub-menu of "Operations".
4
5Resource        ../../lib/gui_resource.robot
6Resource        ../../../lib/state_manager.robot
7
8Test Setup      Run Keywords  Launch Browser And Login GUI  AND  Navigate to Server Power Operation Page
9Test Teardown   Close Browser
10
11
12*** Variables ***
13
14${xpath_server_power_heading}              //h1[text()="Server power operations"]
15${xpath_enable_onetime_boot_checkbox}      //*[contains(@class,'custom-checkbox')]
16${xpath_boot_option_select}                //*[@id='boot-option']
17${xpath_shutdown_button}                   //*[@data-test-id='serverPowerOperations-button-shutDown']
18${xpath_reboot_button}                     //*[@data-test-id='serverPowerOperations-button-reboot']
19${xpath_poweron_button}                    //*[@data-test-id='serverPowerOperations-button-powerOn']
20${xpath_save_button}                       //button[contains(text(),'Save')]
21${xpath_shutdown_orderly_radio}            //*[@data-test-id='serverPowerOperations-radio-shutdownOrderly']
22${xpath_shutdown_immediate_radio}          //*[@data-test-id='serverPowerOperations-radio-shutdownImmediate']
23${xpath_confirm_button}                    //button[contains(text(),'Confirm')]
24${xpath_current_power_state}               //*[@data-test-id='powerServerOps-text-hostStatus']
25${xpath_reboot_immediate_radio}            //*[@data-test-id='serverPowerOperations-radio-rebootImmediate']
26
27
28*** Test Cases ***
29
30Verify Navigation To Server Power Operations Page
31    [Documentation]  Verify navigation to server power operations page.
32    [Tags]  Verify_Navigation_To_Server_Power_Operations_Page
33
34    Page Should Contain Element  ${xpath_server_power_heading}
35
36
37Verify Immediate Shutdown
38    [Documentation]  Verify shutdown after clicking immediate shutdown button.
39    [Tags]  Verify_Immediate_Shutdown
40    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
41    ...  AND  Navigate to Server Power Operation Page
42
43    Click Element At Coordinates  ${xpath_shutdown_immediate_radio}  0  0
44    Click Element  ${xpath_shutdown_button}
45    Wait Until Page Contains Element  ${xpath_confirm_button}  timeout=10
46    Click Element  ${xpath_confirm_button}
47    Wait Until Keyword Succeeds  3 min  15 sec  Element Should Contain  ${xpath_current_power_state}  Off
48
49
50Verify Orderly Shutdown
51    [Documentation]  Verify shutdown after clicking orderly shutdown button.
52    [Tags]  Verify_Orderly_Shutdown
53    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
54    ...  AND  Navigate to Server Power Operation Page
55
56    Click Element At Coordinates  ${xpath_shutdown_orderly_radio}  0  0
57    Click Element  ${xpath_shutdown_button}
58    Wait Until Page Contains Element  ${xpath_confirm_button}  timeout=10
59    Click Element  ${xpath_confirm_button}
60    Wait Until Keyword Succeeds  10 min  15 sec  Element Should Contain  ${xpath_current_power_state}  Off
61
62
63Verify Existence Of All Sections In Server Power Operations Page
64    [Documentation]  Verify existence of all sections in Server Power Operations page.
65    [Tags]  Verify_Existence_Of_All_Sections_In_Server_Power_Operations_Page
66
67    # Added a delay for the page to load boot settings section.
68    Wait Until Page Contains  Server power operations  timeout=5
69    Page Should Contain  Current status
70    Page Should Contain  Operations
71    Page Should Contain  Settings
72
73
74Verify Existence Of All Input Boxes In Host Os Boot Settings
75    [Documentation]  Verify existence of all input boxes in host os boot settings.
76    [Tags]  Verify_Existence_Of_All_Input_Boxes_In_Host_Os_Boot_Settings
77
78    # Added a delay for the page to load boot settings section.
79    Wait Until Page Contains  Boot settings  timeout=5
80    Page Should Contain Element  ${xpath_enable_onetime_boot_checkbox}
81    Page Should Contain Element  ${xpath_boot_option_select}
82
83
84Verify System State At Power Off
85    [Documentation]  Verify state of the system in power off state.
86    [Tags]  Verify_System_State_At_Power_Off
87
88    Redfish Power Off  stack_mode=skip
89    Page Should Contain Element  ${xpath_current_power_state}
90    Element Should Contain   ${xpath_current_power_state}  Off
91
92
93Verify System State At Power On
94    [Documentation]  Verify state of the system in power on state.
95    [Tags]  Verify_System_State_At_Power_On
96    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
97    ...  AND  Navigate to Server Power Operation Page
98
99    Wait Until Keyword Succeeds  15 sec  5 sec   Element Should Contain   ${xpath_current_power_state}  On
100
101
102Verify PowerOn Button Should Present At Power Off
103    [Documentation]  Verify existence of poweron button at power off.
104    [Tags]  Verify_PowerOn_Button_Should_Present_At_Power_Off
105
106    Redfish Power Off  stack_mode=skip
107    # TODO: Implement power off using GUI later.
108    Page Should Contain Element  ${xpath_poweron_button}
109
110
111Verify Shutdown And Reboot Buttons Presence At Power On
112    [Documentation]  Verify existence of shutdown and reboot buttons at power on.
113    [Tags]  Verify_Shutdown_And_Reboot_Buttons_Presence_At_Power_On
114    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
115    ...  AND  Navigate to Server Power Operation Page
116
117    # TODO: Implement power on using GUI later.
118    Page Should Contain Element  ${xpath_shutdown_button}
119    Page Should Contain Element  ${xpath_reboot_button}
120
121
122Verify Host Immediate Reboot
123    [Documentation]  Verify host reboot after triggering immediate reboot.
124    [Tags]  Verify_Host_Immediate_Reboot
125    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
126    ...  AND  Navigate to Server Power Operation Page
127
128    Click Element At Coordinates  ${xpath_reboot_immediate_radio}  0  0
129    Click Element  ${xpath_reboot_button}
130    Wait Until Page Contains Element  ${xpath_confirm_button}  timeout=10
131    Click Element  ${xpath_confirm_button}
132    Wait Until Keyword Succeeds  3 min  2 sec  Element Should Contain  ${xpath_current_power_state}  Off
133    Click Element  ${xpath_refresh_button}
134    Wait Until Keyword Succeeds  10 min  15 sec  Element Should Contain  ${xpath_current_power_state}  On
135
136
137Verify Host Orderly Reboot
138    [Documentation]  Verify host reboot after triggering orderly reboot.
139    [Tags]  Verify_Host_Orderly_Reboot
140    [Setup]  Run Keywords  Redfish Power On  stack_mode=skip  AND  Launch Browser And Login GUI
141    ...  AND  Navigate to Server Power Operation Page
142
143    Click Element  ${xpath_reboot_button}
144    # Delay for confirm button to appear.
145    Sleep  5s
146    Wait Until Element Is Visible  ${xpath_confirm_button}  timeout=10
147    Click Element  ${xpath_confirm_button}
148    Wait Until Keyword Succeeds  2 min  1 sec  Is Server Status Off
149    Click Element  ${xpath_refresh_button}
150    Wait Until Keyword Succeeds  10 min  15 sec  Element Should Contain  ${xpath_current_power_state}  On
151
152
153*** Keywords ***
154
155Navigate to Server Power Operation Page
156    [Documentation]  Go to server power operation page.
157
158    Click Element  ${xpath_operations_menu}
159    Click Element  ${xpath_server_power_operations_sub_menu}
160    Wait Until Keyword Succeeds  30 sec  10 sec  Location Should Contain  server-power-operations
161    Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
162
163Is Server Status Off
164    [Documentation]  Perform GUI refresh and verify server status to Off.
165
166    Refresh GUI
167    Element Should Contain  ${xpath_current_power_state}  Off
168