1*** Settings ***
2Documentation             Test BMC using https://github.com/DMTF/Redfish-Usecase-Checkers
3...                       DMTF tool.
4
5Library                   OperatingSystem
6Library                   ../../lib/state.py
7Resource                  ../../lib/dmtf_tools_utils.robot
8Resource                  ../../lib/openbmc_ffdc.robot
9
10Test Setup                Test Setup Execution
11Test Teardown             Test Teardown Execution
12
13*** Variables ***
14
15${DEFAULT_PYTHON}         python3
16
17${rsv_github_url}         https://github.com/DMTF/Redfish-Usecase-Checkers.git
18${rsv_dir_path}           Redfish-Usecase-Checkers
19
20${command_account}        ${DEFAULT_PYTHON} ${rsv_dir_path}${/}account_management/account_management.py
21...                       -r ${OPENBMC_HOST} -u ${OPENBMC_USERNAME}
22...                       -p ${OPENBMC_PASSWORD} -S Always -d ${EXECDIR}${/}logs${/} -v
23
24${command_power_control}  ${DEFAULT_PYTHON} ${rsv_dir_path}${/}power_control/power_control.py
25...                       -r ${OPENBMC_HOST} -u ${OPENBMC_USERNAME}
26...                       -p ${OPENBMC_PASSWORD} -S Always --F
27
28${power_on_timeout}       15 mins
29${power_off_timeout}      15 mins
30${state_change_timeout}   3 mins
31
32*** Test Case ***
33
34Test BMC Redfish Account Management
35    [Documentation]  Check Account Management with a Redfish interface.
36    [Tags]  Test_BMC_Redfish_Account_Management
37
38    ${output}=  Run DMTF Tool  ${rsv_dir_path}  ${command_account}
39
40    ${output}=  Shell Cmd  cat ${EXECDIR}${/}logs${/}results.json
41    Log  ${output}
42
43
44Test BMC Redfish Boot Host And ForceOff
45    [Documentation]  Boot host and ForceOff.
46    [Tags]  Test_BMC_Redfish_Boot_Host_And_ForceOff
47
48    DMTF Power On
49    DMTF Hard Power Off
50
51
52Test BMC Redfish Boot Host And GracefulShutdown
53    [Documentation]  Boot host and issue GracefulShutdown.
54    [Tags]  Test_BMC_Redfish_Boot_Host_And_GracefulShutdown
55
56    DMTF Power On
57    DMTF Power Off
58
59
60*** Keywords ***
61
62Test Setup Execution
63    [Documentation]  Do test case setup tasks.
64
65    Printn
66    Download DMTF Tool  ${rsv_dir_path}  ${rsv_github_url}
67
68    ${status}  ${state}=  Run Keyword And Ignore Error
69    ...  Check State  standby_match_state
70    Return From Keyword If  '${status}' == 'PASS'
71    DMTF Power Off
72
73
74Test Teardown Execution
75    [Documentation]  Do the post-test teardown.
76
77    Printn
78    FFDC On Test Case Fail
79
80
81DMTF Power On
82    [Documentation]  Power the BMC machine on via DMTF tools.
83
84    Print Timen  Doing "DMTF Power On".
85
86    ${state}=  Get State
87    ${match_state}=  Anchor State  ${state}
88    Run DMTF Tool  ${rsv_dir_path}  ${command_power_control} On
89    ${state}=  Wait State  ${match_state}  wait_time=${state_change_timeout}  interval=10 seconds  invert=1
90    ${state}=  Wait State  os_running_match_state  wait_time=${power_on_timeout}  interval=10 seconds
91
92    [Return]  ${state}
93
94
95DMTF Power Off
96    [Documentation]  Power the BMC machine off via DMTF tools.
97
98    Print Timen  Doing "DMTF Hard Power Off".
99
100    ${state}=  Get State
101    ${match_state}=  Anchor State  ${state}
102    Run DMTF Tool  ${rsv_dir_path}  ${command_power_control} GracefulShutdown
103    ${state}=  Wait State  ${match_state}  wait_time=${state_change_timeout}  interval=10 seconds  invert=1
104    ${state}=  Wait State  standby_match_state  wait_time=${power_off_timeout}  interval=10 seconds
105
106    [Return]  ${state}
107
108
109DMTF Hard Power Off
110    [Documentation]  Power the BMC machine off via DMTF tools.
111
112    Print Timen  Doing "DMTF Hard Power Off".
113
114    ${state}=  Get State
115    ${match_state}=  Anchor State  ${state}
116    Run DMTF Tool  ${rsv_dir_path}  ${command_power_control} ForceOff
117    ${state}=  Wait State  ${match_state}  wait_time=${state_change_timeout}  interval=10 seconds  invert=1
118    ${state}=  Wait State  standby_match_state  wait_time=${power_off_timeout}  interval=10 seconds
119
120    [Return]  ${state}
121