1*** Settings ***
2Documentation    Test Redfish event service.
3
4Resource         ../../../lib/resource.robot
5Resource         ../../../lib/bmc_redfish_resource.robot
6Resource         ../../../lib/openbmc_ffdc.robot
7Resource         ../../../lib/bmc_redfish_utils.robot
8
9Test Setup       Test Setup Execution
10Test Teardown    Test Teardown Execution
11Suite Setup      Suite Setup Execution
12Suite teardown   Run Keyword And Ignore Error  Delete All Redfish Sessions
13
14***Variables***
15
16${REMOTE_SERVER_IP}
17
18** Test Cases **
19
20Verify Event Service Available
21    [Documentation]  Verify Redfish event service is available.
22    [Tags]  Verify_Event_Service_Available
23
24    ${resp} =  Redfish_utils.Get Attribute  /redfish/v1/EventService  ServiceEnabled
25    Should Be Equal As Strings  ${resp}  ${True}
26
27
28Verify Subscribe An Event
29    [Documentation]  Subscribe to an event and verify.
30    [Tags]  Verify_Subscribe_An_Event
31
32    ${subscription_list}=  Redfish_Utils.Get Member List
33    ...  /redfish/v1/EventService/Subscriptions
34
35    Should Be Empty  ${subscription_list}
36
37    ${RegistryPrefixes_list}=  Create List  Base  OpenBMC  TaskEvent
38    ${ResourceTypes_list}=  Create List  Task
39
40    ${payload}=  Create Dictionary
41    ...  Context=Test_Context  Destination=https://${REMOTE_SERVER_IP}:${HTTPS_PORT}/
42    ...  EventFormatType=Event  Protocol=Redfish  SubscriptionType=RedfishEvent
43    ...  RegistryPrefixes=${RegistryPrefixes_list}  ResourceTypes=${ResourceTypes_list}
44
45    Redfish.Post  /redfish/v1/EventService/Subscriptions  body=&{payload}
46    ...  valid_status_codes=[${HTTP_CREATED}]
47
48    ${subscription_list}=  Redfish_Utils.Get Member List
49    ...  /redfish/v1/EventService/Subscriptions
50
51    ${resp}=  redfish.Get  ${subscription_list[0]}
52
53    Dictionary Should Contain Sub Dictionary   ${resp.dict}  ${payload}
54
55
56*** Keywords ***
57
58Suite Setup Execution
59    [Documentation]  Do the suite setup.
60
61    Should Not be Empty  ${REMOTE_SERVER_IP}
62    Should Not be Empty  ${HTTPS_PORT}
63
64
65Test Setup Execution
66    [Documentation]  Do the test setup.
67
68    Redfish.Login
69
70    ${subscription_list}=  Redfish_Utils.Get Member List
71    ...  /redfish/v1/EventService/Subscriptions
72
73    Delete All Subscriptions  ${subscription_list}
74
75
76Test Teardown Execution
77    [Documentation]  Do the post test teardown.
78
79    FFDC On Test Case Fail
80    Run Keyword And Ignore Error  Redfish.Logout
81
82
83Delete All Subscriptions
84    [Documentation]  Delete all subscriptions.
85    [Arguments]   ${subscription_list}
86
87    # Description of argument(s):
88    # subscription_list   List of all subscriptions.
89
90    FOR  ${url}  IN  @{subscription_list}
91      Redfish.Delete  ${url}
92    END
93
94