xref: /openbmc/openbmc-test-automation/extended/standby_bmc.robot (revision 34298bfc9a688f286fa6201208fe16eafa7d3c5d)
178ea2dc3SGeorge Keishing*** Settings ***
278ea2dc3SGeorge KeishingDocumentation     This module will take whatever action is necessary
378ea2dc3SGeorge Keishing...               to bring the BMC to a stable, standby state.  For our
478ea2dc3SGeorge Keishing...               purposes, a stable state is defined as:
578ea2dc3SGeorge Keishing...                  - BMC is communicating
678ea2dc3SGeorge Keishing...                   (pinging, sshing and REST commands working)
778ea2dc3SGeorge Keishing...                  - Power state is 0 (off)
82c725044SRahul Maheshwari...                  - BMC state is "Ready"
92c725044SRahul Maheshwari...                  - HOST state is "Off"
10efc3ff2bSGeorge Keishing...                  - Boot policy is "ALWAYS_POWER_OFF"
1134d4b8d1SGeorge Keishing...               Power cycle system via PDU if specified
120bd59f1bSGeorge Keishing...               Prune archived journal logs
1378ea2dc3SGeorge Keishing
1478ea2dc3SGeorge KeishingResource          ../lib/utils.robot
1534d4b8d1SGeorge KeishingResource          ../lib/pdu/pdu.robot
169bd3abcfSRahul MaheshwariResource          ../lib/state_manager.robot
171b0ceb23SMichael WalshResource          ../lib/bmc_network_utils.robot
18ec6fe31bSSunil MResource          ../lib/bmc_cleanup.robot
1927a1f20aSGeorge KeishingResource          ../lib/dump_utils.robot
20caa718bfSGeorge KeishingResource          ../lib/bmc_redfish_resource.robot
21caa718bfSGeorge KeishingResource          ../lib/bmc_redfish_utils.robot
22c7748be3SGeorge KeishingLibrary           ../lib/gen_misc.py
2378ea2dc3SGeorge Keishing
248dd04affSGeorge Keishing# Force the test to timedout to prevent test hanging.
258dd04affSGeorge KeishingTest Timeout      10 minutes
268dd04affSGeorge Keishing
278dd04affSGeorge Keishing
2878ea2dc3SGeorge Keishing*** Variables ***
2978ea2dc3SGeorge Keishing${HOST_SETTING}      /org/openbmc/settings/host0
3078ea2dc3SGeorge Keishing
31c7748be3SGeorge Keishing${ERROR_REGEX}  xyz.openbmc_project.Software.BMC.Updater.service: Failed with result 'core-dump'
32c7748be3SGeorge Keishing
337c8923f0SGunnar Mills*** Test Cases ***
3478ea2dc3SGeorge Keishing
3562f94303SGeorge KeishingGet To Stable State
3678ea2dc3SGeorge Keishing    [Documentation]  BMC cleanup drive to stable state
3734d4b8d1SGeorge Keishing    ...              1. PDU powercycle if specified
3878ea2dc3SGeorge Keishing    ...              1. Ping Test
3978ea2dc3SGeorge Keishing    ...              2. SSH Connection session Test
4078ea2dc3SGeorge Keishing    ...              3. REST Connection session Test
4178ea2dc3SGeorge Keishing    ...              4. Reboot BMC if REST Test failed
422c725044SRahul Maheshwari    ...              5. Get BMC in Ready state if its not in this state
432c725044SRahul Maheshwari    ...              6. Get Host in Off state if its not in this state
4478ea2dc3SGeorge Keishing    ...              7. Update restore policy
4589fb0f5eSSunil M    ...              8. Verify and Update MAC address.
4662f94303SGeorge Keishing    [Tags]  Get_To_Stable_State
4778ea2dc3SGeorge Keishing
4834d4b8d1SGeorge Keishing    Run Keyword And Ignore Error  Powercycle System Via PDU
4934d4b8d1SGeorge Keishing
5013497eb8SGeorge Keishing    ${ping_status}=  Run Keyword And Return Status
5113497eb8SGeorge Keishing    ...  Wait For Host To Ping  ${OPENBMC_HOST}  2 mins
5213497eb8SGeorge Keishing
5313497eb8SGeorge Keishing    # Check if the ping works using 1400 MTU.
54e31e2232SGeorge Keishing    #Run Keyword if  ${ping_status} == ${True}  MTU Ping Test
5513497eb8SGeorge Keishing
5613497eb8SGeorge Keishing    Run Keyword if  ${ping_status} == ${False}
5713497eb8SGeorge Keishing    ...  Fail  ${OPENBMC_HOST} ping test failed.
5813497eb8SGeorge Keishing
5913497eb8SGeorge Keishing    Open Connection And Log In  host=${OPENBMC_HOST}
6078ea2dc3SGeorge Keishing
618dd04affSGeorge Keishing    Run Keyword If  ${REDFISH_SUPPORTED}
628dd04affSGeorge Keishing    ...    Redfish Clean Up
638dd04affSGeorge Keishing    ...  ELSE
648dd04affSGeorge Keishing    ...    REST Clean Up
65de2acae9SGeorge Keishing
668dd04affSGeorge Keishing
678dd04affSGeorge Keishing    Prune Journal Log
688dd04affSGeorge Keishing    Check For Current Boot Application Failures
698dd04affSGeorge Keishing
708dd04affSGeorge Keishing*** Keywords ***
718dd04affSGeorge Keishing
728dd04affSGeorge Keishing
738dd04affSGeorge KeishingREST Clean Up
748dd04affSGeorge Keishing    [Documentation]  Check states, reboot if needed and poweroff.
758dd04affSGeorge Keishing
768dd04affSGeorge Keishing    Wait Until Keyword Succeeds  1 min  30 sec  Initialize OpenBMC
7778ea2dc3SGeorge Keishing
789bd3abcfSRahul Maheshwari    ${ready_status}=  Run Keyword And Return Status  Is BMC Ready
79334df294SGeorge Keishing    Run Keyword If  '${ready_status}' == '${False}'
80334df294SGeorge Keishing    ...    Put BMC State  Ready
81334df294SGeorge Keishing    ...  ELSE
82334df294SGeorge Keishing    ...    REST Power Off  stack_mode=skip
8378ea2dc3SGeorge Keishing
84efc3ff2bSGeorge Keishing    Run Keyword And Ignore Error  Set BMC Power Policy  ${ALWAYS_POWER_OFF}
855dc827d3SSunil M    Run Keyword And Ignore Error  Delete All Error Logs
865dc827d3SSunil M    Run Keyword And Ignore Error  Delete All Dumps
878dd04affSGeorge Keishing
888dd04affSGeorge Keishing
898dd04affSGeorge KeishingRedfish Clean Up
908dd04affSGeorge Keishing    [Documentation]  Check states, reboot if needed and poweroff.
918dd04affSGeorge Keishing
928dd04affSGeorge Keishing    Wait Until Keyword Succeeds  1 min  30 sec  Redfish.Login
938dd04affSGeorge Keishing
948dd04affSGeorge Keishing    Redfish Power Off  stack_mode=skip
958dd04affSGeorge Keishing
968dd04affSGeorge Keishing    Run Keyword And Ignore Error  Redfish Set Power Restore Policy  AlwaysOff
978dd04affSGeorge Keishing    Run Keyword And Ignore Error  Redfish Purge Event Log
98033a7644SGeorge Keishing    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
992ef6a7dbSGeorge Keishing    Run Keyword And Ignore Error  Redfish Delete All System Dumps
100*34298bfcSAnusha Dathatri    Run Keyword And Ignore Error  Clear All Subscriptions
101caa718bfSGeorge Keishing    Run Keyword And Ignore Error  Delete All Redfish Sessions
10278ea2dc3SGeorge Keishing
10378ea2dc3SGeorge Keishing
10478ea2dc3SGeorge KeishingBMC Online Test
10578ea2dc3SGeorge Keishing    [Documentation]   BMC ping, SSH, REST connection Test
10678ea2dc3SGeorge Keishing
10778ea2dc3SGeorge Keishing    ${l_status}=   Run Keyword and Return Status
10878ea2dc3SGeorge Keishing    ...   Verify Ping and REST Authentication
10978ea2dc3SGeorge Keishing    Run Keyword If  '${l_status}' == '${False}'
11078ea2dc3SGeorge Keishing    ...   Fail  msg=System not in ideal state to continue [ERROR]
11178ea2dc3SGeorge Keishing
11278ea2dc3SGeorge Keishing
11378ea2dc3SGeorge KeishingUpdate Policy Setting
11478ea2dc3SGeorge Keishing    [Documentation]   Update the given restore policy
11538032805SGunnar Mills    [Arguments]   ${policy}
11678ea2dc3SGeorge Keishing
11778ea2dc3SGeorge Keishing    ${valueDict}=     create dictionary  data=${policy}
11878ea2dc3SGeorge Keishing    Write Attribute    ${HOST_SETTING}    power_policy   data=${valueDict}
11978ea2dc3SGeorge Keishing    ${currentPolicy}=  Read Attribute     ${HOST_SETTING}   power_policy
12078ea2dc3SGeorge Keishing    Should Be Equal    ${currentPolicy}   ${policy}
12178ea2dc3SGeorge Keishing
122d5123f75SGeorge Keishing
123d5123f75SGeorge KeishingTrigger Warm Reset via Reboot
124d5123f75SGeorge Keishing    [Documentation]    Execute reboot command on the remote BMC and
125d5123f75SGeorge Keishing    ...                returns immediately. This keyword "Start Command"
126d5123f75SGeorge Keishing    ...                returns nothing and does not wait for the command
127d5123f75SGeorge Keishing    ...                execution to be finished.
128d5123f75SGeorge Keishing    Open Connection And Log In
129d5123f75SGeorge Keishing
130d5123f75SGeorge Keishing    Start Command   /sbin/reboot
13134d4b8d1SGeorge Keishing
13234d4b8d1SGeorge Keishing
13334d4b8d1SGeorge KeishingPowercycle System Via PDU
134f4a807bfSJoy Onyerikwu    [Documentation]   AC cycle the system via PDU.
13534d4b8d1SGeorge Keishing
13634d4b8d1SGeorge Keishing    Validate Parameters
13734d4b8d1SGeorge Keishing    PDU Power Cycle
13834d4b8d1SGeorge Keishing    Check If BMC is Up   5 min    10 sec
13934d4b8d1SGeorge Keishing
14034d4b8d1SGeorge Keishing
1417cdb8b45SCharles Paul HoferCheck For Current Boot Application Failures
142c7748be3SGeorge Keishing    [Documentation]  Parse the journal log and check for failures.
143c7748be3SGeorge Keishing    [Arguments]  ${error_regex}=${ERROR_REGEX}
144c7748be3SGeorge Keishing
145c7748be3SGeorge Keishing    ${error_regex}=  Escape Bash Quotes  ${error_regex}
146c7748be3SGeorge Keishing    ${journal_log}  ${stderr}  ${rc}=  BMC Execute Command
147bcae08bcSCharles Paul Hofer    ...  journalctl -b --no-pager | egrep '${error_regex}'  ignore_err=1
148c7748be3SGeorge Keishing
149c7748be3SGeorge Keishing    Should Be Empty  ${journal_log}
150c7748be3SGeorge Keishing
151c7748be3SGeorge Keishing
15234d4b8d1SGeorge KeishingValidate Parameters
153f4a807bfSJoy Onyerikwu    [Documentation]  Validate PDU parameters.
15434d4b8d1SGeorge Keishing    Should Not Be Empty   ${PDU_IP}
15534d4b8d1SGeorge Keishing    Should Not Be Empty   ${PDU_TYPE}
15634d4b8d1SGeorge Keishing    Should Not Be Empty   ${PDU_SLOT_NO}
15734d4b8d1SGeorge Keishing    Should Not Be Empty   ${PDU_USERNAME}
15834d4b8d1SGeorge Keishing    Should Not Be Empty   ${PDU_PASSWORD}
15913497eb8SGeorge Keishing
16013497eb8SGeorge Keishing
16113497eb8SGeorge KeishingMTU Ping Test
16213497eb8SGeorge Keishing    [Documentation]  Ping test using MTU.
16313497eb8SGeorge Keishing    [Arguments]  ${mtu}=${1400}
16413497eb8SGeorge Keishing
16513497eb8SGeorge Keishing    # Description of argument(s):
16613497eb8SGeorge Keishing    # mtu   The maximum transmission unit (MTU) of a network interface.
16713497eb8SGeorge Keishing
16813497eb8SGeorge Keishing    ${rc}  ${output}=  Run And Return RC And Output
16913497eb8SGeorge Keishing    ...  ping -M do -s ${mtu} -c 10 ${OPENBMC_HOST}
17013497eb8SGeorge Keishing    Should Be Equal As Integers  ${rc}  0
17113497eb8SGeorge Keishing    Should Not Contain  ${output}  100% packet loss
172*34298bfcSAnusha Dathatri
173*34298bfcSAnusha Dathatri
174*34298bfcSAnusha DathatriClear All Subscriptions
175*34298bfcSAnusha Dathatri    [Documentation]  Delete all subscriptions.
176*34298bfcSAnusha Dathatri
177*34298bfcSAnusha Dathatri    ${subscriptions}=  Redfish.Get Attribute  /redfish/v1/EventService/Subscriptions  Members
178*34298bfcSAnusha Dathatri    FOR  ${subscription}  IN  @{subscriptions}
179*34298bfcSAnusha Dathatri        Redfish.Delete  ${subscription['@odata.id']}
180*34298bfcSAnusha Dathatri    END
181