blob: 03a6157404e9e586a03771128f04c6648a2b8353 [file] [log] [blame]
Leah McNuttc9c9cde2016-10-07 16:53:52 +00001*** Settings ***
Michael Walsh0bbd8602016-11-22 11:31:49 -06002Documentation Do random repeated boots based on the state of the BMC machine.
3... The number of repetitions is designated by ${max_num_tests}. Keyword
4... names that are listed in @{AVAIL_BOOTS} become the selection of possible
5... boots for the test.
Leah McNuttc9c9cde2016-10-07 16:53:52 +00006
Leah McNuttc9c9cde2016-10-07 16:53:52 +00007Resource ../lib/dvt/obmc_driver_vars.txt
8Resource ../lib/list_utils.robot
Michael Walsh0bbd8602016-11-22 11:31:49 -06009Resource ../lib/openbmc_ffdc.robot
10
11Library ../lib/gen_robot_print.py
12Library ../lib/gen_robot_plug_in.py
13Library ../lib/gen_robot_valid.py
14Library ../lib/state.py
15Library ../lib/boot/powerons.py
16Library ../lib/boot/poweroffs.py
17Library ../lib/obmc_boot_test.py
18
19# WITH NAME boot_results
20
21*** Variables ***
22# Initialize program parameters variables.
23# Create parm_list containing all of our program parameters. This is used by
24# 'Rqprint Pgm Header'
25@{parm_list} openbmc_nickname openbmc_host openbmc_username
26... openbmc_password os_host os_username os_password pdu_host
27... pdu_username pdu_password pdu_slot_no openbmc_serial_host
28... openbmc_serial_port boot_stack boot_list max_num_tests
29... plug_in_dir_paths status_file_path openbmc_model boot_pass boot_fail
Michael Walshb4125952016-12-13 15:49:50 -060030... ffdc_dir_path_style ffdc_check test_mode quiet debug
Michael Walsh0bbd8602016-11-22 11:31:49 -060031
32# Initialize each program parameter.
33${openbmc_nickname} ${EMPTY}
34${openbmc_host} ${EMPTY}
35${openbmc_username} root
36${openbmc_password} 0penBmc
37${os_host} ${EMPTY}
38${os_username} root
39${os_password} P@ssw0rd
40${pdu_host} ${EMPTY}
41${pdu_username} admin
42${pdu_password} admin
43${pdu_slot_no} ${EMPTY}
44${openbmc_serial_host} ${EMPTY}
45${openbmc_serial_port} ${EMPTY}
46${boot_stack} ${EMPTY}
47${boot_list} ${EMPTY}
48${max_num_tests} 0
49${plug_in_dir_paths} ${EMPTY}
50${status_file_path} ${EMPTY}
51${openbmc_model} ${EMPTY}
52# The reason boot_pass and boot_fail are parameters is that it is possible to
53# be called by a program that has already done some tests. This allows us to
54# keep the grand total.
55${boot_pass} ${0}
56${boot_fail} ${0}
Michael Walshb4125952016-12-13 15:49:50 -060057${ffdc_dir_path_style} ${EMPTY}
58${ffdc_check} ${EMPTY}
Michael Walsh0bbd8602016-11-22 11:31:49 -060059${test_mode} 0
60${quiet} 0
61${debug} 0
62
Michael Walshb4125952016-12-13 15:49:50 -060063
Michael Walsh0bbd8602016-11-22 11:31:49 -060064# Plug-in variables.
65${shell_rc} 0x00000000
66${fail_on_plug_in_failure} 1
67${return_on_non_zero_rc} 0
68
69${next_boot} ${EMPTY}
70# State dictionary. Initializing to a realistic state for testing in
71# test_mode.
72&{default_state} power=1
73... bmc=HOST_BOOTED
74... boot_progress=FW Progress, Starting OS
75... os_ping=1
76... os_login=1
77... os_run_cmd=1
78&{state} &{default_state}
79
80# Flag variables.
81${cp_setup_called} ${0}
82# test_really_running is needed by DB_Logging plug-in.
83${test_really_running} ${1}
Leah McNuttc9c9cde2016-10-07 16:53:52 +000084
85*** Test Cases ***
Michael Walsh0bbd8602016-11-22 11:31:49 -060086Randomized Boot Testing
87 [Documentation] Performs random, repeated boots.
88 [Tags] Randomized_boot_testing
Leah McNuttc9c9cde2016-10-07 16:53:52 +000089
90 # Call the Main keyword to prevent any dots from appearing in the console
91 # due to top level keywords.
92 Main
93
94*** Keywords ***
Michael Walsh0bbd8602016-11-22 11:31:49 -060095###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +000096Main
Michael Walsh0bbd8602016-11-22 11:31:49 -060097 [Teardown] Program Teardown
Leah McNuttc9c9cde2016-10-07 16:53:52 +000098
Michael Walsh0bbd8602016-11-22 11:31:49 -060099 Setup
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000100
Michael Walsh0bbd8602016-11-22 11:31:49 -0600101 :For ${BOOT_COUNT} IN RANGE ${max_num_tests}
102 \ Test Loop Body ${BOOT_COUNT}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000103
Michael Walsh0bbd8602016-11-22 11:31:49 -0600104 Rprint Timen Completed all requested boot tests.
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000105
Michael Walsh0bbd8602016-11-22 11:31:49 -0600106###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000107
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000108
Michael Walsh0bbd8602016-11-22 11:31:49 -0600109###############################################################################
110Setup
111 [Documentation] Do general program setup tasks.
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000112
Michael Walsh0bbd8602016-11-22 11:31:49 -0600113 Rprintn
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000114
Michael Walsh0bbd8602016-11-22 11:31:49 -0600115 Validate Parms
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000116
Michael Walsh0bbd8602016-11-22 11:31:49 -0600117 Rqprint Pgm Header
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000118
Michael Walsh0bbd8602016-11-22 11:31:49 -0600119 Create Boot Results Table
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000120
Michael Walsh0bbd8602016-11-22 11:31:49 -0600121 # Preserve the values of boot_pass/boot_fail that were passed in.
122 Set Global Variable ${initial_boot_pass} ${boot_pass}
123 Set Global Variable ${initial_boot_fail} ${boot_fail}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000124
Michael Walsh0bbd8602016-11-22 11:31:49 -0600125 # Call "setup" plug-ins, if any.
126 Plug In Setup
127 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
128 ... call_point=setup
129 Should Be Equal '${rc}' '${0}'
130
131 # Keyword "FFDC" will fail if TEST_MESSAGE is not set.
132 Set Global Variable ${TEST_MESSAGE} ${EMPTY}
133
134 # Setting cp_setup_called lets our Teardown know that it needs to call
135 # the cleanup plug-in call point.
136 Set Global Variable ${cp_setup_called} ${1}
137
138 Rqprint Timen Getting system state.
139 # The state dictionary must be primed before calling Test Loop Body.
140 ${temp_state}= Run Keyword If '${test_mode}' == '0' Get State
141 ... ELSE Create Dictionary &{default_state}
142 Set Global Variable &{state} &{temp_state}
143 rpvars state
144
145###############################################################################
146
147
148###############################################################################
149Validate Parms
150 [Documentation] Validate all program parameters.
151
152 rprintn
153
154 Rvalid Value AVAIL_BOOTS
155 Rvalid Value openbmc_host
156 Rvalid Value openbmc_username
157 Rvalid Value openbmc_password
158 # os_host is optional so no validation is being done.
Michael Walshb4125952016-12-13 15:49:50 -0600159 Run Keyword If '${OS_HOST}' != '${EMPTY}' Run Keywords
160 ... Rvalid Value os_username AND
161 ... Rvalid Value os_password
Michael Walsh0bbd8602016-11-22 11:31:49 -0600162 Rvalid Value pdu_host
163 Rvalid Value pdu_username
164 Rvalid Value pdu_password
165 Rvalid Integer pdu_slot_no
166 Rvalid Value openbmc_serial_host
167 Rvalid Integer openbmc_serial_port
168 Rvalid Integer max_num_tests
169 Rvalid Value openbmc_model
170 Rvalid Integer boot_pass
171 Rvalid Integer boot_fail
172
173 ${boot_pass_temp}= Convert To Integer ${boot_pass}
174 Set Global Variable ${boot_pass} ${boot_pass_temp}
175 ${boot_fail_temp}= Convert To Integer ${boot_fail}
176 Set Global Variable ${boot_fail} ${boot_fail_temp}
177
178 ${temp_arr}= Rvalidate Plug Ins ${plug_in_dir_paths}
179 Set Global Variable @{plug_in_packages_list} @{temp_arr}
180
Michael Walshb4125952016-12-13 15:49:50 -0600181 Set FFDC Dir Path Style
182
183###############################################################################
184
185
186###############################################################################
187Set FFDC Dir Path Style
188
189 Run Keyword If '${ffdc_dir_path_style}' != '${EMPTY}' Return from Keyword
190
191 ${temp}= Run Keyword and Continue On Failure Get Environment Variable
192 ... FFDC_DIR_PATH_STYLE ${0}
193
194 Set Global Variable ${ffdc_dir_path_style} ${temp}
195
Michael Walsh0bbd8602016-11-22 11:31:49 -0600196###############################################################################
197
198
199###############################################################################
200Program Teardown
201 [Documentation] Clean up after this program.
202
203 Run Keyword If '${cp_setup_called}' == '1' Run Keywords
204 ... Plug In Setup AND
205 ... Rprocess Plug In Packages call_point=cleanup
206 ... stop_on_plug_in_failure=1
207
208 Rqprint Pgm Footer
209
210###############################################################################
211
212
213###############################################################################
214Test Loop Body
215 [Documentation] The main loop body for the loop in "main".
216 [Arguments] ${BOOT_COUNT}
217
218 Rqprintn
219 Rqprint Timen Starting boot ${BOOT_COUNT+1} of ${max_num_tests}.
220
221 ${loc_next_boot}= Select Boot ${state['power']}
222 Set Global Variable ${next_boot} ${loc_next_boot}
223
224 ${status} ${msg}= Run Keyword And Ignore Error Run Boot ${next_boot}
225 Run Keyword If '${status}' == 'FAIL' rprint ${msg}
226
227 rprintn
228 Run Keyword If '${BOOT_STATUS}' == 'PASS' Run Keywords
229 ... Set Global Variable ${boot_success} ${1} AND
230 ... Rqprint Timen BOOT_SUCCESS: "${next_boot}" succeeded.
231 ... ELSE Run Keywords
232 ... Set Global Variable ${boot_success} ${0} AND
233 ... Rqprint Timen BOOT_FAILED: ${next_boot} failed.
234
235 Update Boot Results Table ${next_boot} ${BOOT_STATUS}
236
237 # NOTE: A post_test_case call point failure is NOT counted as a boot
238 # failure.
239 Plug In Setup
240 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
241 ... call_point=post_test_case stop_on_plug_in_failure=1
242
Michael Walshb4125952016-12-13 15:49:50 -0600243 Run Keyword If '${BOOT_STATUS}' != 'PASS' or '${FFDC_CHECK}' == 'All'
Michael Walsh0bbd8602016-11-22 11:31:49 -0600244 ... Run Keyword and Continue On Failure My FFDC
245
246 # Run plug-ins to see if we ought to stop execution.
247 Plug In Setup
248 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
249 ... call_point=stop_check
250 Run Keyword If '${rc}' != '${0}' Run Keywords
251 ... Rprint Error Report Stopping as requested by user.
252 ... Fail
253
254 Print Boot Results Table
255 Rqprint Timen Finished boot ${BOOT_COUNT+1} of ${max_num_tests}.
256
257 Rqprint Timen Getting system state.
258 # The state must be refreshed before calling Test Loop Body again.
259 ${temp_state}= Run Keyword If '${test_mode}' == '0' Get State
260 ... quiet=${1}
261 ... ELSE Create Dictionary &{default_state}
262 Set Global Variable &{state} &{temp_state}
263 rpvars state
264
265###############################################################################
266
267
268###############################################################################
269Select Boot
270 [Documentation] Select a boot test to be run based on our current state.
271 ... Return the chosen boot type.
272 [Arguments] ${power}
273
274 # power The power state of the machine, either zero or one.
275
276 ${boot}= Run Keyword If ${power} == ${0} Select Power On
277 ... ELSE Run Keyword If ${power} == ${1} Select Power Off
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000278 ... ELSE Run Keywords Log to Console
Michael Walsh0bbd8602016-11-22 11:31:49 -0600279 ... **ERROR** BMC not in state to power on or off: "${power}" AND
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000280 ... Fatal Error
281
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600282 [Return] ${boot}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000283
Michael Walsh0bbd8602016-11-22 11:31:49 -0600284###############################################################################
285
286
287###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000288Select Power On
Michael Walsh0bbd8602016-11-22 11:31:49 -0600289 [Documentation] Randomly chooses a boot from the list of Power On boots.
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000290
Michael Walsh0bbd8602016-11-22 11:31:49 -0600291 @{power_on_choices}= Intersect Lists ${VALID_POWER_ON} ${AVAIL_BOOTS}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000292
293 ${length}= Get Length ${power_on_choices}
294
Michael Walsh0bbd8602016-11-22 11:31:49 -0600295 # Currently selects the first boot in the list of options, rather than
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000296 # selecting randomly.
297 ${chosen}= Set Variable @{power_on_choices}[0]
298
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600299 [Return] ${chosen}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000300
Michael Walsh0bbd8602016-11-22 11:31:49 -0600301###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000302
Michael Walsh0bbd8602016-11-22 11:31:49 -0600303
304###############################################################################
305Select Power Off
306 [Documentation] Randomly chooses an boot from the list of Power Off boots.
307
308 @{power_off_choices}= Intersect Lists ${VALID_POWER_OFF} ${AVAIL_BOOTS}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000309
310 ${length}= Get Length ${power_off_choices}
311
Michael Walsh0bbd8602016-11-22 11:31:49 -0600312 # Currently selects the first boot in the list of options, rather than
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000313 # selecting randomly.
314 ${chosen}= Set Variable @{power_off_choices}[0]
315
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600316 [Return] ${chosen}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000317
Michael Walsh0bbd8602016-11-22 11:31:49 -0600318###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000319
Michael Walsh0bbd8602016-11-22 11:31:49 -0600320
321###############################################################################
322Run Boot
323 [Documentation] Run the selected boot and mark the status when complete.
324 [Arguments] ${boot_keyword}
325 [Teardown] Set Global Variable ${BOOT_STATUS} ${KEYWORD STATUS}
326
327 # boot_keyword The name of the boot to run, which corresponds to the
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000328 # keyword to run. (i.e "BMC Power On")
329
Michael Walsh0bbd8602016-11-22 11:31:49 -0600330 Print Test Start Message ${boot_keyword}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000331
Michael Walsh0bbd8602016-11-22 11:31:49 -0600332 Plug In Setup
333 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
334 ... call_point=pre_boot
335 Should Be Equal '${rc}' '${0}'
336
337 @{cmd_buf}= Create List ${boot_keyword}
338 rqpissuing_keyword ${cmd_buf} ${test_mode}
339 Run Keyword If '${test_mode}' == '0' Run Keyword @{cmd_buf}
340
341 Plug In Setup
342 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
343 ... call_point=post_boot
344 Should Be Equal '${rc}' '${0}'
345
346###############################################################################
347
348
349###############################################################################
350Print Test Start Message
351 [Documentation] Print a message indicating what boot test is about to run.
352 [Arguments] ${boot_keyword}
353
354 ${doing_msg}= Sprint Timen Doing "${boot_keyword}".
355 rqprint ${doing_msg}
356
357 Append to List ${LAST_TEN} ${doing_msg}
358 ${length}= Get Length ${LAST_TEN}
359
360 Run Keyword If '${length}' > '${10}' Remove From List ${LAST_TEN} 0
361
362###############################################################################
363
364
365###############################################################################
366My FFDC
367 [Documentation] Collect FFDC data.
368
Michael Walsh0bbd8602016-11-22 11:31:49 -0600369 # FFDC_LOG_PATH is used by "FFDC" keyword.
370 Set Global Variable ${FFDC_LOG_PATH} ${FFDC_DIR_PATH}
371
372 @{cmd_buf}= Create List FFDC
373 rqpissuing_keyword ${cmd_buf} ${test_mode}
374 Run Keyword If '${test_mode}' == '0' @{cmd_buf}
375
376 Plug In Setup
377 ${rc} ${shell_rc} ${failed_plug_in_name}= Rprocess Plug In Packages
378 ... call_point=ffdc stop_on_plug_in_failure=1
379
Michael Walsh0bbd8602016-11-22 11:31:49 -0600380 Log Defect Information
381
382###############################################################################
383
384
385###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000386Log Defect Information
387 [Documentation] Logs information needed for a defect. This information
388 ... can also be found within the FFDC gathered.
389
Michael Walsh0bbd8602016-11-22 11:31:49 -0600390 Rqprintn
391 # indent=0, width=90, linefeed=1, char="="
392 Rqprint Dashes ${0} ${90} ${1} =
393 Rqprintn Copy this data to the defect:
394 Rqprintn
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000395
Michael Walsh0bbd8602016-11-22 11:31:49 -0600396 Rqpvars @{parm_list}
397 Print Last Ten Boots
398
399 ${rc} ${output}= Run Keyword If '${test_mode}' == '0'
400 ... Run and return RC and Output ls ${LOG_PREFIX}*
401 ... ELSE Set Variable ${0} ${EMPTY}
402
403 Run Keyword If '${rc}' != '${0}' and '${rc}' != 'None' rqpvars rc
404
405 Rqprintn
406 Rqprintn FFDC data files:
407 Rqprintn ${output}
408
409 Rqprintn
410 Rqprint Dashes ${0} ${90} ${1} =
411
412###############################################################################
413
414
415###############################################################################
416Print Last Ten Boots
417 [Documentation] Logs the last ten boots that were performed with their
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000418 ... starting time stamp.
419
Michael Walsh0bbd8602016-11-22 11:31:49 -0600420 # indent 0, 90 chars wide, linefeed, char is "="
421 Rqprint Dashes ${0} ${90}
422 Rqprintn Last 10 boots:
423 Rqprintn
424 :FOR ${boot_entry} IN @{LAST_TEN}
425 \ rqprint ${boot_entry}
426 Rqprint Dashes ${0} ${90}
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000427
Michael Walsh0bbd8602016-11-22 11:31:49 -0600428###############################################################################
Leah McNuttc9c9cde2016-10-07 16:53:52 +0000429
Michael Walsh0bbd8602016-11-22 11:31:49 -0600430