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