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