1*** Settings *** 2 3Documentation 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. 10# HTX_DURATION Duration of HTX run, for example, 2h, or 30m. 11# HTX_LOOP The number of times to loop HTX. 12# HTX_INTERVAL The time delay between consecutive checks of HTX 13# status, for example, 15m. 14# In summary: Run HTX for $HTX_DURATION, looping 15# $HTX_LOOP times checking for errors every 16# $HTX_INTERVAL. Then allow extra time for OS 17# Boot, HTX startup, shutdown. 18# HTX_KEEP_RUNNING If set to 1, this indicates that the HTX is to 19# continue running after an error was found. 20# CHECK_INVENTORY If set to 0 or False, OS inventory checking before 21# and after each HTX run will be disabled. This 22# parameter is optional. The default value is True. 23# 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. 27# This parameter is optional. If not specified an 28# initial inventory snapshot will be taken before 29# HTX startup. 30# INV_IGNORE_LIST A comma-delimited list of strings that 31# indicate what to ignore if there are inventory 32# differences, (e.g., processor "size"). 33# If differences are found during inventory checking 34# and those items are in this list, the 35# differences will be ignored. This parameter is 36# optional. If not specified the default value is 37# "size". 38 39Resource ../syslib/utils_os.robot 40Resource ../lib/openbmc_ffdc_utils.robot 41Resource ../lib/logging_utils.robot 42Resource ../lib/code_update_utils.robot 43Library ../syslib/utils_keywords.py 44Library ../lib/utils_files.py 45Library ../lib/logging_utils.py 46Library ../syslib/utils_os.py 47 48Suite Setup Run Keyword Start SOL Console Logging 49Test Setup Test Setup Execution 50Test Teardown Test Teardown Execution 51 52 53*** Variables **** 54 55${stack_mode} skip 56${json_initial_file_path} ${EXECDIR}/os_inventory_initial.json 57${json_final_file_path} ${EXECDIR}/os_inventory_final.json 58${json_diff_file_path} ${EXECDIR}/os_inventory_diff.json 59${CHECK_INVENTORY} True 60${INV_IGNORE_LIST} size 61${PREV_INV_FILE_PATH} NONE 62 63${rest_keyword} REST 64 65# Error log Severities to ignore when checking for eSELs. 66@{ESEL_WHITELIST} 67... xyz.openbmc_project.Logging.Entry.Level.Informational 68 69 70*** Test Cases *** 71 72Hard Bootme Test 73 [Documentation] Stress the system using HTX exerciser. 74 [Tags] Hard_Bootme_Test 75 76 Printn 77 Rprint Vars HTX_DURATION HTX_LOOP HTX_INTERVAL CHECK_INVENTORY 78 ... INV_IGNORE_LIST PREV_INV_FILE_PATH 79 80 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE' 81 ... OperatingSystem.File Should Exist ${PREV_INV_FILE_PATH} 82 83 Set Suite Variable ${PREV_INV_FILE_PATH} children=true 84 Set Suite Variable ${INV_IGNORE_LIST} children=true 85 86 # Set up the iteration (loop) counter. 87 Set Suite Variable ${iteration} ${0} children=true 88 89 # Estimate the time required for a single iteration loop. 90 # HTX_DURATION + 10 minutes for OS boot, HTX startup, shutdown. 91 ${loop_body_seconds}= Add Time To Time ${HTX_DURATION} 10m 92 Set Suite Variable ${loop_body_seconds} children=true 93 # And save it in printable (compact) format. 94 ${estimated_loop_time}= Convert Time 95 ... ${loop_body_seconds} result_format=compact 96 Set Suite Variable ${estimated_loop_time} children=true 97 98 # Estimated time remaining = loop_body_seconds * HTX_LOOP + 5m 99 ${est_seconds_left}= Evaluate ${loop_body_seconds}*${HTX_LOOP}+(5*60) 100 Set Suite Variable ${est_seconds_left} children=true 101 102 Repeat Keyword ${HTX_LOOP} times Run HTX Exerciser 103 104 105*** Keywords *** 106 107 108Run HTX Exerciser 109 [Documentation] Run HTX exerciser. 110 # Test Flow: 111 # - Power on. 112 # - Establish SSH connection session. 113 # - Do inventory collection, compare with 114 # previous inventory run if applicable. 115 # - Create HTX mdt profile. 116 # - Run HTX exerciser. 117 # - Check HTX status for errors. 118 # - Do inventory collection, compare with 119 # previous inventory run. 120 # - Power off. 121 122 Set Suite Variable ${iteration} ${iteration + 1} 123 ${loop_count}= Catenate Starting iteration: ${iteration} 124 ${estimated_time_remaining}= Convert Time 125 ... ${est_seconds_left} result_format=compact 126 Printn 127 Rprint Vars loop_count estimated_loop_time estimated_time_remaining 128 129 Run Keyword ${rest_keyword} Power On stack_mode=skip 130 Run Key U Sleep \ 15s 131 132 # Post Power off and on, the OS SSH session needs to be established. 133 Login To OS 134 135 Run Keyword If '${CHECK_INVENTORY}' == 'True' 136 ... Do Inventory And Compare ${json_initial_file_path} 137 ... ${PREV_INV_FILE_PATH} 138 139 Run Keyword If '${HTX_MDT_PROFILE}' == 'mdt.bu' 140 ... Create Default MDT Profile 141 142 Run MDT Profile 143 144 Loop HTX Health Check 145 146 Shutdown HTX Exerciser 147 148 Run Keyword If '${CHECK_INVENTORY}' == 'True' 149 ... Do Inventory And Compare ${json_final_file_path} 150 ... ${PREV_INV_FILE_PATH} 151 152 Run Keyword ${rest_keyword} Power Off 153 154 # Close all SSH and REST active sessions. 155 Close All Connections 156 Flush REST Sessions 157 158 Print Timen HTX Test ran for: ${HTX_DURATION} 159 160 ${loop_count}= Catenate Ending iteration: ${iteration} 161 162 ${est_seconds_left}= Evaluate ${est_seconds_left}-${loop_body_seconds} 163 Set Suite Variable ${est_seconds_left} children=true 164 ${estimated_time_remaining}= Convert Time 165 ... ${est_seconds_left} result_format=compact 166 167 Rprint Vars loop_count estimated_time_remaining 168 169 170Do Inventory And Compare 171 [Documentation] Do inventory and compare. 172 [Arguments] ${inventory_file_path} ${PREV_INV_FILE_PATH} 173 # Description of argument(s): 174 # inventory_file_path The file to receive the inventory snapshot. 175 # PREV_INV_FILE_PATH The previous inventory to compare with. 176 177 Create JSON Inventory File ${inventory_file_path} 178 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE' 179 ... Compare Json Inventory Files ${inventory_file_path} 180 ... ${PREV_INV_FILE_PATH} 181 ${PREV_INV_FILE_PATH}= Set Variable ${inventory_file_path} 182 Set Suite Variable ${PREV_INV_FILE_PATH} children=true 183 184 185Compare Json Inventory Files 186 [Documentation] Compare JSON inventory files. 187 [Arguments] ${file1} ${file2} 188 # Description of argument(s): 189 # file1 A file that has an inventory snapshot in JSON format. 190 # file2 A file that has an inventory snapshot, to compare with file1. 191 192 ${diff_rc}= File_Diff ${file1} 193 ... ${file2} ${json_diff_file_path} ${INV_IGNORE_LIST} 194 Run Keyword If '${diff_rc}' != '${0}' 195 ... Report Inventory Mismatch ${diff_rc} ${json_diff_file_path} 196 ... ELSE Print Timen Inventoy check: No differences found. 197 198 199Report Inventory Mismatch 200 [Documentation] Report inventory mismatch. 201 [Arguments] ${diff_rc} ${json_diff_file_path} 202 # Description of argument(s): 203 # diff_rc The failing return code from the difference check. 204 # json_diff_file_path The file that has the latest inventory snapshot. 205 206 Log To Console Significant difference in inventory found, rc=${diff_rc} 207 Log To Console Differences are listed in file: no_newline=true 208 Log To Console ${json_diff_file_path} 209 Log To Console File Contents: 210 Wait Until Created ${json_diff_file_path} 211 ${file_contents}= OperatingSystem.Get File ${json_diff_file_path} 212 Log ${file_contents} level=WARN 213 Fail Significant difference in inventory found, rc=${diff_rc} 214 215 216Check For ESELs 217 [Documentation] Terminate if eSELs with Severity field not on WHITELIST. 218 219 Print Timen Checking eSEL Error Logs. 220 ${error_logs}= Get Error Logs 221 222 ${num_error_logs}= Get Length ${error_logs} 223 Rprint Vars num_error_logs 224 Return From Keyword If ${num_error_logs} == ${0} 225 226 Print Error Logs ${error_logs} 227 228 # Get a list of the severities of the error logs. 229 ${error_log_severities}= Nested Get Severity ${error_logs} 230 # Subtract the WHITELIST from the error_log_severities. 231 ${problem_error_logs}= 232 ... Evaluate list(set($error_log_severities) - set($ESEL_WHITELIST)) 233 ${num_error_logs_not_on_whitelist}= Get Length ${problem_error_logs} 234 235 Return From Keyword If ${num_error_logs_not_on_whitelist} == ${0} 236 237 Rprint Vars ESEL_WHITELIST 238 Fail msg=Found error logs with Severity not matching ESEL_WHITELIST. 239 240 241Loop HTX Health Check 242 [Documentation] Run until HTX exerciser fails. 243 Repeat Keyword ${HTX_DURATION} 244 ... Run Keywords Check HTX Run Status 245 ... AND Check For ESELs 246 ... AND Sleep ${HTX_INTERVAL} 247 248 249Test Setup Execution 250 [Documentation] Do the initial test setup. 251 252 ${bmc_version} ${stderr} ${rc}= BMC Execute Command 253 ... cat /etc/os-release 254 Printn 255 Rprint Vars bmc_version 256 257 ${pnor_version}= Get Host Software Objects Details 258 Rprint Vars pnor_version 259 260 ${is_redfish}= Run Keyword And Return Status Redfish.Login 261 ${rest_keyword}= Set Variable If ${is_redfish} Redfish REST 262 Rprint Vars rest_keyword 263 Set Suite Variable ${rest_keyword} children=true 264 265 Run Keyword ${rest_keyword} Power On stack_mode=skip 266 267 Run Key U Sleep \ 15s 268 Delete All Error Logs 269 Tool Exist htxcmdline 270 271 ${os_release_info}= Get OS Release Info 272 Rprint Vars os_release_info fmt=1 273 274 # Shutdown if HTX is running. 275 ${status}= Is HTX Running 276 Run Keyword If '${status}' == 'True' 277 ... Shutdown HTX Exerciser 278 279 280Test Teardown Execution 281 [Documentation] Do the post-test teardown. 282 283 # Keep HTX running if user set HTX_KEEP_RUNNING to 1. 284 Run Keyword If 285 ... '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0} 286 ... Shutdown HTX Exerciser 287 288 ${keyword_buf}= Catenate Stop SOL Console Logging 289 ... \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log 290 Run Key ${keyword_buf} 291 292 FFDC On Test Case Fail 293 Close All Connections 294