xref: /openbmc/openbmc-test-automation/extended/standby_bmc.robot (revision 597ffa0b1af6e8321eb37b22c8899772a4b3d728)
1*** Settings ***
2Documentation     This module will take whatever action is necessary
3...               to bring the BMC to a stable, standby state.  For our
4...               purposes, a stable state is defined as:
5...                  - BMC is communicating
6...                   (pinging, sshing and REST commands working)
7...                  - Power state is 0 (off)
8...                  - BMC state is "BMC_READY" or "HOST_POWERED_OFF"
9...                  - Boot policy is "RESTORE_LAST_STATE"
10
11Resource          ../lib/boot/boot_resource_master.robot
12Resource          ../lib/utils.robot
13
14*** Variables ***
15${HOST_SETTING}      /org/openbmc/settings/host0
16
17*** Test cases ***
18
19Get to Stable State
20    [Documentation]    BMC cleanup drive to stable state
21    ...                1. Ping Test
22    ...                2. SSH Connection session Test
23    ...                3. REST Connection session Test
24    ...                4. Reboot BMC if REST Test failed
25    ...                5. Check BMC state for standby
26    ...                6. Issue poweroff if not already in
27    ...                   standby state
28    ...                7. Update restore policy
29    [Tags]  Get to Stable State
30
31    Wait For Host To Ping  ${OPENBMC_HOST}  1 mins
32    Open Connection And Log In   host=${OPENBMC_HOST}
33
34    ${l_rest}=   Run Keyword And Return Status
35    ...    Initialize OpenBMC
36    Run Keyword If  '${l_rest}' == '${False}'
37    ...    Reboot and Wait for BMC Online
38
39    ${l_ready}=   Run Keyword And Return Status
40    ...    Get BMC State and Expect Standby
41
42    Run Keyword If  '${l_ready}' == '${False}'
43    ...    Initiate Power Off
44
45    Update Policy Setting   RESTORE_LAST_STATE
46
47
48*** Keywords ***
49
50Reboot and Wait for BMC Online
51    [Documentation]    Reboot BMC and wait for it to come online
52    ...                and boot to standby
53
54    Trigger Warm Reset via Reboot
55    Wait Until Keyword Succeeds
56    ...    5 min   10 sec    BMC Online Test
57
58    Wait For BMC Standby
59
60
61BMC Online Test
62    [Documentation]   BMC ping, SSH, REST connection Test
63
64    ${l_status}=   Run Keyword and Return Status
65    ...   Verify Ping and REST Authentication
66    Run Keyword If  '${l_status}' == '${False}'
67    ...   Fail  msg=System not in ideal state to continue [ERROR]
68
69
70Wait For BMC Standby
71    [Documentation]   Wait Until BMC standby post BMC reboot
72
73    @{states}=   Create List   BMC_READY   HOST_POWERED_OFF
74    Wait Until Keyword Succeeds
75    ...    10 min   10 sec   Verify BMC State   ${states}
76
77
78Get BMC State and Expect Standby
79    [Documentation]   Get BMC state and should be at standby
80
81    @{states}=     Create List   BMC_READY   HOST_POWERED_OFF
82    ${bmc_state}=  Get BMC State
83    Should Contain  ${states}   ${bmc_state}
84
85
86Update Policy Setting
87    [Documentation]   Update the given restore policy
88    [arguments]   ${policy}
89
90    ${valueDict}=     create dictionary  data=${policy}
91    Write Attribute    ${HOST_SETTING}    power_policy   data=${valueDict}
92    ${currentPolicy}=  Read Attribute     ${HOST_SETTING}   power_policy
93    Should Be Equal    ${currentPolicy}   ${policy}
94
95