blob: 247016f1b9503fa85c8db8e9b35724f35b7c75a5 [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
Steven Sombar1ddc7c62018-06-01 11:55:34 -0500122 Run Key U Sleep \ 15s
George Keishingffbe8ce2017-05-04 12:08:54 -0500123
124 # Post Power off and on, the OS SSH session needs to be established.
George Keishing8b082fd2017-05-03 13:42:39 -0500125 Login To OS
126
Steven Sombara2f166c2017-08-02 14:22:45 -0500127 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500128 ... Do Inventory And Compare ${json_initial_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500129 ... ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500130
George Keishing13f44e52017-05-12 15:28:12 -0500131 Run Keyword If '${HTX_MDT_PROFILE}' == 'mdt.bu'
132 ... Create Default MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500133
George Keishing13f44e52017-05-12 15:28:12 -0500134 Run MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500135
136 Loop HTX Health Check
137
George Keishingffbe8ce2017-05-04 12:08:54 -0500138 Shutdown HTX Exerciser
139
Steven Sombara2f166c2017-08-02 14:22:45 -0500140 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500141 ... Do Inventory And Compare ${json_final_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500142 ... ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500143
Steven Sombar3ecb6892018-03-23 11:41:08 -0500144 # Terminate run if there are any BMC error logs.
145 ${error_logs}= Get Error Logs
146 ${num_logs}= Get Length ${error_logs}
147 Run Keyword If ${num_logs} != 0 Run Keywords
148 ... Print Error Logs ${error_logs}
149 ... AND Fail msg=Terminating run due to BMC error log(s).
150
George Keishingffbe8ce2017-05-04 12:08:54 -0500151 Power Off Host
152
George Keishingae5d9782017-06-12 13:35:59 -0500153 # Close all SSH and REST active sessions.
154 Close All Connections
155 Flush REST Sessions
156
George Keishingffbe8ce2017-05-04 12:08:54 -0500157 Rprint Timen HTX Test ran for: ${HTX_DURATION}
George Keishing8b082fd2017-05-03 13:42:39 -0500158
Steven Sombar16dba512017-10-20 07:20:08 -0500159 ${loop_count}= Catenate Ending iteration: ${iteration}
Steven Sombar2c97f812017-10-31 09:55:13 -0500160
161 ${est_seconds_left}= Evaluate ${est_seconds_left}-${loop_body_seconds}
162 Set Suite Variable ${est_seconds_left} children=true
163 ${estimated_time_remaining}= Convert Time
164 ... ${est_seconds_left} result_format=compact
165
166 Rpvars loop_count estimated_time_remaining
Steven Sombar16dba512017-10-20 07:20:08 -0500167
George Keishing13f44e52017-05-12 15:28:12 -0500168
Steven Sombara2f166c2017-08-02 14:22:45 -0500169Do Inventory And Compare
Steven Sombar130a04f2017-07-16 10:02:37 -0500170 [Documentation] Do inventory and compare.
Steven Sombar2c97f812017-10-31 09:55:13 -0500171 [Arguments] ${inventory_file_path} ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500172 # Description of argument(s):
Steven Sombar2c97f812017-10-31 09:55:13 -0500173 # inventory_file_path The file to receive the inventory snapshot.
174 # PREV_INV_FILE_PATH The previous inventory to compare with.
Steven Sombar130a04f2017-07-16 10:02:37 -0500175
176 Create JSON Inventory File ${inventory_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500177 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE'
Steven Sombar130a04f2017-07-16 10:02:37 -0500178 ... Compare Json Inventory Files ${inventory_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500179 ... ${PREV_INV_FILE_PATH}
180 ${PREV_INV_FILE_PATH}= Set Variable ${inventory_file_path}
181 Set Suite Variable ${PREV_INV_FILE_PATH} children=true
Steven Sombar130a04f2017-07-16 10:02:37 -0500182
183
184Compare Json Inventory Files
185 [Documentation] Compare JSON inventory files.
186 [Arguments] ${file1} ${file2}
187 # Description of argument(s):
188 # file1 A file that has an inventory snapshot in JSON format.
189 # file2 A file that has an inventory snapshot, to compare with file1.
190
Steven Sombarb6749a62017-10-06 08:34:23 -0500191 ${diff_rc}= File_Diff ${file1}
Steven Sombar48ad01d2017-08-17 14:17:37 -0500192 ... ${file2} ${json_diff_file_path} ${INV_IGNORE_LIST}
Steven Sombar130a04f2017-07-16 10:02:37 -0500193 Run Keyword If '${diff_rc}' != '${0}'
194 ... Report Inventory Mismatch ${diff_rc} ${json_diff_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500195 ... ELSE Rprint Timen Inventoy check: No differences found.
Steven Sombar130a04f2017-07-16 10:02:37 -0500196
197
198Report Inventory Mismatch
199 [Documentation] Report inventory mismatch.
200 [Arguments] ${diff_rc} ${json_diff_file_path}
201 # Description of argument(s):
202 # diff_rc The failing return code from the difference check.
203 # json_diff_file_path The file that has the latest inventory snapshot.
204
Steven Sombara2216d22017-08-09 12:18:00 -0500205 Log To Console Significant difference in inventory found, rc=${diff_rc}
206 Log To Console Differences are listed in file: no_newline=true
207 Log To Console ${json_diff_file_path}
208 Log To Console File Contents:
209 Wait Until Created ${json_diff_file_path}
210 ${file_contents}= OperatingSystem.Get File ${json_diff_file_path}
211 Log ${file_contents} level=WARN
212 Fail Significant difference in inventory found, rc=${diff_rc}
Steven Sombar130a04f2017-07-16 10:02:37 -0500213
214
George Keishing8b082fd2017-05-03 13:42:39 -0500215Loop HTX Health Check
George Keishingffbe8ce2017-05-04 12:08:54 -0500216 [Documentation] Run until HTX exerciser fails.
George Keishing8b082fd2017-05-03 13:42:39 -0500217 Repeat Keyword ${HTX_DURATION}
218 ... Run Keywords Check HTX Run Status
219 ... AND Sleep ${HTX_INTERVAL}
220
221
Steven Sombar0278b132018-01-09 14:41:32 -0600222Test Setup Execution
223 [Documentation] Do the initial test setup.
224
225 REST Power On stack_mode=skip
Steven Sombar1ddc7c62018-06-01 11:55:34 -0500226 Run Key U Sleep \ 15s
Steven Sombar0278b132018-01-09 14:41:32 -0600227 Delete All Error Logs
228 Tool Exist htxcmdline
229
230 # Shutdown if HTX is running.
Steven Sombar3ecb6892018-03-23 11:41:08 -0500231 ${status}= Is HTX Running
Steven Sombar0278b132018-01-09 14:41:32 -0600232 Run Keyword If '${status}' == 'True'
233 ... Shutdown HTX Exerciser
234
235
George Keishingdc1691d2017-12-07 12:17:46 -0600236Test Teardown Execution
George Keishingffbe8ce2017-05-04 12:08:54 -0500237 [Documentation] Do the post test teardown.
238 # 1. Shut down HTX exerciser if test Failed.
239 # 2. Capture FFDC on test failure.
240 # 3. Close all open SSH connections.
241
George Keishing1a23b692017-05-06 12:19:41 -0500242 # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
Steven Sombar130a04f2017-07-16 10:02:37 -0500243 Run Keyword If
244 ... '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
George Keishingffbe8ce2017-05-04 12:08:54 -0500245 ... Shutdown HTX Exerciser
246
George Keishingae5d9782017-06-12 13:35:59 -0500247 ${keyword_buf}= Catenate Stop SOL Console Logging
248 ... \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
249 Run Key ${keyword_buf}
250
George Keishingffbe8ce2017-05-04 12:08:54 -0500251 FFDC On Test Case Fail
252 Close All Connections