blob: 853241c4f1bff9ff99388cdf4529a07fa8cf0283 [file] [log] [blame]
George Keishing8b082fd2017-05-03 13:42:39 -05001*** Settings ***
George Keishing8b082fd2017-05-03 13:42:39 -05002
Steven Sombar130a04f2017-07-16 10:02:37 -05003Documentation Stress the system using HTX exerciser.
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.
Steven Sombar2c97f812017-10-31 09:55:13 -050010# HTX_DURATION Duration of HTX run, for example, 2h, or 30m.
Steven Sombar130a04f2017-07-16 10:02:37 -050011# HTX_LOOP The number of times to loop HTX.
12# HTX_INTERVAL The time delay between consecutive checks of HTX
Steven Sombar2c97f812017-10-31 09:55:13 -050013# status, for example, 15m.
Steven Sombar130a04f2017-07-16 10:02:37 -050014# In summary: Run HTX for $HTX_DURATION, looping
Steven Sombar0278b132018-01-09 14:41:32 -060015# $HTX_LOOP times checking for errors every
16# $HTX_INTERVAL. Then allow extra time for OS
17# Boot, HTX startup, shutdown.
Steven Sombar130a04f2017-07-16 10:02:37 -050018# HTX_KEEP_RUNNING If set to 1, this indicates that the HTX is to
Steven Sombar2c97f812017-10-31 09:55:13 -050019# continue running after an error was found.
Steven Sombara2f166c2017-08-02 14:22:45 -050020# CHECK_INVENTORY If set to 0 or False, OS inventory checking before
21# and after each HTX run will be disabled. This
Steven Sombar2c97f812017-10-31 09:55:13 -050022# parameter is optional. The default value is True.
Steven Sombara2f166c2017-08-02 14:22:45 -050023# PREV_INV_FILE_PATH The file path and name of an initial previous
24# inventory snapshot file in JSON format. Inventory
25# snapshots taken before and after each HTX run will
26# be compared to this file.
Steven Sombar2c97f812017-10-31 09:55:13 -050027# This parameter is optional. If not specified an
Steven Sombara2f166c2017-08-02 14:22:45 -050028# initial inventory snapshot will be taken before
29# HTX startup.
Steven Sombarb6749a62017-10-06 08:34:23 -050030# INV_IGNORE_LIST A comma-delimited list of strings that
Steven Sombar48ad01d2017-08-17 14:17:37 -050031# indicate what to ignore if there are inventory
Steven Sombarb6749a62017-10-06 08:34:23 -050032# differences, (e.g., processor "size").
Steven Sombar48ad01d2017-08-17 14:17:37 -050033# If differences are found during inventory checking
Steven Sombarb6749a62017-10-06 08:34:23 -050034# and those items are in this list, the
Steven Sombar48ad01d2017-08-17 14:17:37 -050035# differences will be ignored. This parameter is
36# optional. If not specified the default value is
Steven Sombarb6749a62017-10-06 08:34:23 -050037# "size".
Steven Sombar130a04f2017-07-16 10:02:37 -050038
39Resource ../syslib/utils_os.robot
George Keishingdc1691d2017-12-07 12:17:46 -060040Resource ../lib/openbmc_ffdc_utils.robot
Steven Sombar3ecb6892018-03-23 11:41:08 -050041Resource ../lib/logging_utils.robot
Steven Sombar130a04f2017-07-16 10:02:37 -050042Library ../syslib/utils_keywords.py
Steven Sombarb6749a62017-10-06 08:34:23 -050043Library ../lib/utils_files.py
Steven Sombar3ecb6892018-03-23 11:41:08 -050044Library ../lib/logging_utils.py
George Keishingffbe8ce2017-05-04 12:08:54 -050045
Steven Sombar16dba512017-10-20 07:20:08 -050046Suite Setup Run Keyword Start SOL Console Logging
George Keishingdc1691d2017-12-07 12:17:46 -060047Test Setup Test Setup Execution
48Test Teardown Test Teardown Execution
George Keishing8b082fd2017-05-03 13:42:39 -050049
Steven Sombar6f9d41d2017-08-08 13:35:30 -050050
George Keishing8b082fd2017-05-03 13:42:39 -050051*** Variables ****
52
Steven Sombar130a04f2017-07-16 10:02:37 -050053${stack_mode} skip
Steven Sombar6f9d41d2017-08-08 13:35:30 -050054${json_initial_file_path} ${EXECDIR}/os_inventory_initial.json
55${json_final_file_path} ${EXECDIR}/os_inventory_final.json
56${json_diff_file_path} ${EXECDIR}/os_inventory_diff.json
Steven Sombara2f166c2017-08-02 14:22:45 -050057${CHECK_INVENTORY} True
Steven Sombarb6749a62017-10-06 08:34:23 -050058${INV_IGNORE_LIST} size
Steven Sombar2c97f812017-10-31 09:55:13 -050059${PREV_INV_FILE_PATH} NONE
George Keishingffbe8ce2017-05-04 12:08:54 -050060
Steven Sombar6f9d41d2017-08-08 13:35:30 -050061
George Keishing8b082fd2017-05-03 13:42:39 -050062*** Test Cases ***
63
64Hard Bootme Test
65 [Documentation] Stress the system using HTX exerciser.
George Keishingffbe8ce2017-05-04 12:08:54 -050066 [Tags] Hard_Bootme_Test
George Keishing8b082fd2017-05-03 13:42:39 -050067
Steven Sombar48ad01d2017-08-17 14:17:37 -050068 Rprintn
Steven Sombar2c97f812017-10-31 09:55:13 -050069 Rpvars HTX_DURATION HTX_LOOP HTX_INTERVAL CHECK_INVENTORY
70 ... INV_IGNORE_LIST PREV_INV_FILE_PATH
Steven Sombar48ad01d2017-08-17 14:17:37 -050071
Steven Sombar2c97f812017-10-31 09:55:13 -050072 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE'
73 ... OperatingSystem.File Should Exist ${PREV_INV_FILE_PATH}
Steven Sombar48ad01d2017-08-17 14:17:37 -050074
Steven Sombar2c97f812017-10-31 09:55:13 -050075 Set Suite Variable ${PREV_INV_FILE_PATH} children=true
Steven Sombar48ad01d2017-08-17 14:17:37 -050076 Set Suite Variable ${INV_IGNORE_LIST} children=true
Steven Sombar2c97f812017-10-31 09:55:13 -050077
78 # Set up the iteration (loop) counter.
Steven Sombar16dba512017-10-20 07:20:08 -050079 Set Suite Variable ${iteration} ${0} children=true
Steven Sombar130a04f2017-07-16 10:02:37 -050080
Steven Sombar2c97f812017-10-31 09:55:13 -050081 # Estimate the time required for a single iteration loop.
82 # HTX_DURATION + 10 minutes for OS boot, HTX startup, shutdown.
83 ${loop_body_seconds}= Add Time To Time ${HTX_DURATION} 10m
84 Set Suite Variable ${loop_body_seconds} children=true
85 # And save it in printable (compact) format.
86 ${estimated_loop_time}= Convert Time
87 ... ${loop_body_seconds} result_format=compact
88 Set Suite Variable ${estimated_loop_time} children=true
89
90 # Estimated time remaining = loop_body_seconds * HTX_LOOP + 5m
91 ${est_seconds_left}= Evaluate ${loop_body_seconds}*${HTX_LOOP}+(5*60)
92 Set Suite Variable ${est_seconds_left} children=true
93
Steven Sombar130a04f2017-07-16 10:02:37 -050094 Repeat Keyword ${HTX_LOOP} times Run HTX Exerciser
George Keishingffbe8ce2017-05-04 12:08:54 -050095
96
97*** Keywords ***
98
Steven Sombar16dba512017-10-20 07:20:08 -050099
Steven Sombar130a04f2017-07-16 10:02:37 -0500100Run HTX Exerciser
101 [Documentation] Run HTX exerciser.
George Keishingffbe8ce2017-05-04 12:08:54 -0500102 # Test Flow:
Steven Sombar130a04f2017-07-16 10:02:37 -0500103 # - Power on.
104 # - Establish SSH connection session.
105 # - Do inventory collection, compare with
106 # previous inventory run if applicable.
107 # - Create HTX mdt profile.
108 # - Run HTX exerciser.
109 # - Check HTX status for errors.
110 # - Do inventory collection, compare with
111 # previous inventory run.
112 # - Power off.
George Keishingffbe8ce2017-05-04 12:08:54 -0500113
Steven Sombar16dba512017-10-20 07:20:08 -0500114 Set Suite Variable ${iteration} ${iteration + 1}
115 ${loop_count}= Catenate Starting iteration: ${iteration}
Steven Sombar2c97f812017-10-31 09:55:13 -0500116 ${estimated_time_remaining}= Convert Time
117 ... ${est_seconds_left} result_format=compact
118 Rprintn
119 Rpvars loop_count estimated_loop_time estimated_time_remaining
Steven Sombar16dba512017-10-20 07:20:08 -0500120
Steven Sombar0278b132018-01-09 14:41:32 -0600121 REST Power On stack_mode=skip
George Keishingffbe8ce2017-05-04 12:08:54 -0500122
123 # Post Power off and on, the OS SSH session needs to be established.
George Keishing8b082fd2017-05-03 13:42:39 -0500124 Login To OS
125
Steven Sombara2f166c2017-08-02 14:22:45 -0500126 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500127 ... Do Inventory And Compare ${json_initial_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500128 ... ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500129
George Keishing13f44e52017-05-12 15:28:12 -0500130 Run Keyword If '${HTX_MDT_PROFILE}' == 'mdt.bu'
131 ... Create Default MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500132
George Keishing13f44e52017-05-12 15:28:12 -0500133 Run MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500134
135 Loop HTX Health Check
136
George Keishingffbe8ce2017-05-04 12:08:54 -0500137 Shutdown HTX Exerciser
138
Steven Sombara2f166c2017-08-02 14:22:45 -0500139 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500140 ... Do Inventory And Compare ${json_final_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500141 ... ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500142
Steven Sombar3ecb6892018-03-23 11:41:08 -0500143 # Terminate run if there are any BMC error logs.
144 ${error_logs}= Get Error Logs
145 ${num_logs}= Get Length ${error_logs}
146 Run Keyword If ${num_logs} != 0 Run Keywords
147 ... Print Error Logs ${error_logs}
148 ... AND Fail msg=Terminating run due to BMC error log(s).
149
George Keishingffbe8ce2017-05-04 12:08:54 -0500150 Power Off Host
151
George Keishingae5d9782017-06-12 13:35:59 -0500152 # Close all SSH and REST active sessions.
153 Close All Connections
154 Flush REST Sessions
155
George Keishingffbe8ce2017-05-04 12:08:54 -0500156 Rprint Timen HTX Test ran for: ${HTX_DURATION}
George Keishing8b082fd2017-05-03 13:42:39 -0500157
Steven Sombar16dba512017-10-20 07:20:08 -0500158 ${loop_count}= Catenate Ending iteration: ${iteration}
Steven Sombar2c97f812017-10-31 09:55:13 -0500159
160 ${est_seconds_left}= Evaluate ${est_seconds_left}-${loop_body_seconds}
161 Set Suite Variable ${est_seconds_left} children=true
162 ${estimated_time_remaining}= Convert Time
163 ... ${est_seconds_left} result_format=compact
164
165 Rpvars loop_count estimated_time_remaining
Steven Sombar16dba512017-10-20 07:20:08 -0500166
George Keishing13f44e52017-05-12 15:28:12 -0500167
Steven Sombara2f166c2017-08-02 14:22:45 -0500168Do Inventory And Compare
Steven Sombar130a04f2017-07-16 10:02:37 -0500169 [Documentation] Do inventory and compare.
Steven Sombar2c97f812017-10-31 09:55:13 -0500170 [Arguments] ${inventory_file_path} ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500171 # Description of argument(s):
Steven Sombar2c97f812017-10-31 09:55:13 -0500172 # inventory_file_path The file to receive the inventory snapshot.
173 # PREV_INV_FILE_PATH The previous inventory to compare with.
Steven Sombar130a04f2017-07-16 10:02:37 -0500174
175 Create JSON Inventory File ${inventory_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500176 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE'
Steven Sombar130a04f2017-07-16 10:02:37 -0500177 ... Compare Json Inventory Files ${inventory_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500178 ... ${PREV_INV_FILE_PATH}
179 ${PREV_INV_FILE_PATH}= Set Variable ${inventory_file_path}
180 Set Suite Variable ${PREV_INV_FILE_PATH} children=true
Steven Sombar130a04f2017-07-16 10:02:37 -0500181
182
183Compare Json Inventory Files
184 [Documentation] Compare JSON inventory files.
185 [Arguments] ${file1} ${file2}
186 # Description of argument(s):
187 # file1 A file that has an inventory snapshot in JSON format.
188 # file2 A file that has an inventory snapshot, to compare with file1.
189
Steven Sombarb6749a62017-10-06 08:34:23 -0500190 ${diff_rc}= File_Diff ${file1}
Steven Sombar48ad01d2017-08-17 14:17:37 -0500191 ... ${file2} ${json_diff_file_path} ${INV_IGNORE_LIST}
Steven Sombar130a04f2017-07-16 10:02:37 -0500192 Run Keyword If '${diff_rc}' != '${0}'
193 ... Report Inventory Mismatch ${diff_rc} ${json_diff_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500194 ... ELSE Rprint Timen Inventoy check: No differences found.
Steven Sombar130a04f2017-07-16 10:02:37 -0500195
196
197Report Inventory Mismatch
198 [Documentation] Report inventory mismatch.
199 [Arguments] ${diff_rc} ${json_diff_file_path}
200 # Description of argument(s):
201 # diff_rc The failing return code from the difference check.
202 # json_diff_file_path The file that has the latest inventory snapshot.
203
Steven Sombara2216d22017-08-09 12:18:00 -0500204 Log To Console Significant difference in inventory found, rc=${diff_rc}
205 Log To Console Differences are listed in file: no_newline=true
206 Log To Console ${json_diff_file_path}
207 Log To Console File Contents:
208 Wait Until Created ${json_diff_file_path}
209 ${file_contents}= OperatingSystem.Get File ${json_diff_file_path}
210 Log ${file_contents} level=WARN
211 Fail Significant difference in inventory found, rc=${diff_rc}
Steven Sombar130a04f2017-07-16 10:02:37 -0500212
213
George Keishing8b082fd2017-05-03 13:42:39 -0500214Loop HTX Health Check
George Keishingffbe8ce2017-05-04 12:08:54 -0500215 [Documentation] Run until HTX exerciser fails.
George Keishing8b082fd2017-05-03 13:42:39 -0500216 Repeat Keyword ${HTX_DURATION}
217 ... Run Keywords Check HTX Run Status
218 ... AND Sleep ${HTX_INTERVAL}
219
220
Steven Sombar0278b132018-01-09 14:41:32 -0600221Test Setup Execution
222 [Documentation] Do the initial test setup.
223
224 REST Power On stack_mode=skip
225 Delete All Error Logs
226 Tool Exist htxcmdline
227
228 # Shutdown if HTX is running.
Steven Sombar3ecb6892018-03-23 11:41:08 -0500229 ${status}= Is HTX Running
Steven Sombar0278b132018-01-09 14:41:32 -0600230 Run Keyword If '${status}' == 'True'
231 ... Shutdown HTX Exerciser
232
233
George Keishingdc1691d2017-12-07 12:17:46 -0600234Test Teardown Execution
George Keishingffbe8ce2017-05-04 12:08:54 -0500235 [Documentation] Do the post test teardown.
236 # 1. Shut down HTX exerciser if test Failed.
237 # 2. Capture FFDC on test failure.
238 # 3. Close all open SSH connections.
239
George Keishing1a23b692017-05-06 12:19:41 -0500240 # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
Steven Sombar130a04f2017-07-16 10:02:37 -0500241 Run Keyword If
242 ... '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
George Keishingffbe8ce2017-05-04 12:08:54 -0500243 ... Shutdown HTX Exerciser
244
George Keishingae5d9782017-06-12 13:35:59 -0500245 ${keyword_buf}= Catenate Stop SOL Console Logging
246 ... \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
247 Run Key ${keyword_buf}
248
George Keishingffbe8ce2017-05-04 12:08:54 -0500249 FFDC On Test Case Fail
250 Close All Connections