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