1*** Settings ***
2
3Documentation  Test OpenBMC GUI "Overview" menu.
4
5Resource        ../../lib/gui_resource.robot
6Resource        ../../../lib/logging_utils.robot
7Resource        ../../../lib/list_utils.robot
8Resource        ../../../lib/bmc_network_utils.robot
9
10Library         String
11
12Suite Setup     Run Keywords  Launch Browser And Login GUI  AND  Redfish.Login
13Suite Teardown  Run Keywords  Close Browser  AND  Redfish.Logout
14Test Setup      Test Setup Execution
15
16
17*** Variables ***
18
19${xpath_overview_page_header}          //h1[contains(text(), "Overview")]
20${xpath_edit_network_settings_button}  (//*[text()="View more"])[3]
21${view_all_event_logs}                 (//*[text()="View more"])[5]
22${xpath_launch_host_console}           //*[@data-test-id='overviewQuickLinks-button-solConsole']
23${xpath_led_button}                    //*[@data-test-id='overviewInventory-checkbox-identifyLed']
24${view_all_Dumps}                      (//*[text()="View more"])[7]
25
26*** Test Cases ***
27
28Verify Existence Of All Sections In Overview Page
29    [Documentation]  Verify existence of all sections in Overview page.
30    [Tags]  Verify_Existence_Of_All_Sections_In_Overview_Page
31
32    Page Should Contain  BMC date and time
33    Page Should Contain  Firmware information
34    Page Should Contain  Server information
35    Wait Until Page Contains  Network information  timeout=10
36    Page Should Contain  Power information
37    Page Should Contain  Event logs
38    Page Should Contain  Inventory and LEDs
39    Page Should Contain  Dumps
40
41
42Verify Network Information In Overview Page
43    [Documentation]  Verify values under network information section.
44    [Tags]  Verify_Network_Information_In_Overview_Page
45
46    ${hostname}=  Get BMC Hostname
47    Page Should Contain  ${hostname}
48
49    # Get all IP addresses and prefix lengths on system.
50
51    ${resp}=  Redfish.Get Attribute  /redfish/v1/Managers/bmc/EthernetInterfaces/eth0  IPv4StaticAddresses
52    ${ip_addr}=  Set Variable  ${resp[0]['Address']}
53    Page Should Contain  ${ip_addr}
54
55
56Verify Server Information Section
57    [Documentation]  Verify values under server information section in overview page.
58    [Tags]  Verify_Server_Information_Section
59
60    ${redfish_machine_model}=  Redfish.Get Attribute  /redfish/v1/Systems/system/  Model
61    Page Should Contain  ${redfish_machine_model}
62
63    ${redfish_serial_number}=  Redfish.Get Attribute  /redfish/v1/Systems/system/  SerialNumber
64    Page Should Contain  ${redfish_serial_number}
65
66    ${redfish_motherboard_manufacturer}=  Redfish.Get Attribute
67    ...  /redfish/v1/Systems/system/  Manufacturer
68
69    Page Should Contain  ${redfish_motherboard_manufacturer}
70
71
72Verify BMC Information Section
73    [Documentation]  Verify BMC information section in overview page.
74    [Tags]  Verify_BMC_Information_Section
75
76    ${firmware_version}=  Redfish Get BMC Version
77    Page Should Contain  ${firmware_version}
78
79
80Verify Edit Network Setting Button
81    [Documentation]  Verify navigation to network setting page after clicking the button in overview page.
82    [Tags]  Verify_Edit_Network_Setting_Button
83
84    Click Element  ${xpath_edit_network_settings_button}
85    Wait Until Page Contains Element  ${xpath_network_page_header}
86
87
88Verify Event Under High Priority Events Section
89    [Documentation]  Verify event under high priority events section in case of any event.
90    [Tags]  Verify_Event_Under_High_Priority_Events_Section
91
92    Redfish Purge Event Log
93    Click Element  ${xpath_refresh_button}
94    Generate Test Error Log
95    Click Element  ${xpath_refresh_button}
96    Wait Until Page Contains  xyz.openbmc_project.Common.Error.InternalFailure  timeout=30s
97
98
99Verify View All Event Logs Button
100    [Documentation]  Verify view all event log button in overview page.
101    [Tags]  Verify_View_All_Event_Logs_Button
102
103    Generate Test Error Log
104    Page Should Contain Element  ${view_all_event_logs}  timeout=30
105    Click Element  ${view_all_event_logs}
106    Wait Until Page Contains Element  ${xpath_event_header}  timeout=30
107
108
109Verify Host Console Button In Overview Page
110    [Documentation]  Click host console button and verify page navigation to host console page.
111    [Tags]  Verify_Host_Console_Button_In_Overview_Page
112
113    Click Element  ${xpath_launch_host_console}
114    Wait Until Page Contains Element  ${xpath_host_console_heading}
115
116
117Verify Server LED Turn On
118    [Documentation]  Turn on server LED via GUI and verify its status via Redfish.
119    [Tags]  Verify_Server_LED_Turn_On
120
121    # Turn Off the server LED via Redfish and refresh GUI.
122    Set IndicatorLED State  Off
123
124    Refresh GUI
125
126    # Turn ON the LED via GUI.
127    Click Element At Coordinates  ${xpath_led_button}  0  0
128
129    # Cross check that server LED ON state via Redfish.
130    Verify Identify LED State Via Redfish  Lit
131
132
133Verify Server LED Turn Off
134    [Documentation]  Turn off server LED via GUI and verify its status via Redfish.
135    [Tags]  Verify_Server_LED_Turn_Off
136
137    # Turn On the server LED via Redfish and refresh GUI.
138    Set IndicatorLED State  Lit
139    Refresh GUI
140
141    # Turn OFF the LED via GUI.
142    Click Element At Coordinates  ${xpath_led_button}  0  0
143
144    # Cross check that server LED off state via Redfish.
145    Verify Identify LED State Via Redfish  Off
146
147
148Verify BMC Time In Overview Page
149    [Documentation]  Verify that BMC date from GUI matches with BMC time via Redfish.
150    [Tags]  Verify_BMC_Time_In_Overview_Page
151
152    ${date_time}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Managers/bmc  DateTime
153    ${converted_date}=  Convert Date  ${date_time}  result_format=%Y-%m-%d
154
155    Page Should Contain  ${converted_date}
156
157
158Verify BMC Information At Host Power Off State
159    [Documentation]  Verify that BMC information is displayed at host power off state.
160    [Tags]  Verify_BMC_Information_At_Host_Power_Off_State
161
162    Redfish Power Off  stack_mode=skip
163    ${firmware_version}=  Redfish Get BMC Version
164    Page Should Contain  ${firmware_version}
165
166
167Verify View More Button For Dumps
168    [Documentation]  Verify view more button for dumps button in overview page.
169    [Tags]  Verify_View_More_Button_For_Dumps
170
171    Wait Until Page Contains Element  ${view_all_Dumps}  timeout=30
172    Click Element  ${view_all_Dumps}
173    Wait Until Page Contains Element  ${xpath_dumps_header}   timeout=30
174
175*** Keywords ***
176
177Test Setup Execution
178    [Documentation]  Do test case setup tasks.
179
180    Click Element  ${xpath_overview_menu}
181    Wait Until Page Contains Element  ${xpath_overview_page_header}
182    Wait Until Element Is Not Visible   ${xpath_page_loading_progress_bar}  timeout=30
183
184
185Verify Identify LED State Via Redfish
186    [Documentation]  Verify that Redfish identify LED system with given state.
187    [Arguments]  ${expected_state}
188    # Description of argument(s):
189    # expected_state    Expected value of Identify LED.
190
191    # Python module:  get_member_list(resource_path)
192    ${systems}=  Redfish_Utils.Get Member List  /redfish/v1/Systems
193    FOR  ${system}  IN  @{systems}
194        ${led_value}=  Redfish.Get Attribute  ${system}  IndicatorLED
195        Should Be True  '${led_value}' == '${expected_state}'
196    END
197
198
199Set IndicatorLED State
200    [Documentation]  Perform redfish PATCH operation.
201    [Arguments]  ${led_state}  ${expect_resp_code}=[200, 204]
202    # Description of argument(s):
203    # led_state            IndicatorLED state to "off", "Lit" etc.
204    # expect_resp_code     Expected HTTPS response code. Default [200, 204]
205
206    # Python module:  get_member_list(resource_path)
207    ${systems}=  Redfish_Utils.Get Member List  /redfish/v1/Systems
208    FOR  ${system}  IN  @{systems}
209        Redfish.Patch  ${system}  body={"IndicatorLED":${led_state}}   valid_status_codes=${expect_resp_code}
210    END
211