xref: /openbmc/openbmc-test-automation/redfish/managers/test_managers_bmc.robot (revision 4d4302835588e40baff7a7ccaf1f705c9b224911)
122872e55SGeorge Keishing*** Settings ***
2dbfe97dbSJoy OnyerikwuDocumentation    Test BMC Manager functionality.
32db7bcaeSGeorge KeishingResource         ../../lib/resource.robot
422872e55SGeorge KeishingResource         ../../lib/bmc_redfish_resource.robot
522872e55SGeorge KeishingResource         ../../lib/common_utils.robot
63298d5c3SGeorge KeishingResource         ../../lib/openbmc_ffdc.robot
7ba0441ccSGeorge KeishingResource         ../../lib/boot_utils.robot
844f890b1SGeorge KeishingResource         ../../lib/open_power_utils.robot
9224377beSGeorge KeishingResource         ../../lib/bmc_network_utils.robot
10224377beSGeorge KeishingLibrary          ../../lib/gen_robot_valid.py
1122872e55SGeorge Keishing
1297c93945SGeorge KeishingTest Setup       Test Setup Execution
1349f46332SGeorge KeishingTest Teardown    Test Teardown Execution
1422872e55SGeorge Keishing
15912094bbSGeorge Keishing
16912094bbSGeorge Keishing*** Variables ***
17912094bbSGeorge Keishing
18912094bbSGeorge Keishing${SYSTEM_SHUTDOWN_TIME}    ${5}
19912094bbSGeorge Keishing
20912094bbSGeorge Keishing# Strings to check from journald.
219fae1669Saravinth0510${REBOOT_REGEX}    ^\-- Boot | Startup finished
22912094bbSGeorge Keishing
2322872e55SGeorge Keishing*** Test Cases ***
2422872e55SGeorge Keishing
255ee33d93SGeorge KeishingVerify Redfish BMC Firmware Version
2622872e55SGeorge Keishing    [Documentation]  Get firmware version from BMC manager.
275ee33d93SGeorge Keishing    [Tags]  Verify_Redfish_BMC_Firmware_Version
2822872e55SGeorge Keishing
2997c93945SGeorge Keishing    Redfish.Login
30*4d430283Sganesanb    ${resp}=  Redfish.Get  /redfish/v1/Managers/${MANAGER_ID}
3122872e55SGeorge Keishing    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
3222872e55SGeorge Keishing    ${bmc_version}=  Get BMC Version
3322872e55SGeorge Keishing    Should Be Equal As Strings
3422872e55SGeorge Keishing    ...  ${resp.dict["FirmwareVersion"]}  ${bmc_version.strip('"')}
3522872e55SGeorge Keishing
3622872e55SGeorge Keishing
375ee33d93SGeorge KeishingVerify Redfish BMC Manager Properties
3822872e55SGeorge Keishing    [Documentation]  Verify BMC managers resource properties.
395ee33d93SGeorge Keishing    [Tags]  Verify_Redfish_BMC_Manager_Properties
4022872e55SGeorge Keishing
4197c93945SGeorge Keishing    Redfish.Login
42*4d430283Sganesanb    ${resp}=  Redfish.Get  /redfish/v1/Managers/${MANAGER_ID}
4322872e55SGeorge Keishing    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
4422872e55SGeorge Keishing    # Example:
4522872e55SGeorge Keishing    #  "Description": "Baseboard Management Controller"
4622872e55SGeorge Keishing    #  "Id": "bmc"
4722872e55SGeorge Keishing    #  "Model": "OpenBmc",
4822872e55SGeorge Keishing    #  "Name": "OpenBmc Manager",
4922872e55SGeorge Keishing    #  "UUID": "xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx"
5022872e55SGeorge Keishing    #  "PowerState": "On"
5122872e55SGeorge Keishing
5222872e55SGeorge Keishing    Should Be Equal As Strings
5322872e55SGeorge Keishing    ...  ${resp.dict["Description"]}  Baseboard Management Controller
5422872e55SGeorge Keishing    Should Be Equal As Strings  ${resp.dict["Id"]}  bmc
5522872e55SGeorge Keishing    Should Be Equal As Strings  ${resp.dict["Name"]}  OpenBmc Manager
5622872e55SGeorge Keishing    Should Not Be Empty  ${resp.dict["UUID"]}
5722872e55SGeorge Keishing    Should Be Equal As Strings  ${resp.dict["PowerState"]}  On
5822872e55SGeorge Keishing
5922872e55SGeorge Keishing
60224377beSGeorge KeishingVerify MAC Address Property Is Populated
61224377beSGeorge Keishing    [Documentation]  Verify BMC managers resource properties.
62224377beSGeorge Keishing    [Tags]  Verify_MAC_Address_Property_Is_Populated
63224377beSGeorge Keishing
6411789a21SGeorge Keishing    # Get OrderedDict from the BMC which contains active ethernet channel.
6511789a21SGeorge Keishing    # Example: ([('1', {'name': 'eth0',
6611789a21SGeorge Keishing    #                   'is_valid': True,
6711789a21SGeorge Keishing    #                   'active_sessions': 0,
6811789a21SGeorge Keishing    #                   'channel_info': {'medium_type': 'lan-802.3',
6911789a21SGeorge Keishing    #                                    'protocol_type': 'ipmb-1.0',
7011789a21SGeorge Keishing    #                                    'session_supported': 'multi-session',
7111789a21SGeorge Keishing    #                                    'is_ipmi': True
7211789a21SGeorge Keishing    #                                   }
7311789a21SGeorge Keishing    #                  }
7411789a21SGeorge Keishing    #          )])
7511789a21SGeorge Keishing
7611789a21SGeorge Keishing    ${active_channel_config}=  Get Active Channel Config
7711789a21SGeorge Keishing
7811789a21SGeorge Keishing    FOR  ${channel_number}  IN  @{active_channel_config.keys()}
7911789a21SGeorge Keishing        Log Dictionary  ${active_channel_config["${channel_number}"]}
8011789a21SGeorge Keishing
81a3b203c2Saravinth0510        # Skip channel if is_valid is false for the channel number
82a3b203c2Saravinth0510        Continue For Loop If
83a3b203c2Saravinth0510        ...  ${active_channel_config["${channel_number}"]["is_valid"]}==${FALSE}
84a3b203c2Saravinth0510
8511789a21SGeorge Keishing        # Get ethernet valid paths in redfish.
86*4d430283Sganesanb        # Example: ['/redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces']
8711789a21SGeorge Keishing        ${eth_interface}=  redfish_utils.Get Endpoint Path List
8811789a21SGeorge Keishing        ...  /redfish/v1/Managers/  EthernetInterfaces
8911789a21SGeorge Keishing
9011789a21SGeorge Keishing        # Get the MACAddress attrivute value with the 'name': 'eth0'.
91*4d430283Sganesanb        # Example: /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/eth0
9211789a21SGeorge Keishing        ${redfish_mac_addr}=  Redfish.Get Attribute
9311789a21SGeorge Keishing        ...  ${eth_interface[0]}/${active_channel_config["${channel_number}"]["name"]}
9411789a21SGeorge Keishing        ...  MACAddress
9511789a21SGeorge Keishing    END
9611789a21SGeorge Keishing
97224377beSGeorge Keishing    Rprint Vars  redfish_mac_addr  fmt=terse
98e7edb22cSMichael Walsh    Valid Value  redfish_mac_addr
99224377beSGeorge Keishing
100224377beSGeorge Keishing    ${ipaddr_mac_addr}=  Get BMC MAC Address List
101224377beSGeorge Keishing    Rprint Vars  ipaddr_mac_addr  fmt=terse
102224377beSGeorge Keishing
103224377beSGeorge Keishing    List Should Contain Value  ${ipaddr_mac_addr}  ${redfish_mac_addr}
104224377beSGeorge Keishing
105224377beSGeorge Keishing
106ba0441ccSGeorge KeishingRedfish BMC Manager GracefulRestart When Host Off
107ba0441ccSGeorge Keishing    [Documentation]  BMC graceful restart when host is powered off.
108ba0441ccSGeorge Keishing    [Tags]  Redfish_BMC_Manager_GracefulRestart_When_Host_Off
10922872e55SGeorge Keishing
11022872e55SGeorge Keishing    # "Actions": {
11122872e55SGeorge Keishing    # "#Manager.Reset": {
11222872e55SGeorge Keishing    #  "ResetType@Redfish.AllowableValues": [
113b910d89bSSushil Singh    #    "GracefulRestart",
114b910d89bSSushil Singh    #    "ForceRestart"
11522872e55SGeorge Keishing    #  ],
116*4d430283Sganesanb    #  "target": "/redfish/v1/Managers/${MANAGER_ID}/Actions/Manager.Reset"
11722872e55SGeorge Keishing    # }
11822872e55SGeorge Keishing
119912094bbSGeorge Keishing    ${test_file_path}=  Set Variable  /tmp/before_bmcreboot
120912094bbSGeorge Keishing    BMC Execute Command  touch ${test_file_path}
121912094bbSGeorge Keishing
122b910d89bSSushil Singh    Redfish Power Off  stack_mode=skip
123b910d89bSSushil Singh
124b910d89bSSushil Singh    Redfish BMC Reset Operation  reset_type=GracefulRestart
125b910d89bSSushil Singh
126b910d89bSSushil Singh    Is BMC Standby
127b910d89bSSushil Singh
128e9ebf91cSGeorge Keishing    ${stdout}  ${stderr}  ${rc}=  BMC Execute Command  test ! -f ${test_file_path}  print_out=1
129b910d89bSSushil Singh    Verify BMC RTC And UTC Time Drift
130b910d89bSSushil Singh
131b910d89bSSushil Singh    # Check for journald persistency post reboot.
1329fae1669Saravinth0510    Wait Until Keyword Succeeds  3 min  10 sec
1339fae1669Saravinth0510    ...  Check For Regex In Journald  ${REBOOT_REGEX}  error_check=${1}
134b910d89bSSushil Singh
135b910d89bSSushil Singh
136b910d89bSSushil SinghRedfish BMC Manager ForceRestart When Host Off
137b910d89bSSushil Singh    [Documentation]  BMC force restart when host is powered off.
138b910d89bSSushil Singh    [Tags]  Redfish_BMC_Manager_ForceRestart_When_Host_Off
139b910d89bSSushil Singh
140b910d89bSSushil Singh    # "Actions": {
141b910d89bSSushil Singh    # "#Manager.Reset": {
142b910d89bSSushil Singh    #  "ResetType@Redfish.AllowableValues": [
143b910d89bSSushil Singh    #    "GracefulRestart",
144b910d89bSSushil Singh    #    "ForceRestart"
145b910d89bSSushil Singh    #  ],
146*4d430283Sganesanb    #  "target": "/redfish/v1/Managers/${MANAGER_ID}/Actions/Manager.Reset"
147b910d89bSSushil Singh    # }
148b910d89bSSushil Singh
149b910d89bSSushil Singh    ${test_file_path}=  Set Variable  /tmp/before_bmcreboot
150b910d89bSSushil Singh    BMC Execute Command  touch ${test_file_path}
151b910d89bSSushil Singh
152b910d89bSSushil Singh    Redfish Power Off  stack_mode=skip
153b910d89bSSushil Singh
154b910d89bSSushil Singh    Redfish BMC Reset Operation  reset_type=ForceRestart
155b910d89bSSushil Singh
156b910d89bSSushil Singh    Is BMC Standby
15722872e55SGeorge Keishing
158e9ebf91cSGeorge Keishing    ${stdout}  ${stderr}  ${rc}=  BMC Execute Command  test ! -f ${test_file_path}  print_out=1
159912094bbSGeorge Keishing    Verify BMC RTC And UTC Time Drift
160912094bbSGeorge Keishing
161912094bbSGeorge Keishing    # Check for journald persistency post reboot.
1629fae1669Saravinth0510    Wait Until Keyword Succeeds  3 min  10 sec
1639fae1669Saravinth0510    ...  Check For Regex In Journald  ${REBOOT_REGEX}  error_check=${1}
164912094bbSGeorge Keishing
165ba0441ccSGeorge Keishing
166e210d599SGeorge KeishingVerify Boot Count After BMC Reboot
167e210d599SGeorge Keishing    [Documentation]  Verify boot count increments on BMC reboot.
168e210d599SGeorge Keishing    [Tags]  Verify_Boot_Count_After_BMC_Reboot
16983f3118aSaravinth0510    [Setup]  Run Keywords  Update NTP Test Initial Status  AND
17083f3118aSaravinth0510    ...  Set NTP state  ${TRUE}
17183f3118aSaravinth0510    [Teardown]  Restore NTP Status
172e210d599SGeorge Keishing
173e210d599SGeorge Keishing    Set BMC Boot Count  ${0}
174e210d599SGeorge Keishing    Redfish OBMC Reboot (off)
175e210d599SGeorge Keishing    ${boot_count}=  Get BMC Boot Count
176e210d599SGeorge Keishing    Should Be Equal  ${boot_count}  ${1}  msg=Boot count is not incremented.
177e210d599SGeorge Keishing
178e210d599SGeorge Keishing
179ba0441ccSGeorge KeishingRedfish BMC Manager GracefulRestart When Host Booted
180ba0441ccSGeorge Keishing    [Documentation]  BMC graceful restart when host is running.
181ba0441ccSGeorge Keishing    [Tags]  Redfish_BMC_Manager_GracefulRestart_When_Host_Booted
182ba0441ccSGeorge Keishing
183ba0441ccSGeorge Keishing    Redfish OBMC Reboot (run)
184ba0441ccSGeorge Keishing
18544f890b1SGeorge Keishing    # TODO: Replace OCC state check with redfish property when available.
186e9ebf91cSGeorge Keishing    Wait Until Keyword Succeeds  10 min  30 sec  Verify OCC State
18744f890b1SGeorge Keishing
18822872e55SGeorge Keishing
18997c93945SGeorge Keishing*** Keywords ***
19022872e55SGeorge Keishing
19197c93945SGeorge KeishingTest Setup Execution
19297c93945SGeorge Keishing    [Documentation]  Do test case setup tasks.
19397c93945SGeorge Keishing
19497c93945SGeorge Keishing    redfish.Login
19597c93945SGeorge Keishing
19697c93945SGeorge Keishing
19797c93945SGeorge KeishingTest Teardown Execution
19897c93945SGeorge Keishing    [Documentation]  Do the post test teardown.
19997c93945SGeorge Keishing
20097c93945SGeorge Keishing    FFDC On Test Case Fail
201780ee112SGeorge Keishing    Run Keyword And Ignore Error  redfish.Logout
20283f3118aSaravinth0510
20383f3118aSaravinth0510
20483f3118aSaravinth0510Update NTP Test Initial Status
20583f3118aSaravinth0510    [Documentation]  Update the initial status of NTP.
20683f3118aSaravinth0510
207a69ca6a7SGeorge Keishing    Redfish.Login
20883f3118aSaravinth0510    ${original_ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP
20983f3118aSaravinth0510    Set Suite Variable  ${original_ntp}
21083f3118aSaravinth0510
21183f3118aSaravinth0510
21283f3118aSaravinth0510Set NTP state
21383f3118aSaravinth0510    [Documentation]  Set NTP service inactive.
21483f3118aSaravinth0510    [Arguments]  ${state}
21583f3118aSaravinth0510
216a69ca6a7SGeorge Keishing    Redfish.Login
21783f3118aSaravinth0510    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${state}}}
21883f3118aSaravinth0510    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
21983f3118aSaravinth0510
22083f3118aSaravinth0510
22183f3118aSaravinth0510Restore NTP Status
22283f3118aSaravinth0510    [Documentation]  Restore NTP Status.
22383f3118aSaravinth0510
22483f3118aSaravinth0510    Run Keyword If  '${original_ntp["ProtocolEnabled"]}' == 'True'
22583f3118aSaravinth0510    ...    Set NTP state  ${TRUE}
22683f3118aSaravinth0510    ...  ELSE  Set NTP state  ${FALSE}
227