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   BOOTME_PERIOD   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    # **********************************
58    # HTX bootme_period:
59    #        1 - every 20 minutes
60    #        2 - every 30 minutes
61    #        3 - every hour
62    #        4 - every midnight
63    # **********************************
64
65    # Set a boot interval based on the given boot me period.
66
67    ${boot_interval}=   Set Variable If
68    ...  ${BOOTME_PERIOD} == 1  20m
69    ...  ${BOOTME_PERIOD} == 2  30m
70    ...  ${BOOTME_PERIOD} == 3  1h
71
72    ${runtime}=  Convert Time  ${boot_interval}
73
74    ${startTime} =    Get Current Date
75    Run Keyword If  '${HTX_MDT_PROFILE}' == 'mdt.bu'
76    ...  Create Default MDT Profile
77
78    Run MDT Profile
79
80    Run Soft Bootme  ${BOOTME_PERIOD}
81
82    FOR    ${index}    IN RANGE    999999
83        ${l_ping}=
84        ...   Run Keyword And Return Status   Ping Host  ${OS_HOST}
85
86        IF   '${l_ping}' == '${False}'
87            Log to console   ("OS Host is rebooting")
88            # Wait for OS (re) Boot - Max 20 minutes
89            FOR   ${waitindex}   IN RANGE   40
90                Run Key U  Sleep \ 30s
91                ${l_ping}=
92                ...   Run Keyword And Return Status   Ping Host  ${OS_HOST}
93                Exit For Loop If    '${l_ping}' == '${True}'
94            END
95
96            Run Keyword If  '${l_ping}' == '${False}'  Fail  msg=OS not pinging in 20 minutes
97
98            Wait Until Keyword Succeeds
99            ...   1 min   30 sec   Verify Ping SSH And Redfish Authentication
100
101            Wait Until Keyword Succeeds
102            ...   3x  60 sec  OS Execute Command  uptime
103            Wait Until Keyword Succeeds
104            ...   1 min   30 sec   Check HTX Run Status
105
106            Set Suite Variable  ${iteration}  ${iteration + 1}
107            ${loop_count}=  Catenate  Completed reboot number: ${iteration}
108
109            Printn
110            Rprint Vars  loop_count
111        END
112
113        ${currentTime} =    Get Current Date
114        ${elapsedTimeSec} =
115        ...   Subtract Date From Date
116        ...   ${currentTime}   ${startTime}   result_format=number   exclude_millis=True
117        Exit For Loop If   ${runtime} < ${elapsedTimeSec}
118    END
119
120    Wait Until Keyword Succeeds
121    ...   15 min   30 sec   Verify Ping SSH And Redfish Authentication
122
123    Wait Until Keyword Succeeds
124    ...   2 min  60 sec   Shutdown Bootme
125
126    # If user needs to keep the HTX running to debug on failure or post processing.
127    Run Keyword If  ${HTX_KEEP_RUNNING} == ${0}
128    ...  Wait Until Keyword Succeeds
129    ...     2 min  60 sec   Shutdown HTX Exerciser
130
131
132Test Setup Execution
133    [Documentation]  Do the initial test setup.
134
135    ${bmc_version}  ${stderr}  ${rc}=  BMC Execute Command
136    ...  cat /etc/os-release
137    Printn
138    Rprint Vars  bmc_versionhtxcmdline -bootme
139
140    ${fw_version}=  Get BMC Version
141    Rprint Vars  fw_version
142
143    ${is_redfish}=  Run Keyword And Return Status  Redfish.Login
144    ${rest_keyword}=  Set Variable If  ${is_redfish}  Redfish  REST
145    Rprint Vars  rest_keyword
146    Set Suite Variable  ${rest_keyword}  children=true
147
148    Run Keyword  ${rest_keyword} Power On  stack_mode=skip
149
150    Run Key U  Sleep \ 15s
151    Run Keyword And Ignore Error  Delete All Error Logs
152    Run Keyword And Ignore Error  Redfish Purge Event Log
153    Tool Exist  htxcmdline
154
155    ${os_release_info}=  utils_os.Get OS Release Info  uname
156    Rprint Vars  os_release_info  fmt=1
157
158    # Shutdown if HTX is running.
159    ${status}=  Is HTX Running
160    Run Keyword If  '${status}' == 'True'
161    ...  Wait Until Keyword Succeeds
162    ...     2 min  60 sec   Shutdown HTX Exerciser
163
164Test Teardown Execution
165    [Documentation]  Do the post-test teardown.
166
167    # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
168    Run Keyword If
169    ...  '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
170    ...      Wait Until Keyword Succeeds
171    ...        2 min  60 sec   Shutdown HTX Exerciser
172
173    ${keyword_buf}=  Catenate  Stop SOL Console Logging
174    ...  \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
175    Run Key  ${keyword_buf}
176
177    Close All Connections
178