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