xref: /openbmc/openbmc-test-automation/systest/htx_softbootme_test.robot (revision 49c1b53931191184251a4d1d9ba9ab127ee9f9fb)
1*** Settings ***
2
3Documentation  Stress the system using HTX exerciser - bootme option.
4
5# Test Parameters:
6# OPENBMC_HOST        The BMC host name or IP address.
7# OS_HOST             The OS host name or IP Address.
8# OS_USERNAME         The OS login userid (usually root).
9# OS_PASSWORD         The password for the OS login.
10# HTX_DURATION        Duration of HTX run, for example, 2h, or 30m.
11# HTX_LOOP            The number of times to loop HTX.
12
13
14Resource        ../lib/htx_resource.robot
15Resource        ../lib/os_utilities.robot
16Library         ../lib/os_utils_keywords.py
17Resource        ../lib/openbmc_ffdc_utils.robot
18Library         ../lib/os_utilities.py
19Library         DateTime
20
21Suite Setup     Run Keyword And Ignore Error  Start SOL Console Logging
22Test Setup      Test Setup Execution
23Test Teardown   Test Teardown Execution
24
25Test Tags      HTX_Softbootme
26
27*** Variables ****
28
29${rest_keyword}     REST
30
31*** Test Cases ***
32
33Soft Bootme Test
34    [Documentation]  Using HTX exerciser soft boot option.
35    [Tags]  Soft_Bootme_Test
36
37    Printn
38    Rprint Vars   BOOTME_PERIOD   HTX_LOOP
39
40    # Set up the (soft) bootme iteration (loop) counter.
41    Set Suite Variable  ${iteration}  ${0}  children=true
42
43    # Run test
44    Repeat Keyword  ${HTX_LOOP} times  Run HTX Soft Bootme Exerciser
45
46
47*** Keywords ***
48
49
50Run HTX Soft Bootme Exerciser
51    [Documentation]  Run HTX Soft Bootme Exerciser.
52    # Test Flow:
53    # - Power on.
54    # - Create HTX mdt profile.
55    # - Run HTX exerciser.
56    # - Soft bootme (OS Reboot).
57    # - Check HTX status for errors.
58
59    # **********************************
60    # HTX bootme_period:
61    #        1 - every 20 minutes
62    #        2 - every 30 minutes
63    #        3 - every hour
64    #        4 - every midnight
65    # **********************************
66
67    # Set a boot interval based on the given boot me period.
68
69    ${boot_interval}=   Set Variable If
70    ...  ${BOOTME_PERIOD} == 1  20m
71    ...  ${BOOTME_PERIOD} == 2  30m
72    ...  ${BOOTME_PERIOD} == 3  1h
73
74    ${runtime}=  Convert Time  ${boot_interval}
75
76    ${startTime} =    Get Current Date
77    IF  '${HTX_MDT_PROFILE}' == 'mdt.bu'
78        Create Default MDT Profile
79    END
80
81    Run MDT Profile
82
83    Run Soft Bootme  ${BOOTME_PERIOD}
84
85    FOR    ${index}    IN RANGE    999999
86        ${l_ping}=
87        ...   Run Keyword And Return Status   Ping Host  ${OS_HOST}
88
89        IF   '${l_ping}' == '${False}'
90            Log to console   ("OS Host is rebooting")
91            # Wait for OS (re) Boot - Max 20 minutes
92            FOR   ${waitindex}   IN RANGE   40
93                Run Key U  Sleep \ 30s
94                ${l_ping}=
95                ...   Run Keyword And Return Status   Ping Host  ${OS_HOST}
96                IF  '${l_ping}' == '${True}'  BREAK
97            END
98
99            IF  '${l_ping}' == '${False}'  Fail  msg=OS not pinging in 20 minutes
100
101            Wait Until Keyword Succeeds
102            ...   2 min   30 sec   Verify Ping SSH And Redfish Authentication
103
104            Wait Until Keyword Succeeds
105            ...   3x  60 sec  OS Execute Command  uptime
106            Wait Until Keyword Succeeds
107            ...   1 min   30 sec   Check HTX Run Status
108
109            Set Suite Variable  ${iteration}  ${iteration + 1}
110            ${loop_count}=  Catenate  Completed reboot number: ${iteration}
111
112            Printn
113            Rprint Vars  loop_count
114        END
115
116        ${currentTime} =    Get Current Date
117        ${elapsedTimeSec} =
118        ...   Subtract Date From Date
119        ...   ${currentTime}   ${startTime}   result_format=number   exclude_millis=True
120        IF   ${runtime} < ${elapsedTimeSec}  BREAK
121    END
122
123    Wait Until Keyword Succeeds
124    ...   15 min   30 sec   Verify Ping SSH And Redfish Authentication
125
126    Wait Until Keyword Succeeds
127    ...   2 min  60 sec   Shutdown Bootme
128
129    # If user needs to keep the HTX running to debug on failure or post processing.
130    IF  ${HTX_KEEP_RUNNING} == ${0}
131        Wait Until Keyword Succeeds  2 min  60 sec   Shutdown HTX Exerciser
132    END
133
134
135Test Setup Execution
136    [Documentation]  Do the initial test setup.
137
138    ${bmc_version}  ${stderr}  ${rc}=  BMC Execute Command
139    ...  cat /etc/os-release
140    Printn
141    Rprint Vars  bmc_versionhtxcmdline -bootme
142
143    ${fw_version}=  Get BMC Version
144    Rprint Vars  fw_version
145
146    ${is_redfish}=  Run Keyword And Return Status  Redfish.Login
147    ${rest_keyword}=  Set Variable If  ${is_redfish}  Redfish  REST
148    Rprint Vars  rest_keyword
149    Set Suite Variable  ${rest_keyword}  children=true
150
151    Run Keyword  ${rest_keyword} Power On  stack_mode=skip
152
153    Run Key U  Sleep \ 15s
154    Run Keyword And Ignore Error  Delete All Error Logs
155    Run Keyword And Ignore Error  Redfish Purge Event Log
156    Tool Exist  htxcmdline
157
158    ${os_release_info}=  os_utilities.Get OS Release Info  uname
159    Rprint Vars  os_release_info  fmt=1
160
161    # Shutdown if HTX is running.
162    ${status}=  Is HTX Running
163    IF  '${status}' == 'True'
164        Wait Until Keyword Succeeds  2 min  60 sec   Shutdown HTX Exerciser
165    END
166
167
168Test Teardown Execution
169    [Documentation]  Do the post-test teardown.
170
171    # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
172    IF  '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
173        Wait Until Keyword Succeeds  2 min  60 sec   Shutdown HTX Exerciser
174    END
175
176    ${keyword_buf}=  Catenate  Stop SOL Console Logging
177    ...  \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
178    Run Keyword And Ignore Error   ${keyword_buf}
179
180    FFDC On Test Case Fail
181
182    Close All Connections
183