1*** Settings ***
2Documentation  Test for HW CI.
3
4Library             DateTime
5
6Resource            ../../lib/utils.robot
7Resource            ../../lib/ipmi_client.robot
8Resource            ../../lib/boot_utils.robot
9Resource            ../../lib/openbmc_ffdc.robot
10Resource            ../../lib/bmc_redfish_resource.robot
11
12Test Setup          Test Setup Execution
13Test Teardown       FFDC On Test Case Fail
14
15*** Variables ***
16
17# Error strings to check from journald.
18${ERROR_REGEX}     SEGV|core-dump|FAILURE|Failed to start
19${STANDBY_REGEX}   Startup finished in
20
21# 3 minutes standby boot time.
22${startup_time_threshold}  180
23
24*** Test Cases ***
25
26Verify Application Services Running At Standby
27    [Documentation]  Check if there are services that have not completed.
28    [Tags]  Verify_Application_Services_Running_At_Standby
29
30    # Application services running on the BMC are not tightly coupled.
31    # At standby, there shouldn't be any pending job waiting to complete.
32    # Examples:
33    # Failure o/p:
34    # root@witherspoon:~# systemctl list-jobs --no-pager | cat
35    #    JOB UNIT                                     TYPE  STATE
36    # 35151 xyz.openbmc_project.ObjectMapper.service start running
37    # 1 jobs listed.
38    #
39    # Success o/p:
40    # root@witherspoon:~# systemctl list-jobs --no-pager | cat
41    # No jobs running.
42
43    Redfish Hard Power Off
44    ${stdout}  ${stderr}  ${rc}=  BMC Execute Command
45    ...  systemctl list-jobs --no-pager | cat
46    Should Be Equal As Strings  ${stdout}  No jobs running.
47
48
49Verify Front And Rear LED At Standby
50    [Documentation]  Front and Rear LED should be off at standby.
51    [Tags]  Verify_Front_And_Rear_LED_At_Standby
52
53    Redfish Power Off  stack_mode=skip  quiet=1
54    Verify Identify LED State  ${0}
55
56
57Check For Application Failures
58    [Documentation]  Parse the journal log and check for failures.
59    [Tags]  Check_For_Application_Failures
60
61    Check For Regex In Journald  ${ERROR_REGEX}  error_check=${0}  boot=-b
62
63
64Verify Uptime Average Against Threshold
65    [Documentation]  Compare BMC average boot time to a constant threshold.
66    [Tags]  Verify_Uptime_Average_Against_Threshold
67
68    Redfish OBMC Reboot (off)
69
70    Wait Until Keyword Succeeds
71    ...  1 min  30 sec  Check BMC Uptime Journald
72
73
74Test SSH And IPMI Connections
75    [Documentation]  Try SSH and IPMI commands to verify each connection.
76    [Tags]  Test_SSH_And_IPMI_Connections
77
78    BMC Execute Command  true
79    Run IPMI Standard Command  chassis status
80
81
82*** Keywords ***
83
84Test Setup Execution
85   [Documentation]  Do test case setup tasks.
86
87   Printn
88   Redfish.Login
89
90
91Check BMC Uptime Journald
92    [Documentation]  Check BMC journald uptime entry.
93
94    # Example output:
95    # Startup finished in 10.074s (kernel) + 2min 23.506s (userspace) = 2min 33.581s.
96    ${startup_time}  ${stderr}  ${rc}=  BMC Execute Command
97    ...  journalctl --no-pager | egrep '${STANDBY_REGEX}' | tail -1
98    Should Not Be Empty  ${startup_time}
99
100    # Example time conversion:
101    # Get the "2min 33.581s" string total time taken to reach standby.
102    # Convert time "2min 33.581s" to unit 153.581.
103    ${startup_time}=  Convert Time  ${startup_time.split("= ",1)[1].strip(".")}
104
105    Should Be True  ${startup_time} < ${startup_time_threshold}
106    ...  msg=${startup_time} greater than threshold value of ${startup_time_threshold}.
107