blob: fe787c55348f8fcd7bd5ab931085ace1c71678cf [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
Steven Sombare0be9152018-08-08 08:22:53 -050045Library ../syslib/utils_os.py
George Keishingffbe8ce2017-05-04 12:08:54 -050046
Steven Sombar16dba512017-10-20 07:20:08 -050047Suite Setup Run Keyword Start SOL Console Logging
George Keishingdc1691d2017-12-07 12:17:46 -060048Test Setup Test Setup Execution
49Test Teardown Test Teardown Execution
George Keishing8b082fd2017-05-03 13:42:39 -050050
Steven Sombar6f9d41d2017-08-08 13:35:30 -050051
George Keishing8b082fd2017-05-03 13:42:39 -050052*** Variables ****
53
Steven Sombar130a04f2017-07-16 10:02:37 -050054${stack_mode} skip
Steven Sombar6f9d41d2017-08-08 13:35:30 -050055${json_initial_file_path} ${EXECDIR}/os_inventory_initial.json
56${json_final_file_path} ${EXECDIR}/os_inventory_final.json
57${json_diff_file_path} ${EXECDIR}/os_inventory_diff.json
Steven Sombara2f166c2017-08-02 14:22:45 -050058${CHECK_INVENTORY} True
Steven Sombarb6749a62017-10-06 08:34:23 -050059${INV_IGNORE_LIST} size
Steven Sombar2c97f812017-10-31 09:55:13 -050060${PREV_INV_FILE_PATH} NONE
George Keishingffbe8ce2017-05-04 12:08:54 -050061
Steven Sombar6f9d41d2017-08-08 13:35:30 -050062
George Keishing8b082fd2017-05-03 13:42:39 -050063*** Test Cases ***
64
65Hard Bootme Test
66 [Documentation] Stress the system using HTX exerciser.
George Keishingffbe8ce2017-05-04 12:08:54 -050067 [Tags] Hard_Bootme_Test
George Keishing8b082fd2017-05-03 13:42:39 -050068
Steven Sombar48ad01d2017-08-17 14:17:37 -050069 Rprintn
Steven Sombar2c97f812017-10-31 09:55:13 -050070 Rpvars HTX_DURATION HTX_LOOP HTX_INTERVAL CHECK_INVENTORY
71 ... INV_IGNORE_LIST PREV_INV_FILE_PATH
Steven Sombar48ad01d2017-08-17 14:17:37 -050072
Steven Sombar2c97f812017-10-31 09:55:13 -050073 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE'
74 ... OperatingSystem.File Should Exist ${PREV_INV_FILE_PATH}
Steven Sombar48ad01d2017-08-17 14:17:37 -050075
Steven Sombar2c97f812017-10-31 09:55:13 -050076 Set Suite Variable ${PREV_INV_FILE_PATH} children=true
Steven Sombar48ad01d2017-08-17 14:17:37 -050077 Set Suite Variable ${INV_IGNORE_LIST} children=true
Steven Sombar2c97f812017-10-31 09:55:13 -050078
79 # Set up the iteration (loop) counter.
Steven Sombar16dba512017-10-20 07:20:08 -050080 Set Suite Variable ${iteration} ${0} children=true
Steven Sombar130a04f2017-07-16 10:02:37 -050081
Steven Sombar2c97f812017-10-31 09:55:13 -050082 # Estimate the time required for a single iteration loop.
83 # HTX_DURATION + 10 minutes for OS boot, HTX startup, shutdown.
84 ${loop_body_seconds}= Add Time To Time ${HTX_DURATION} 10m
85 Set Suite Variable ${loop_body_seconds} children=true
86 # And save it in printable (compact) format.
87 ${estimated_loop_time}= Convert Time
88 ... ${loop_body_seconds} result_format=compact
89 Set Suite Variable ${estimated_loop_time} children=true
90
91 # Estimated time remaining = loop_body_seconds * HTX_LOOP + 5m
92 ${est_seconds_left}= Evaluate ${loop_body_seconds}*${HTX_LOOP}+(5*60)
93 Set Suite Variable ${est_seconds_left} children=true
94
Steven Sombar130a04f2017-07-16 10:02:37 -050095 Repeat Keyword ${HTX_LOOP} times Run HTX Exerciser
George Keishingffbe8ce2017-05-04 12:08:54 -050096
97
98*** Keywords ***
99
Steven Sombar16dba512017-10-20 07:20:08 -0500100
Steven Sombar130a04f2017-07-16 10:02:37 -0500101Run HTX Exerciser
102 [Documentation] Run HTX exerciser.
George Keishingffbe8ce2017-05-04 12:08:54 -0500103 # Test Flow:
Steven Sombar130a04f2017-07-16 10:02:37 -0500104 # - Power on.
105 # - Establish SSH connection session.
106 # - Do inventory collection, compare with
107 # previous inventory run if applicable.
108 # - Create HTX mdt profile.
109 # - Run HTX exerciser.
110 # - Check HTX status for errors.
111 # - Do inventory collection, compare with
112 # previous inventory run.
113 # - Power off.
George Keishingffbe8ce2017-05-04 12:08:54 -0500114
Steven Sombar16dba512017-10-20 07:20:08 -0500115 Set Suite Variable ${iteration} ${iteration + 1}
116 ${loop_count}= Catenate Starting iteration: ${iteration}
Steven Sombar2c97f812017-10-31 09:55:13 -0500117 ${estimated_time_remaining}= Convert Time
118 ... ${est_seconds_left} result_format=compact
119 Rprintn
120 Rpvars loop_count estimated_loop_time estimated_time_remaining
Steven Sombar16dba512017-10-20 07:20:08 -0500121
Steven Sombar0278b132018-01-09 14:41:32 -0600122 REST Power On stack_mode=skip
Steven Sombar1ddc7c62018-06-01 11:55:34 -0500123 Run Key U Sleep \ 15s
George Keishingffbe8ce2017-05-04 12:08:54 -0500124
125 # Post Power off and on, the OS SSH session needs to be established.
George Keishing8b082fd2017-05-03 13:42:39 -0500126 Login To OS
127
Steven Sombara2f166c2017-08-02 14:22:45 -0500128 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500129 ... Do Inventory And Compare ${json_initial_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500130 ... ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500131
George Keishing13f44e52017-05-12 15:28:12 -0500132 Run Keyword If '${HTX_MDT_PROFILE}' == 'mdt.bu'
133 ... Create Default MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500134
George Keishing13f44e52017-05-12 15:28:12 -0500135 Run MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500136
137 Loop HTX Health Check
138
George Keishingffbe8ce2017-05-04 12:08:54 -0500139 Shutdown HTX Exerciser
140
Steven Sombara2f166c2017-08-02 14:22:45 -0500141 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500142 ... Do Inventory And Compare ${json_final_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500143 ... ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500144
Steven Sombar3ecb6892018-03-23 11:41:08 -0500145 # Terminate run if there are any BMC error logs.
146 ${error_logs}= Get Error Logs
147 ${num_logs}= Get Length ${error_logs}
148 Run Keyword If ${num_logs} != 0 Run Keywords
149 ... Print Error Logs ${error_logs}
150 ... AND Fail msg=Terminating run due to BMC error log(s).
151
George Keishingffbe8ce2017-05-04 12:08:54 -0500152 Power Off Host
153
George Keishingae5d9782017-06-12 13:35:59 -0500154 # Close all SSH and REST active sessions.
155 Close All Connections
156 Flush REST Sessions
157
George Keishingffbe8ce2017-05-04 12:08:54 -0500158 Rprint Timen HTX Test ran for: ${HTX_DURATION}
George Keishing8b082fd2017-05-03 13:42:39 -0500159
Steven Sombar16dba512017-10-20 07:20:08 -0500160 ${loop_count}= Catenate Ending iteration: ${iteration}
Steven Sombar2c97f812017-10-31 09:55:13 -0500161
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 Rpvars loop_count estimated_time_remaining
Steven Sombar16dba512017-10-20 07:20:08 -0500168
George Keishing13f44e52017-05-12 15:28:12 -0500169
Steven Sombara2f166c2017-08-02 14:22:45 -0500170Do Inventory And Compare
Steven Sombar130a04f2017-07-16 10:02:37 -0500171 [Documentation] Do inventory and compare.
Steven Sombar2c97f812017-10-31 09:55:13 -0500172 [Arguments] ${inventory_file_path} ${PREV_INV_FILE_PATH}
Steven Sombar130a04f2017-07-16 10:02:37 -0500173 # Description of argument(s):
Steven Sombar2c97f812017-10-31 09:55:13 -0500174 # inventory_file_path The file to receive the inventory snapshot.
175 # PREV_INV_FILE_PATH The previous inventory to compare with.
Steven Sombar130a04f2017-07-16 10:02:37 -0500176
177 Create JSON Inventory File ${inventory_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500178 Run Keyword If '${PREV_INV_FILE_PATH}' != 'NONE'
Steven Sombar130a04f2017-07-16 10:02:37 -0500179 ... Compare Json Inventory Files ${inventory_file_path}
Steven Sombar2c97f812017-10-31 09:55:13 -0500180 ... ${PREV_INV_FILE_PATH}
181 ${PREV_INV_FILE_PATH}= Set Variable ${inventory_file_path}
182 Set Suite Variable ${PREV_INV_FILE_PATH} children=true
Steven Sombar130a04f2017-07-16 10:02:37 -0500183
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
Steven Sombarb6749a62017-10-06 08:34:23 -0500192 ${diff_rc}= File_Diff ${file1}
Steven Sombar48ad01d2017-08-17 14:17:37 -0500193 ... ${file2} ${json_diff_file_path} ${INV_IGNORE_LIST}
Steven Sombar130a04f2017-07-16 10:02:37 -0500194 Run Keyword If '${diff_rc}' != '${0}'
195 ... Report Inventory Mismatch ${diff_rc} ${json_diff_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500196 ... ELSE Rprint Timen Inventoy check: No differences found.
Steven Sombar130a04f2017-07-16 10:02:37 -0500197
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
Steven Sombara2216d22017-08-09 12:18:00 -0500206 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}
Steven Sombar130a04f2017-07-16 10:02:37 -0500214
215
George Keishing8b082fd2017-05-03 13:42:39 -0500216Loop HTX Health Check
George Keishingffbe8ce2017-05-04 12:08:54 -0500217 [Documentation] Run until HTX exerciser fails.
George Keishing8b082fd2017-05-03 13:42:39 -0500218 Repeat Keyword ${HTX_DURATION}
219 ... Run Keywords Check HTX Run Status
220 ... AND Sleep ${HTX_INTERVAL}
221
222
Steven Sombar0278b132018-01-09 14:41:32 -0600223Test Setup Execution
224 [Documentation] Do the initial test setup.
225
Steven Sombarac687c42018-08-09 13:39:36 -0500226 ${bmc_version} ${stderr} ${rc}= BMC Execute Command
227 ... cat /etc/os-release
228 Rprintn
229 Rpvars bmc_version
Steven Sombare0be9152018-08-08 08:22:53 -0500230
231 ${pnor_version} ${stderr} ${rc}= BMC Execute Command
232 ... sed -re 's/\t//g' /var/lib/phosphor-software-manager/pnor/ro/VERSION
233 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