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