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
13Suite Setup         Suite Setup Execution
14Test Setup          Open Connection And Log In
15Test Teardown       Test Teardown Execution
16
17*** Test Cases ***
18
19Verify Core Dump Size
20    [Documentation]  Verify BMC core dump size is under 200k.
21    [Tags]  Verify_Core_Dump_Size
22
23    Redfish Delete All BMC Dumps
24    Trigger Core Dump
25    Wait Until Keyword Succeeds  2 min  10 sec  Get Dump Entries
26
27    ${dump_entries}=  Get URL List  ${DUMP_ENTRY_URI}
28    ${dump_size}=  Read Attribute  ${dump_entries[0]}  Size
29
30    # Max size for dump is 200k = 200x1024
31    Should Be True  0 < ${dump_size} < 204800  msg=Size of dump is incorrect.
32
33
34Verify Dump After Host Watchdog Error Injection
35    [Documentation]  Inject host watchdog error and verify whether dump is generated.
36    [Tags]  Verify_Dump_After_Host_Watchdog_Error_Injection
37
38    Redfish Power On
39
40    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
41
42    # Enable auto reboot
43    Set Auto Reboot  ${1}
44
45    Set Watchdog Interval Using Busctl  2000
46
47    Wait Until Keyword Succeeds  300 sec  20 sec  Is Host Rebooted
48
49    #Get dump details
50    @{dump_entry_list}=  Read Properties  ${DUMP_ENTRY_URI}
51
52    # Verifying that there is only one dump
53    ${length}=  Get length  ${dump_entry_list}
54    Should Be Equal As Integers  ${length}  ${1}
55
56    # Get dump id
57    ${value}=  Get From List  ${dump_entry_list}  0
58    @{split_value}=  Split String  ${value}  /
59    ${dump_id}=  Get From List  ${split_value}  -1
60
61    # Max size for dump is 200k = 200x1024
62    ${dump_size}=  Read Attribute  ${DUMP_ENTRY_URI}${dump_id}  Size
63    Should Be True  0 < ${dump_size} < 204800
64
65
66Verify Download BMC Dump
67    [Documentation]  Verify that a BMC dump can be downloaded to the local machine.
68    [Tags]  Verify_Download_BMC_Dump
69
70    ${dump_id}=  Create User Initiated BMC Dump Via Redfish
71    ${dump_dict}=  Get Dump Dict
72    ${bmc_dump_name}=  Fetch From Right  ${dump_dict['${dump_id}']}  /
73    ${bmc_dump_checksum}  ${stderr}  ${rc}=  BMC Execute Command
74    ...  md5sum ${dump_dict['${dump_id}']}|awk '{print$1}'
75    ${bmc_dump_size}  ${stderr}  ${rc}=  BMC Execute Command
76    ...  stat -c "%s" ${dump_dict['${dump_id}']}
77
78    ${response}=  OpenBMC Get Request  ${DUMP_DOWNLOAD_URI}${dump_id}
79    ...  quiet=${1}
80    Should Be Equal As Strings  ${response.status_code}  ${HTTP_OK}
81    Create Binary File  ${EXECDIR}${/}dumps   ${response.content}
82    Run  tar -xvf ${EXECDIR}${/}dumps
83    ${download_dump_name}=  Fetch From Left  ${bmc_dump_name}  .
84    ${download_dump_checksum}=  Run  md5sum ${EXECDIR}/dumps|awk '{print$1}'
85    ${download_dump_size}=  Run  stat -c "%s" ${EXECDIR}${/}dumps
86
87    OperatingSystem.Directory Should Exist  ${EXECDIR}/${download_dump_name}
88    ...  msg=Created dump name and downloaded dump name don't match.
89    Should Be Equal As Strings  ${bmc_dump_checksum}  ${download_dump_checksum}
90    Should Be Equal As Strings  ${bmc_dump_size}  ${download_dump_size}
91
92    Run  rm -rf ${EXECDIR}${/}${download_dump_name};rm ${EXECDIR}${/}dumps
93
94
95*** Keywords ***
96
97Suite Setup Execution
98    [Documentation]  Do initial suite setup tasks.
99
100    ${resp}=  OpenBMC Get Request  ${DUMP_URI}
101    Run Keyword If  '${resp.status_code}' == '${HTTP_NOT_FOUND}'
102    ...  Run Keywords  Set Suite Variable  ${DUMP_URI}  /xyz/openbmc_project/dump/  AND
103    ...  Set Suite Variable  ${DUMP_ENTRY_URI}  /xyz/openbmc_project/dump/entry/
104
105
106Test Teardown Execution
107    [Documentation]  Do the post test teardown.
108
109    Wait Until Keyword Succeeds  3 min  15 sec  Verify No Dump In Progress
110    FFDC On Test Case Fail
111    Delete All BMC Dump
112    Close All Connections
113