xref: /openbmc/openbmc-test-automation/redfish/extended/test_bmc_dump.robot (revision ce2e7aee3c678eefb48fcf62b65820b2459fe390)
1*** Settings ***
2
3Documentation       Test dump functionality of OpenBMC.
4
5Resource            ../../lib/openbmc_ffdc.robot
6Resource            ../../lib/rest_client.robot
7Resource            ../../lib/dump_utils.robot
8Resource            ../../lib/boot_utils.robot
9Resource            ../../lib/utils.robot
10Resource            ../../lib/state_manager.robot
11Library             ../../lib/bmc_ssh_utils.py
12
13Test Setup          Open Connection And Log In
14Test Teardown       Test Teardown Execution
15
16*** Test Cases ***
17
18Pre Dump BMC Performance Test
19    [Documentation]  Check performance of memory, CPU & file system of BMC.
20    [Tags]  Pre_Dump_BMC_Performance_Test
21
22    Open Connection And Log In
23    Check BMC Performance
24
25
26Verify User Initiated BMC Dump When Powered Off
27    [Documentation]  Create user initiated BMC dump at host off state and
28    ...  verify dump entry for it.
29    [Tags]  Verify_User_Initiated_BMC_Dump_When_Powered_Off
30
31    Redfish Power Off  stack_mode=skip
32    ${dump_id}=  Create User Initiated Dump
33    Check Existence of BMC Dump file  ${dump_id}
34
35
36Verify Dump Persistency On Service Restart
37    [Documentation]  Create user dump, restart BMC service and verify dump
38    ...  persistency.
39    [Tags]  Verify_Dump_Persistency_On_Service_Restart
40
41    Delete All BMC Dump
42    ${dump_id}=  Create User Initiated Dump
43    BMC Execute Command
44    ...  systemctl restart xyz.openbmc_project.Dump.Manager.service
45    Sleep  10s  reason=Wait for BMC dump service to restart properly.
46
47    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}list
48    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
49    Check Existence of BMC Dump file  ${dump_id}
50
51
52Verify Dump Persistency On Reset
53    [Documentation]  Create user dump, reset BMC and verify dump persistency.
54    [Tags]  Verify_Dump_Persistency_On_Reset
55
56    Delete All BMC Dump
57    ${dump_id}=  Create User Initiated Dump
58    OBMC Reboot (off)
59    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}list
60    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
61    Check Existence of BMC Dump file  ${dump_id}
62
63
64Delete User Initiated BMC Dump And Verify
65    [Documentation]  Delete user initiated dump and verify.
66    [Tags]  Delete_User_Initiated_Dump_And_Verify
67
68    ${dump_id}=  Create User Initiated Dump
69    Check Existence of BMC Dump file  ${dump_id}
70
71    Delete BMC Dump  ${dump_id}
72
73
74Verify User Initiated Dump Size
75    [Documentation]  Verify user Initiated BMC dump size is under 200k.
76    [Tags]  Verify_User_Initiated_Dump_Size
77
78    ${dump_id}=  Create User Initiated Dump
79
80    ${dump_size}=  Read Attribute  ${DUMP_ENTRY_URI}${dump_id}  Size
81    # Max size for dump is 200k = 200x1024
82    Should Be True  0 < ${dump_size} < 204800
83    Check Existence of BMC Dump file  ${dump_id}
84
85
86Create Two User Initiated Dump And Delete One
87    [Documentation]  Create two dumps and delete the first.
88    [Tags]  Create_Two_User_Initiated_Dump_And_Delete_One
89
90    ${dump_id_1}=  Create User Initiated Dump
91    ${dump_id_2}=  Create User Initiated Dump
92
93    Delete BMC Dump  ${dump_id_1}
94
95    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}${dump_id_1}
96    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
97
98    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}${dump_id_2}
99    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
100    Check Existence of BMC Dump file  ${dump_id_2}
101
102
103Create And Delete BMC Dump Multiple Times
104    [Documentation]  Create and delete BMC dump multiple times.
105    [Tags]  Create_And_Delete_BMC_Dump_Multiple_Times
106
107    :FOR  ${INDEX}  IN RANGE  1  5
108    \  ${dump_id}=  Create User Initiated Dump
109    \  Delete BMC Dump  ${dump_id}
110
111
112Delete All BMC Dumps And Verify
113    [Documentation]  Delete all BMC dumps and verify.
114    [Tags]  Delete_All_BMC_Dumps_And_Verify
115
116    # Create some dump.
117    Create User Initiated Dump
118    Create User Initiated Dump
119
120    Delete All BMC Dump
121    ${resp}=  OpenBMC Get Request  ${DUMP_ENTRY_URI}list
122    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
123
124
125Verify User Initiated BMC Dump When Host Booted
126    [Documentation]  Create user initiated BMC dump at host booted state and
127    ...  verify dump entry for it.
128    [Tags]  Verify_User_Initiated_BMC_Dump_When_Host_Booted
129
130    Redfish Power On  stack_mode=skip
131    Create User Initiated Dump
132
133
134Verify Core Dump Size
135    [Documentation]  Verify BMC core dump size is under 200k.
136    [Tags]  Verify_Core_Dump_Size
137
138    Delete All Dumps
139    Trigger Core Dump
140    Wait Until Keyword Succeeds  2 min  10 sec  Get Dump Entries
141
142    ${dump_entries}=  Get URL List  ${DUMP_ENTRY_URI}
143    ${dump_size}=  Read Attribute  ${dump_entries[0]}  Size
144
145    # Max size for dump is 200k = 200x1024
146    Should Be True  0 < ${dump_size} < 204800  msg=Size of dump is incorrect.
147
148
149Dump Out Of Space Test
150    [Documentation]  Verify out of dump space is reported when attempt
151    ...  to create too many dumps.
152    [Tags]  Dump_Out_Of_Space_Test
153    [Setup]  Delete All BMC Dump
154
155    # Systems typically hold 8-14 dumps before running out of dump space.
156    # Attempt to create too_many_dumps.  Expect to run out of space
157    # before this.
158    ${too_many_dumps}  Set Variable  ${100}
159
160    # Should be able to create at least this many dumps.
161    ${minimum_number_of_dumps}   Set Variable  ${7}
162
163    # Loop, creating a dump each iteration.  Will either get dump_id or
164    # will get EMPTY when out of dump space.
165    :FOR  ${n}  IN RANGE  ${too_many_dumps}
166    \  ${dump_id}=  Create User Initiated Dump  check_out_of_space=${True}
167    \  Exit For Loop If  '${dump_id}' == '${EMPTY}'
168    \  Check Existence of BMC Dump file  ${dump_id}
169
170    Run Keyword If  '${dump_id}' != '${EMPTY}'  Fail
171    ...  msg=Did not run out of dump space as expected.
172
173    Run Keyword If  ${n} < ${minimum_number_of_dumps}  Fail
174    ...  msg=Insufficient space for at least ${minimum_number_of_dumps} dumps.
175
176
177Post Dump BMC Performance Test
178    [Documentation]  Check performance of memory, CPU & file system of BMC.
179    [Tags]  Post_Dump_BMC_Performance_Test
180
181    Open Connection And Log In
182    Check BMC Performance
183
184
185Post Dump Core Dump Check
186    [Documentation]  Check core dump existence on BMC after code update.
187    [Tags]  Post_Dump_Core_Dump_Check
188
189    Check For Core Dumps
190
191
192Verify Dump After Host Watchdog Error Injection
193    [Documentation]  Inject host watchdog error and verify whether dump is generated.
194    [Tags]  Verify_Dump_After_Host_Watchdog_Error_Injection
195
196    Redfish Power On
197
198    Run Keyword And Ignore Error  Delete All Dumps
199
200    # Enable auto reboot
201    Set Auto Reboot  ${1}
202
203    Trigger Host Watchdog Error  2000  30
204
205    Wait Until Keyword Succeeds  300 sec  20 sec  Is Host Rebooted
206
207    #Get dump details
208    @{dump_entry_list}=  Read Properties  ${DUMP_ENTRY_URI}
209
210    # Verifing that there is only one dump
211    ${length}=  Get length  ${dump_entry_list}
212    Should Be Equal As Integers  ${length}  ${1}
213
214    # Get dump id
215    ${value}=  Get From List  ${dump_entry_list}  0
216    @{split_value}=  Split String  ${value}  /
217    ${dump_id}=  Get From List  ${split_value}  -1
218
219    # Max size for dump is 200k = 200x1024
220    ${dump_size}=  Read Attribute  ${DUMP_ENTRY_URI}${dump_id}  Size
221    Should Be True  0 < ${dump_size} < 204800
222
223
224Verify Download BMC Dump
225    [Documentation]  Verify that a BMC dump can be downloaded to the local machine.
226    [Tags]  Verify_Download_BMC_Dump
227
228    ${dump_id}=  Create User Initiated Dump
229    ${dump_dict}=  Get Dump Dict
230    ${bmc_dump_name}=  Fetch From Right  ${dump_dict['${dump_id}']}  /
231    ${bmc_dump_checksum}  ${stderr}  ${rc}=  BMC Execute Command
232    ...  md5sum ${dump_dict['${dump_id}']}|awk '{print$1}'
233    ${bmc_dump_size}  ${stderr}  ${rc}=  BMC Execute Command
234    ...  stat -c "%s" ${dump_dict['${dump_id}']}
235
236    ${response}=  OpenBMC Get Request  ${DUMP_DOWNLOAD_URI}${dump_id}
237    ...  quiet=${1}
238    Should Be Equal As Strings  ${response.status_code}  ${HTTP_OK}
239    Create Binary File  ${EXECDIR}${/}dumps   ${response.content}
240    Run  tar -xvf ${EXECDIR}${/}dumps
241    ${download_dump_name}=  Fetch From Left  ${bmc_dump_name}  .
242    ${download_dump_checksum}=  Run  md5sum ${EXECDIR}/dumps|awk '{print$1}'
243    ${download_dump_size}=  Run  stat -c "%s" ${EXECDIR}${/}dumps
244
245    OperatingSystem.Directory Should Exist  ${EXECDIR}/${download_dump_name}
246    ...  msg=Created dump name and downloaded dump name don't match.
247    Should Be Equal As Strings  ${bmc_dump_checksum}  ${download_dump_checksum}
248    Should Be Equal As Strings  ${bmc_dump_size}  ${download_dump_size}
249
250    Run  rm -rf ${EXECDIR}${/}${download_dump_name};rm ${EXECDIR}${/}dumps
251
252
253*** Keywords ***
254
255Test Teardown Execution
256    [Documentation]  Do the post test teardown.
257
258    Wait Until Keyword Succeeds  3 min  15 sec  Verify No Dump In Progress
259    FFDC On Test Case Fail
260    Delete All BMC Dump
261    Close All Connections
262