xref: /openbmc/openbmc-test-automation/redfish/systems/eventlog/test_event_service.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
178059b65STony Lee*** Settings ***
2ba868646SGeorge KeishingDocumentation    Test Redfish event service subscription function.
378059b65STony Lee
478059b65STony LeeResource         ../../../lib/resource.robot
578059b65STony LeeResource         ../../../lib/bmc_redfish_resource.robot
678059b65STony LeeResource         ../../../lib/openbmc_ffdc.robot
778059b65STony LeeResource         ../../../lib/bmc_redfish_utils.robot
878059b65STony Lee
9ba868646SGeorge KeishingSuite Setup      Suite Setup Execution
10ba868646SGeorge KeishingSuite teardown   Suite Teardown Execution
11ba868646SGeorge Keishing
1278059b65STony LeeTest Setup       Test Setup Execution
1378059b65STony LeeTest Teardown    Test Teardown Execution
1478059b65STony Lee
15*6fb70d98SMatt FischerTest Tags       Event_Service
16f699f55dSGeorge Keishing
1778059b65STony Lee***Variables***
1878059b65STony Lee
19ba868646SGeorge Keishing# override this default using -v REMOTE_SERVER_IP:<IP> from CLI
20ba868646SGeorge Keishing${REMOTE_SERVER_IP}    10.7.7.7
2178059b65STony Lee
2278059b65STony Lee** Test Cases **
2378059b65STony Lee
24ba868646SGeorge KeishingVerify Add Subscribe Server For Event Notification
25ba868646SGeorge Keishing    [Documentation]  Subscribe a remote server and verify if added successful.
26ba868646SGeorge Keishing    [Tags]  Verify_Add_Subscribe_Server_For_Event_Notification
2778059b65STony Lee
2878059b65STony Lee    ${subscription_list}=  Redfish_Utils.Get Member List
2978059b65STony Lee    ...  /redfish/v1/EventService/Subscriptions
3078059b65STony Lee
3178059b65STony Lee    Should Be Empty  ${subscription_list}
3278059b65STony Lee
3362acabc3STim Lee    ${RegistryPrefixes_list}=  Create List  Base  OpenBMC  TaskEvent
3478059b65STony Lee    ${ResourceTypes_list}=  Create List  Task
3578059b65STony Lee
3678059b65STony Lee    ${payload}=  Create Dictionary
3778059b65STony Lee    ...  Context=Test_Context  Destination=https://${REMOTE_SERVER_IP}:${HTTPS_PORT}/
38380880d6STim Lee    ...  EventFormatType=Event  Protocol=Redfish  SubscriptionType=RedfishEvent
39380880d6STim Lee    ...  RegistryPrefixes=${RegistryPrefixes_list}  ResourceTypes=${ResourceTypes_list}
4078059b65STony Lee
4178059b65STony Lee    Redfish.Post  /redfish/v1/EventService/Subscriptions  body=&{payload}
4278059b65STony Lee    ...  valid_status_codes=[${HTTP_CREATED}]
4378059b65STony Lee
4478059b65STony Lee    ${subscription_list}=  Redfish_Utils.Get Member List
4578059b65STony Lee    ...  /redfish/v1/EventService/Subscriptions
4678059b65STony Lee
4778059b65STony Lee    ${resp}=  redfish.Get  ${subscription_list[0]}
4878059b65STony Lee
4978059b65STony Lee    Dictionary Should Contain Sub Dictionary   ${resp.dict}  ${payload}
5078059b65STony Lee
5178059b65STony Lee
5278059b65STony Lee*** Keywords ***
5378059b65STony Lee
5478059b65STony LeeSuite Setup Execution
5578059b65STony Lee    [Documentation]  Do the suite setup.
5678059b65STony Lee
5778059b65STony Lee    Should Not be Empty  ${REMOTE_SERVER_IP}
5878059b65STony Lee    Should Not be Empty  ${HTTPS_PORT}
5978059b65STony Lee
60ba868646SGeorge Keishing    Redfish.Login
61ba868646SGeorge Keishing
62ba868646SGeorge Keishing
63ba868646SGeorge KeishingSuite Teardown Execution
64ba868646SGeorge Keishing    [Documentation]  Do the suite teardown.
65ba868646SGeorge Keishing
66ba868646SGeorge Keishing    Run Keyword And Ignore Error  Delete All Redfish Sessions
67ba868646SGeorge Keishing    Run Keyword And Ignore Error  Redfish.Logout
68ba868646SGeorge Keishing
6978059b65STony Lee
7078059b65STony LeeTest Setup Execution
7178059b65STony Lee    [Documentation]  Do the test setup.
7278059b65STony Lee
7378059b65STony Lee    ${subscription_list}=  Redfish_Utils.Get Member List
7478059b65STony Lee    ...  /redfish/v1/EventService/Subscriptions
7578059b65STony Lee
7678059b65STony Lee    Delete All Subscriptions  ${subscription_list}
7778059b65STony Lee
78ba868646SGeorge Keishing    # Verify Redfish event service attribute ServiceEnabled is set to True.
79ba868646SGeorge Keishing    ${resp} =  Redfish_utils.Get Attribute  /redfish/v1/EventService  ServiceEnabled
80ba868646SGeorge Keishing    Should Be Equal As Strings  ${resp}  ${True}
81ba868646SGeorge Keishing
8278059b65STony Lee
8378059b65STony LeeTest Teardown Execution
8478059b65STony Lee    [Documentation]  Do the post test teardown.
8578059b65STony Lee
8678059b65STony Lee    FFDC On Test Case Fail
87ba868646SGeorge Keishing
88ba868646SGeorge Keishing    ${subscription_list}=  Redfish_Utils.Get Member List
89ba868646SGeorge Keishing    ...  /redfish/v1/EventService/Subscriptions
90ba868646SGeorge Keishing
91ba868646SGeorge Keishing    Delete All Subscriptions  ${subscription_list}
9278059b65STony Lee
9378059b65STony Lee
9478059b65STony LeeDelete All Subscriptions
9578059b65STony Lee    [Documentation]  Delete all subscriptions.
9678059b65STony Lee    [Arguments]   ${subscription_list}
9778059b65STony Lee
9878059b65STony Lee    # Description of argument(s):
9978059b65STony Lee    # subscription_list   List of all subscriptions.
10078059b65STony Lee
10178059b65STony Lee    FOR  ${url}  IN  @{subscription_list}
10278059b65STony Lee      Redfish.Delete  ${url}
10378059b65STony Lee    END
10478059b65STony Lee
105