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 10 minutes
81            FOR   ${waitindex}   IN RANGE   20
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            Wait Until Keyword Succeeds
89            ...   15 min   30 sec   Verify Ping and REST Authentication
90
91            # Give OS a minute from first ping for sshd to (re)start
92            Run Key U  Sleep \ 60s
93            OS Execute Command  uptime
94            Check HTX Run Status
95
96            Set Suite Variable  ${iteration}  ${iteration + 1}
97            ${loop_count}=  Catenate  Completed reboot number: ${iteration}
98
99            Printn
100            Rprint Vars  loop_count
101        END
102
103        ${currentTime} =    Get Current Date
104        ${elapsedTimeSec} =
105        ...   Subtract Date From Date
106        ...   ${currentTime}   ${startTime}   result_format=number   exclude_millis=True
107        Exit For Loop If   ${runtime} < ${elapsedTimeSec}
108    END
109
110    Wait Until Keyword Succeeds
111    ...   15 min   30 sec   Verify Ping and REST Authentication
112
113    Shutdown Bootme
114
115    # If user needs to keep the HTX running to debug on failure or post processing.
116    Run Keyword If  ${HTX_KEEP_RUNNING} == ${0}  Shutdown HTX Exerciser
117
118
119Test Setup Execution
120    [Documentation]  Do the initial test setup.
121
122    ${bmc_version}  ${stderr}  ${rc}=  BMC Execute Command
123    ...  cat /etc/os-release
124    Printn
125    Rprint Vars  bmc_versionhtxcmdline -bootme
126
127    ${fw_version}=  Get BMC Version
128    Rprint Vars  fw_version
129
130    ${is_redfish}=  Run Keyword And Return Status  Redfish.Login
131    ${rest_keyword}=  Set Variable If  ${is_redfish}  Redfish  REST
132    Rprint Vars  rest_keyword
133    Set Suite Variable  ${rest_keyword}  children=true
134
135    Run Keyword  ${rest_keyword} Power On  stack_mode=skip
136
137    Run Key U  Sleep \ 15s
138    Run Keyword And Ignore Error  Delete All Error Logs
139    Run Keyword And Ignore Error  Redfish Purge Event Log
140    Tool Exist  htxcmdline
141
142    ${os_release_info}=  utils_os.Get OS Release Info  uname
143    Rprint Vars  os_release_info  fmt=1
144
145    # Shutdown if HTX is running.
146    ${status}=  Is HTX Running
147    Run Keyword If  '${status}' == 'True'
148    ...  Shutdown HTX Exerciser
149
150
151Test Teardown Execution
152    [Documentation]  Do the post-test teardown.
153
154    # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
155    Run Keyword If
156    ...  '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
157    ...  Shutdown HTX Exerciser
158
159    ${keyword_buf}=  Catenate  Stop SOL Console Logging
160    ...  \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
161    Run Key  ${keyword_buf}
162
163    Close All Connections
164