xref: /openbmc/openbmc-test-automation/systest/htx_softbootme_test.robot (revision bee71fa0128b18b954f404eeaf40d7e128391937)
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    Wait Until Keyword Succeeds
116    ...   2 min  60 sec   Shutdown Bootme
117
118    # If user needs to keep the HTX running to debug on failure or post processing.
119    Run Keyword If  ${HTX_KEEP_RUNNING} == ${0}
120    ...  Wait Until Keyword Succeeds
121    ...     2 min  60 sec   Shutdown HTX Exerciser
122
123
124Test Setup Execution
125    [Documentation]  Do the initial test setup.
126
127    ${bmc_version}  ${stderr}  ${rc}=  BMC Execute Command
128    ...  cat /etc/os-release
129    Printn
130    Rprint Vars  bmc_versionhtxcmdline -bootme
131
132    ${fw_version}=  Get BMC Version
133    Rprint Vars  fw_version
134
135    ${is_redfish}=  Run Keyword And Return Status  Redfish.Login
136    ${rest_keyword}=  Set Variable If  ${is_redfish}  Redfish  REST
137    Rprint Vars  rest_keyword
138    Set Suite Variable  ${rest_keyword}  children=true
139
140    Run Keyword  ${rest_keyword} Power On  stack_mode=skip
141
142    Run Key U  Sleep \ 15s
143    Run Keyword And Ignore Error  Delete All Error Logs
144    Run Keyword And Ignore Error  Redfish Purge Event Log
145    Tool Exist  htxcmdline
146
147    ${os_release_info}=  utils_os.Get OS Release Info  uname
148    Rprint Vars  os_release_info  fmt=1
149
150    # Shutdown if HTX is running.
151    ${status}=  Is HTX Running
152    Run Keyword If  '${status}' == 'True'
153    ...  Shutdown HTX Exerciser
154
155
156Test Teardown Execution
157    [Documentation]  Do the post-test teardown.
158
159    # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
160    Run Keyword If
161    ...  '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
162    ...  Shutdown HTX Exerciser
163
164    ${keyword_buf}=  Catenate  Stop SOL Console Logging
165    ...  \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
166    Run Key  ${keyword_buf}
167
168    Close All Connections
169