blob: 343ffef85b1c806d62e7f93401e7542e01acd82b [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.
10# HTX_DURATION Duration of HTX run, for example, 8 hours, or
11# 30 minutes.
12# HTX_LOOP The number of times to loop HTX.
13# HTX_INTERVAL The time delay between consecutive checks of HTX
14# status, for example, 30s.
15# In summary: Run HTX for $HTX_DURATION, looping
16# $HTX_LOOP times checking every $HTX_INTERVAL.
17# HTX_KEEP_RUNNING If set to 1, this indicates that the HTX is to
18# continue running after an error.
Steven Sombara2f166c2017-08-02 14:22:45 -050019# CHECK_INVENTORY If set to 0 or False, OS inventory checking before
20# and after each HTX run will be disabled. This
21# parameter is optional.
22# PREV_INV_FILE_PATH The file path and name of an initial previous
23# inventory snapshot file in JSON format. Inventory
24# snapshots taken before and after each HTX run will
25# be compared to this file.
26# This parameter is optional. If not specified, an
27# initial inventory snapshot will be taken before
28# HTX startup.
Steven Sombarb6749a62017-10-06 08:34:23 -050029# INV_IGNORE_LIST A comma-delimited list of strings that
Steven Sombar48ad01d2017-08-17 14:17:37 -050030# indicate what to ignore if there are inventory
Steven Sombarb6749a62017-10-06 08:34:23 -050031# differences, (e.g., processor "size").
Steven Sombar48ad01d2017-08-17 14:17:37 -050032# If differences are found during inventory checking
Steven Sombarb6749a62017-10-06 08:34:23 -050033# and those items are in this list, the
Steven Sombar48ad01d2017-08-17 14:17:37 -050034# differences will be ignored. This parameter is
35# optional. If not specified the default value is
Steven Sombarb6749a62017-10-06 08:34:23 -050036# "size".
Steven Sombar130a04f2017-07-16 10:02:37 -050037
38Resource ../syslib/utils_os.robot
39Library ../syslib/utils_keywords.py
Steven Sombarb6749a62017-10-06 08:34:23 -050040Library ../lib/utils_files.py
George Keishingffbe8ce2017-05-04 12:08:54 -050041
Steven Sombar16dba512017-10-20 07:20:08 -050042Suite Setup Run Keyword Start SOL Console Logging
George Keishingffbe8ce2017-05-04 12:08:54 -050043Test Setup Pre Test Case Execution
44Test Teardown Post Test Case Execution
George Keishing8b082fd2017-05-03 13:42:39 -050045
Steven Sombar6f9d41d2017-08-08 13:35:30 -050046
George Keishing8b082fd2017-05-03 13:42:39 -050047*** Variables ****
48
Steven Sombar130a04f2017-07-16 10:02:37 -050049${stack_mode} skip
Steven Sombar6f9d41d2017-08-08 13:35:30 -050050${json_initial_file_path} ${EXECDIR}/os_inventory_initial.json
51${json_final_file_path} ${EXECDIR}/os_inventory_final.json
52${json_diff_file_path} ${EXECDIR}/os_inventory_diff.json
Steven Sombar130a04f2017-07-16 10:02:37 -050053${last_inventory_file_path} ${EMPTY}
Steven Sombara2f166c2017-08-02 14:22:45 -050054${CHECK_INVENTORY} True
Steven Sombarb6749a62017-10-06 08:34:23 -050055${INV_IGNORE_LIST} size
Steven Sombar48ad01d2017-08-17 14:17:37 -050056${PREV_INV_FILE_PATH} ${EMPTY}
George Keishingffbe8ce2017-05-04 12:08:54 -050057
Steven Sombar6f9d41d2017-08-08 13:35:30 -050058
George Keishing8b082fd2017-05-03 13:42:39 -050059*** Test Cases ***
60
61Hard Bootme Test
62 [Documentation] Stress the system using HTX exerciser.
George Keishingffbe8ce2017-05-04 12:08:54 -050063 [Tags] Hard_Bootme_Test
George Keishing8b082fd2017-05-03 13:42:39 -050064
Steven Sombara2f166c2017-08-02 14:22:45 -050065 # Set last inventory file to PREV_INV_FILE_PATH otherwise set it
66 # to ${EMPTY}.
Steven Sombar130a04f2017-07-16 10:02:37 -050067 ${last_inventory_file_path}= Get Variable Value ${PREV_INV_FILE_PATH}
68 ... ${EMPTY}
69
Steven Sombar48ad01d2017-08-17 14:17:37 -050070 Rprintn
71 Rpvars HTX_DURATION HTX_INTERVAL CHECK_INVENTORY INV_IGNORE_LIST
72 ... PREV_INV_FILE_PATH
73
74 Run Keyword If '${last_inventory_file_path}' != '${EMPTY}'
75 ... OperatingSystem.File Should Exist ${last_inventory_file_path}
76
Steven Sombar130a04f2017-07-16 10:02:37 -050077 Set Suite Variable ${last_inventory_file_path} children=true
Steven Sombar48ad01d2017-08-17 14:17:37 -050078 Set Suite Variable ${INV_IGNORE_LIST} children=true
Steven Sombar16dba512017-10-20 07:20:08 -050079 Set Suite Variable ${iteration} ${0} children=true
Steven Sombar130a04f2017-07-16 10:02:37 -050080
81 Repeat Keyword ${HTX_LOOP} times Run HTX Exerciser
George Keishingffbe8ce2017-05-04 12:08:54 -050082
83
84*** Keywords ***
85
Steven Sombar16dba512017-10-20 07:20:08 -050086
Steven Sombar130a04f2017-07-16 10:02:37 -050087Run HTX Exerciser
88 [Documentation] Run HTX exerciser.
George Keishingffbe8ce2017-05-04 12:08:54 -050089 # Test Flow:
Steven Sombar130a04f2017-07-16 10:02:37 -050090 # - Power on.
91 # - Establish SSH connection session.
92 # - Do inventory collection, compare with
93 # previous inventory run if applicable.
94 # - Create HTX mdt profile.
95 # - Run HTX exerciser.
96 # - Check HTX status for errors.
97 # - Do inventory collection, compare with
98 # previous inventory run.
99 # - Power off.
George Keishingffbe8ce2017-05-04 12:08:54 -0500100
Steven Sombar16dba512017-10-20 07:20:08 -0500101 Set Suite Variable ${iteration} ${iteration + 1}
102 ${loop_count}= Catenate Starting iteration: ${iteration}
103 Rpvars loop_count
104
George Keishingffbe8ce2017-05-04 12:08:54 -0500105 Boot To OS
106
107 # Post Power off and on, the OS SSH session needs to be established.
George Keishing8b082fd2017-05-03 13:42:39 -0500108 Login To OS
109
Steven Sombara2f166c2017-08-02 14:22:45 -0500110 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500111 ... Do Inventory And Compare ${json_initial_file_path}
112 ... ${last_inventory_file_path}
113
George Keishing13f44e52017-05-12 15:28:12 -0500114 Run Keyword If '${HTX_MDT_PROFILE}' == 'mdt.bu'
115 ... Create Default MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500116
George Keishing13f44e52017-05-12 15:28:12 -0500117 Run MDT Profile
George Keishing8b082fd2017-05-03 13:42:39 -0500118
119 Loop HTX Health Check
120
George Keishingffbe8ce2017-05-04 12:08:54 -0500121 Shutdown HTX Exerciser
122
Steven Sombara2f166c2017-08-02 14:22:45 -0500123 Run Keyword If '${CHECK_INVENTORY}' == 'True'
Steven Sombar130a04f2017-07-16 10:02:37 -0500124 ... Do Inventory And Compare ${json_final_file_path}
125 ... ${last_inventory_file_path}
126
George Keishingffbe8ce2017-05-04 12:08:54 -0500127 Power Off Host
128
George Keishingae5d9782017-06-12 13:35:59 -0500129 # Close all SSH and REST active sessions.
130 Close All Connections
131 Flush REST Sessions
132
George Keishingffbe8ce2017-05-04 12:08:54 -0500133 Rprint Timen HTX Test ran for: ${HTX_DURATION}
George Keishing8b082fd2017-05-03 13:42:39 -0500134
Steven Sombar16dba512017-10-20 07:20:08 -0500135 ${loop_count}= Catenate Ending iteration: ${iteration}
136 Rpvars loop_count
137
George Keishing13f44e52017-05-12 15:28:12 -0500138
Steven Sombara2f166c2017-08-02 14:22:45 -0500139Do Inventory And Compare
Steven Sombar130a04f2017-07-16 10:02:37 -0500140 [Documentation] Do inventory and compare.
141 [Arguments] ${inventory_file_path} ${last_inventory_file_path}
142 # Description of argument(s):
143 # inventory_file_path The file to receive the inventory snapshot.
144 # last_inventory_file_path The previous inventory to compare with.
145
146 Create JSON Inventory File ${inventory_file_path}
147 Run Keyword If '${last_inventory_file_path}' != '${EMPTY}'
148 ... Compare Json Inventory Files ${inventory_file_path}
149 ... ${last_inventory_file_path}
150 ${last_inventory_file_path}= Set Variable ${inventory_file_path}
151 Set Suite Variable ${last_inventory_file_path} children=true
152
153
154Compare Json Inventory Files
155 [Documentation] Compare JSON inventory files.
156 [Arguments] ${file1} ${file2}
157 # Description of argument(s):
158 # file1 A file that has an inventory snapshot in JSON format.
159 # file2 A file that has an inventory snapshot, to compare with file1.
160
Steven Sombarb6749a62017-10-06 08:34:23 -0500161 ${diff_rc}= File_Diff ${file1}
Steven Sombar48ad01d2017-08-17 14:17:37 -0500162 ... ${file2} ${json_diff_file_path} ${INV_IGNORE_LIST}
Steven Sombar130a04f2017-07-16 10:02:37 -0500163 Run Keyword If '${diff_rc}' != '${0}'
164 ... Report Inventory Mismatch ${diff_rc} ${json_diff_file_path}
165
166
167Report Inventory Mismatch
168 [Documentation] Report inventory mismatch.
169 [Arguments] ${diff_rc} ${json_diff_file_path}
170 # Description of argument(s):
171 # diff_rc The failing return code from the difference check.
172 # json_diff_file_path The file that has the latest inventory snapshot.
173
Steven Sombara2216d22017-08-09 12:18:00 -0500174 Log To Console Significant difference in inventory found, rc=${diff_rc}
175 Log To Console Differences are listed in file: no_newline=true
176 Log To Console ${json_diff_file_path}
177 Log To Console File Contents:
178 Wait Until Created ${json_diff_file_path}
179 ${file_contents}= OperatingSystem.Get File ${json_diff_file_path}
180 Log ${file_contents} level=WARN
181 Fail Significant difference in inventory found, rc=${diff_rc}
Steven Sombar130a04f2017-07-16 10:02:37 -0500182
183
George Keishing8b082fd2017-05-03 13:42:39 -0500184Loop HTX Health Check
George Keishingffbe8ce2017-05-04 12:08:54 -0500185 [Documentation] Run until HTX exerciser fails.
George Keishing8b082fd2017-05-03 13:42:39 -0500186 Repeat Keyword ${HTX_DURATION}
187 ... Run Keywords Check HTX Run Status
188 ... AND Sleep ${HTX_INTERVAL}
189
190
George Keishingffbe8ce2017-05-04 12:08:54 -0500191Post Test Case Execution
192 [Documentation] Do the post test teardown.
193 # 1. Shut down HTX exerciser if test Failed.
194 # 2. Capture FFDC on test failure.
195 # 3. Close all open SSH connections.
196
George Keishing1a23b692017-05-06 12:19:41 -0500197 # Keep HTX running if user set HTX_KEEP_RUNNING to 1.
Steven Sombar130a04f2017-07-16 10:02:37 -0500198 Run Keyword If
199 ... '${TEST_STATUS}' == 'FAIL' and ${HTX_KEEP_RUNNING} == ${0}
George Keishingffbe8ce2017-05-04 12:08:54 -0500200 ... Shutdown HTX Exerciser
201
George Keishingae5d9782017-06-12 13:35:59 -0500202 ${keyword_buf}= Catenate Stop SOL Console Logging
203 ... \ targ_file_path=${EXECDIR}${/}logs${/}SOL.log
204 Run Key ${keyword_buf}
205
George Keishingffbe8ce2017-05-04 12:08:54 -0500206 FFDC On Test Case Fail
207 Close All Connections