blob: 8ad67391b24ed4bdd7fc105a7ebaf3dd447d46e9 [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
George Keishing559f8382018-10-28 02:17:49 -050042Resource ../lib/code_update_utils.robot
Steven Sombar130a04f2017-07-16 10:02:37 -050043Library ../syslib/utils_keywords.py
Steven Sombarb6749a62017-10-06 08:34:23 -050044Library ../lib/utils_files.py
Steven Sombar3ecb6892018-03-23 11:41:08 -050045Library ../lib/logging_utils.py
Steven Sombare0be9152018-08-08 08:22:53 -050046Library ../syslib/utils_os.py
George Keishingffbe8ce2017-05-04 12:08:54 -050047
Steven Sombar16dba512017-10-20 07:20:08 -050048Suite Setup Run Keyword Start SOL Console Logging
George Keishingdc1691d2017-12-07 12:17:46 -060049Test Setup Test Setup Execution
50Test Teardown Test Teardown Execution
George Keishing8b082fd2017-05-03 13:42:39 -050051
Steven Sombar6f9d41d2017-08-08 13:35:30 -050052
George Keishing8b082fd2017-05-03 13:42:39 -050053*** Variables ****
54
Steven Sombar130a04f2017-07-16 10:02:37 -050055${stack_mode} skip
Steven Sombar6f9d41d2017-08-08 13:35:30 -050056${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
Steven Sombara2f166c2017-08-02 14:22:45 -050059${CHECK_INVENTORY} True
Steven Sombarb6749a62017-10-06 08:34:23 -050060${INV_IGNORE_LIST} size
Steven Sombar2c97f812017-10-31 09:55:13 -050061${PREV_INV_FILE_PATH} NONE
George Keishingffbe8ce2017-05-04 12:08:54 -050062
Steven Sombar6f9d41d2017-08-08 13:35:30 -050063
George Keishing8b082fd2017-05-03 13:42:39 -050064*** Test Cases ***
65
66Hard Bootme Test
67 [Documentation] Stress the system using HTX exerciser.
George Keishingffbe8ce2017-05-04 12:08:54 -050068 [Tags] Hard_Bootme_Test
George Keishing8b082fd2017-05-03 13:42:39 -050069
Steven Sombar48ad01d2017-08-17 14:17:37 -050070 Rprintn
Steven Sombar2c97f812017-10-31 09:55:13 -050071 Rpvars HTX_DURATION HTX_LOOP HTX_INTERVAL CHECK_INVENTORY
72 ... INV_IGNORE_LIST PREV_INV_FILE_PATH
Steven Sombar48ad01d2017-08-17 14:17:37 -050073
Steven Sombar2c97f812017-10-31 09:55:13 -050074 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE'
75 ... OperatingSystem.File Should Exist ${PREV_INV_FILE_PATH}
Steven Sombar48ad01d2017-08-17 14:17:37 -050076
Steven Sombar2c97f812017-10-31 09:55:13 -050077 Set Suite Variable ${PREV_INV_FILE_PATH} children=true
Steven Sombar48ad01d2017-08-17 14:17:37 -050078 Set Suite Variable ${INV_IGNORE_LIST} children=true
Steven Sombar2c97f812017-10-31 09:55:13 -050079
80 # Set up the iteration (loop) counter.
Steven Sombar16dba512017-10-20 07:20:08 -050081 Set Suite Variable ${iteration} ${0} children=true
Steven Sombar130a04f2017-07-16 10:02:37 -050082
Steven Sombar2c97f812017-10-31 09:55:13 -050083 # Estimate the time required for a single iteration loop.
84 # HTX_DURATION + 10 minutes for OS boot, HTX startup, shutdown.
85 ${loop_body_seconds}= Add Time To Time ${HTX_DURATION} 10m
86 Set Suite Variable ${loop_body_seconds} children=true
87 # And save it in printable (compact) format.
88 ${estimated_loop_time}= Convert Time
89 ... ${loop_body_seconds} result_format=compact
90 Set Suite Variable ${estimated_loop_time} children=true
91
92 # Estimated time remaining = loop_body_seconds * HTX_LOOP + 5m
93 ${est_seconds_left}= Evaluate ${loop_body_seconds}*${HTX_LOOP}+(5*60)
94 Set Suite Variable ${est_seconds_left} children=true
95
Steven Sombar130a04f2017-07-16 10:02:37 -050096 Repeat Keyword ${HTX_LOOP} times Run HTX Exerciser
George Keishingffbe8ce2017-05-04 12:08:54 -050097
98
99*** Keywords ***
100
Steven Sombar16dba512017-10-20 07:20:08 -0500101
Steven Sombar130a04f2017-07-16 10:02:37 -0500102Run HTX Exerciser
103 [Documentation] Run HTX exerciser.
George Keishingffbe8ce2017-05-04 12:08:54 -0500104 # Test Flow:
Steven Sombar130a04f2017-07-16 10:02:37 -0500105 # - Power on.
106 # - Establish SSH connection session.
107 # - Do inventory collection, compare with
108 # previous inventory run if applicable.
109 # - Create HTX mdt profile.
110 # - Run HTX exerciser.
111 # - Check HTX status for errors.
112 # - Do inventory collection, compare with
113 # previous inventory run.
114 # - Power off.
George Keishingffbe8ce2017-05-04 12:08:54 -0500115
Steven Sombar16dba512017-10-20 07:20:08 -0500116 Set Suite Variable ${iteration} ${iteration + 1}
117 ${loop_count}= Catenate Starting iteration: ${iteration}
Steven Sombar2c97f812017-10-31 09:55:13 -0500118 ${estimated_time_remaining}= Convert Time
119 ... ${est_seconds_left} result_format=compact
120 Rprintn
121 Rpvars loop_count estimated_loop_time estimated_time_remaining
Steven Sombar16dba512017-10-20 07:20:08 -0500122
Steven Sombar0278b132018-01-09 14:41:32 -0600123 REST Power On stack_mode=skip
Steven Sombar1ddc7c62018-06-01 11:55:34 -0500124 Run Key U Sleep \ 15s
George Keishingffbe8ce2017-05-04 12:08:54 -0500125
126 # Post Power off and on, the OS SSH session needs to be established.
George Keishing8b082fd2017-05-03 13:42:39 -0500127 Login To OS
128
Steven Sombara2f166c2017-08-02 14:22:45 -0500129 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500130 ... Do Inventory And Compare ${json_initial_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500131 ... ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500132
George Keishing13f44e52017-05-12 15:28:12 -0500133 Run Keyword If '${HTX_MDT_PROFILE}' == 'mdt.bu'
134 ... Create Default MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500135
George Keishing13f44e52017-05-12 15:28:12 -0500136 Run MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500137
138 Loop HTX Health Check
139
George Keishingffbe8ce2017-05-04 12:08:54 -0500140 Shutdown HTX Exerciser
141
Steven Sombara2f166c2017-08-02 14:22:45 -0500142 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500143 ... Do Inventory And Compare ${json_final_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500144 ... ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500145
Steven Sombar3ecb6892018-03-23 11:41:08 -0500146 # Terminate run if there are any BMC error logs.
147 ${error_logs}= Get Error Logs
148 ${num_logs}= Get Length ${error_logs}
149 Run Keyword If ${num_logs} != 0 Run Keywords
150 ... Print Error Logs ${error_logs}
151 ... AND Fail msg=Terminating run due to BMC error log(s).
152
George Keishingffbe8ce2017-05-04 12:08:54 -0500153 Power Off Host
154
George Keishingae5d9782017-06-12 13:35:59 -0500155 # Close all SSH and REST active sessions.
156 Close All Connections
157 Flush REST Sessions
158
George Keishingffbe8ce2017-05-04 12:08:54 -0500159 Rprint Timen HTX Test ran for: ${HTX_DURATION}
George Keishing8b082fd2017-05-03 13:42:39 -0500160
Steven Sombar16dba512017-10-20 07:20:08 -0500161 ${loop_count}= Catenate Ending iteration: ${iteration}
Steven Sombar2c97f812017-10-31 09:55:13 -0500162
163 ${est_seconds_left}= Evaluate ${est_seconds_left}-${loop_body_seconds}
164 Set Suite Variable ${est_seconds_left} children=true
165 ${estimated_time_remaining}= Convert Time
166 ... ${est_seconds_left} result_format=compact
167
168 Rpvars loop_count estimated_time_remaining
Steven Sombar16dba512017-10-20 07:20:08 -0500169
George Keishing13f44e52017-05-12 15:28:12 -0500170
Steven Sombara2f166c2017-08-02 14:22:45 -0500171Do Inventory And Compare
Steven Sombar130a04f2017-07-16 10:02:37 -0500172 [Documentation] Do inventory and compare.
Steven Sombar2c97f812017-10-31 09:55:13 -0500173 [Arguments] ${inventory_file_path} ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500174 # Description of argument(s):
Steven Sombar2c97f812017-10-31 09:55:13 -0500175 # inventory_file_path The file to receive the inventory snapshot.
176 # PREV_INV_FILE_PATH The previous inventory to compare with.
Steven Sombar130a04f2017-07-16 10:02:37 -0500177
178 Create JSON Inventory File ${inventory_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500179 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE'
Steven Sombar130a04f2017-07-16 10:02:37 -0500180 ... Compare Json Inventory Files ${inventory_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500181 ... ${PREV_INV_FILE_PATH}
182 ${PREV_INV_FILE_PATH}= Set Variable ${inventory_file_path}
183 Set Suite Variable ${PREV_INV_FILE_PATH} children=true
Steven Sombar130a04f2017-07-16 10:02:37 -0500184
185
186Compare Json Inventory Files
187 [Documentation] Compare JSON inventory files.
188 [Arguments] ${file1} ${file2}
189 # Description of argument(s):
190 # file1 A file that has an inventory snapshot in JSON format.
191 # file2 A file that has an inventory snapshot, to compare with file1.
192
Steven Sombarb6749a62017-10-06 08:34:23 -0500193 ${diff_rc}= File_Diff ${file1}
Steven Sombar48ad01d2017-08-17 14:17:37 -0500194 ... ${file2} ${json_diff_file_path} ${INV_IGNORE_LIST}
Steven Sombar130a04f2017-07-16 10:02:37 -0500195 Run Keyword If '${diff_rc}' != '${0}'
196 ... Report Inventory Mismatch ${diff_rc} ${json_diff_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500197 ... ELSE Rprint Timen Inventoy check: No differences found.
Steven Sombar130a04f2017-07-16 10:02:37 -0500198
199
200Report Inventory Mismatch
201 [Documentation] Report inventory mismatch.
202 [Arguments] ${diff_rc} ${json_diff_file_path}
203 # Description of argument(s):
204 # diff_rc The failing return code from the difference check.
205 # json_diff_file_path The file that has the latest inventory snapshot.
206
Steven Sombara2216d22017-08-09 12:18:00 -0500207 Log To Console Significant difference in inventory found, rc=${diff_rc}
208 Log To Console Differences are listed in file: no_newline=true
209 Log To Console ${json_diff_file_path}
210 Log To Console File Contents:
211 Wait Until Created ${json_diff_file_path}
212 ${file_contents}= OperatingSystem.Get File ${json_diff_file_path}
213 Log ${file_contents} level=WARN
214 Fail Significant difference in inventory found, rc=${diff_rc}
Steven Sombar130a04f2017-07-16 10:02:37 -0500215
216
George Keishing8b082fd2017-05-03 13:42:39 -0500217Loop HTX Health Check
George Keishingffbe8ce2017-05-04 12:08:54 -0500218 [Documentation] Run until HTX exerciser fails.
George Keishing8b082fd2017-05-03 13:42:39 -0500219 Repeat Keyword ${HTX_DURATION}
220 ... Run Keywords Check HTX Run Status
221 ... AND Sleep ${HTX_INTERVAL}
222
223
Steven Sombar0278b132018-01-09 14:41:32 -0600224Test Setup Execution
225 [Documentation] Do the initial test setup.
226
Steven Sombarac687c42018-08-09 13:39:36 -0500227 ${bmc_version} ${stderr} ${rc}= BMC Execute Command
228 ... cat /etc/os-release
229 Rprintn
230 Rpvars bmc_version
Steven Sombare0be9152018-08-08 08:22:53 -0500231
George Keishing559f8382018-10-28 02:17:49 -0500232 ${pnor_version}= Get Host Software Objects Details
Steven Sombare0be9152018-08-08 08:22:53 -0500233 Rpvars pnor_version
234
Steven Sombar0278b132018-01-09 14:41:32 -0600235 REST Power On stack_mode=skip
Steven Sombar1ddc7c62018-06-01 11:55:34 -0500236 Run Key U Sleep \ 15s
Steven Sombar0278b132018-01-09 14:41:32 -0600237 Delete All Error Logs
238 Tool Exist htxcmdline
239
Steven Sombarac687c42018-08-09 13:39:36 -0500240 ${os_release_info}= Get OS Release Info
241 Rpvars 1 os_release_info
242
Steven Sombar0278b132018-01-09 14:41:32 -0600243 # Shutdown if HTX is running.
Steven Sombar3ecb6892018-03-23 11:41:08 -0500244 ${status}= Is HTX Running
Steven Sombar0278b132018-01-09 14:41:32 -0600245 Run Keyword If '${status}' == 'True'
246 ... Shutdown HTX Exerciser
247
248
George Keishingdc1691d2017-12-07 12:17:46 -0600249Test Teardown Execution
Steven Sombare0be9152018-08-08 08:22:53 -0500250 [Documentation] Do the post-test teardown.
George Keishingffbe8ce2017-05-04 12:08:54 -0500251
George Keishing1a23b692017-05-06 12:19:41 -0500252 # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
Steven Sombar130a04f2017-07-16 10:02:37 -0500253 Run Keyword If
254 ... '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
George Keishingffbe8ce2017-05-04 12:08:54 -0500255 ... Shutdown HTX Exerciser
256
George Keishingae5d9782017-06-12 13:35:59 -0500257 ${keyword_buf}= Catenate Stop SOL Console Logging
258 ... \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
259 Run Key ${keyword_buf}
260
George Keishingffbe8ce2017-05-04 12:08:54 -0500261 FFDC On Test Case Fail
262 Close All Connections