1*** Settings ***
2Documentation       REST test Error callout association.
3
4Resource            ../../../lib/bmc_redfish_resource.robot
5Resource            ../../../lib/bmc_redfish_utils.robot
6Resource            ../../../lib/connection_client.robot
7Resource            ../../../lib/openbmc_ffdc.robot
8Resource            ../../../lib/utils.robot
9Resource            ../../../lib/state_manager.robot
10Resource            ../../../lib/boot_utils.robot
11
12
13Suite Setup         Suite Setup Execution
14Suite Teardown      Suite Teardown Execution
15Test Setup          Test Setup Execution
16Test Teardown       FFDC On Test Case Fail
17
18Force Tags          Event_Association
19
20***Variables***
21${target_device_path}  /sys/devices/platform/gpio-fsi/fsi0/slave@00:00/raw
22
23${stack_mode}          skip
24
25*** Test Cases ***
26
27Create Test Error Callout And Verify
28    [Documentation]  Create error log callout and verify via REST.
29    [Tags]  Create_Test_Error_Callout_And_Verify
30
31    Create Test Error With Callout
32    Verify Test Error Log And Callout
33
34
35Create Test Error Callout And Verify AdditionalData
36    [Documentation]  Create Test Error Callout And Verify AdditionalData.
37    [Tags]  Create_Test_Error_Callout_And_Verify_AdditionalData
38
39    # Test error log entry example:
40    #  "/xyz/openbmc_project/logging/entry/1": {
41    #  "AdditionalData": [
42    #      "CALLOUT_DEVICE_PATH_TEST=/sys/devices/platform/fsi-master/slave@00:00",
43    #      "CALLOUT_ERRNO_TEST=0",
44    #      "DEV_ADDR=0x0DEADEAD"
45    #    ]
46
47    Create Test Error With Callout
48    ${elog_entry}=  Get Elog URL List
49    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
50    List Should Contain Value
51    ...  ${resp.json()["data"]["AdditionalData"]}  CALLOUT_DEVICE_PATH_TEST=${target_device_path}
52    List Should Contain Value  ${resp.json()["data"]["AdditionalData"]}  DEV_ADDR=0x0DEADEAD
53
54
55Create Test Error Callout And Verify Associations
56    [Documentation]  Create test error callout and verify Associations.
57    [Tags]  Create_Test_Error_Callout_And_Verify_Associations
58
59    # Test error log association entry example:
60    # "Associations": [
61    #   [
62    #        "callout",
63    #        "fault",
64    #        "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
65    #   ]
66    # ]
67
68    Create Test Error With Callout
69    ${elog_entry}=  Get Elog URL List
70    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
71    List Should Contain Value  ${resp.json()["data"]["Associations"][0]}  callout
72    List Should Contain Value  ${resp.json()["data"]["Associations"][0]}  fault
73    List Should Contain Value
74    ...  ${resp.json()["data"]["Associations"][0]}
75    ...  /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
76
77
78Create Test Error Callout And Delete
79    [Documentation]  Create Test Error Callout And Delete.
80    [Tags]  Create_Test_Error_Callout_And_Delete
81
82    # Test error log entry example:
83    #  "/xyz/openbmc_project/logging/entry/1": {
84    #  "AdditionalData": [
85    #      "CALLOUT_DEVICE_PATH_TEST=/sys/devices/platform/fsi-master/slave@00:00",
86    #      "CALLOUT_ERRNO_TEST=0",
87    #      "DEV_ADDR=0x0DEADEAD"
88    #    ],
89    #    "Id": 1,
90    #    "Message": "example.xyz.openbmc_project.Example.Elog.TestCallout",
91    #    "Resolved": 0,
92    #    "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
93    #    "Timestamp": 1487747332528,
94    #    "Associations": [
95    #        [
96    #          "callout",
97    #          "fault",
98    #          "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
99    #        ]
100    #    ]
101    # },
102    # "/xyz/openbmc_project/logging/entry/1/callout": {
103    #    "endpoints": [
104    #        "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
105    #    ]
106    # },
107
108    Create Test Error With Callout
109    ${elog_entry}=  Get Elog URL List
110    Delete Error Log Entry  ${elog_entry[0]}
111    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}/callout
112    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
113
114
115Create Two Test Error Callout And Delete
116    [Documentation]  Create Two Test Error Callout And Delete.
117    [Tags]  Create_Two_Test_Error_Callout_And_Delete
118
119    # Test error log entry example:
120    #  "/xyz/openbmc_project/logging/entry/1": {
121    #  "AdditionalData": [
122    #      "CALLOUT_DEVICE_PATH_TEST=/sys/devices/platform/fsi-master/slave@00:00",
123    #      "CALLOUT_ERRNO_TEST=0",
124    #      "DEV_ADDR=0x0DEADEAD"
125    #    ],
126    #    "Id": 1,
127    #    "Message": "example.xyz.openbmc_project.Example.Elog.TestCallout",
128    #    "Resolved": 0,
129    #    "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
130    #    "Timestamp": 1487747332528,
131    #    "Associations": [
132    #        [
133    #          "callout",
134    #          "fault",
135    #          "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
136    #        ]
137    #    ]
138    # },
139    # "/xyz/openbmc_project/logging/entry/1/callout": {
140    #    "endpoints": [
141    #        "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
142    #    ]
143    # },
144    # "/xyz/openbmc_project/logging/entry/2": {
145    #  "AdditionalData": [
146    #      "CALLOUT_DEVICE_PATH_TEST=/sys/devices/platform/fsi-master/slave@00:00",
147    #      "CALLOUT_ERRNO_TEST=0",
148    #      "DEV_ADDR=0x0DEADEAD"
149    #    ],
150    #    "Id": 2,
151    #    "Message": "example.xyz.openbmc_project.Example.Elog.TestCallout",
152    #    "Resolved": 0,
153    #    "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
154    #    "Timestamp": 1487747332528,
155    #    "Associations": [
156    #        [
157    #          "callout",
158    #          "fault",
159    #          "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
160    #        ]
161    #    ]
162    # },
163    # "/xyz/openbmc_project/logging/entry/2/callout": {
164    #    "endpoints": [
165    #        "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
166    #    ]
167    # },
168
169    # Create two error logs.
170    Create Test Error With Callout
171    Create Test Error With Callout
172
173    # Delete entry/2 elog entry.
174    ${elog_entry}=  Get Elog URL List
175    Delete Error Log Entry  ${elog_entry[1]}
176
177    # Verify if entry/1 exist and entry/2 is deleted.
178    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
179    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
180    ${resp}=  OpenBMC Get Request  ${elog_entry[1]}
181    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
182
183
184Create Test Error Callout And Verify LED
185    [Documentation]  Create an error log callout and verify respective
186    ...  LED state.
187    [Tags]  Create_Test_Error_Callout_And_Verify_LED
188
189    Create Test Error With Callout
190
191    ${resp}=  Get LED State XYZ  cpu0_fault
192    Should Be Equal  ${resp}  ${1}
193
194
195Set Resolved Field And Verify Callout Deletion
196    [Documentation]  Set the "Resolved" error log and verify callout is deleted
197    [Tags]  Set_Resolved_Field_And_Verify_Callout_Deletion
198
199    Delete All Error Logs
200    Create Test Error With Callout
201    ${elog_entry}=  Get URL List  ${BMC_LOGGING_ENTRY}
202    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
203    Should Contain  ${resp.json()["data"]["Associations"][0]}  callout
204
205    # Set the error log field "Resolved".
206    # By doing so, the callout object should get deleted automatically.
207    ${valueDict}=  Create Dictionary  data=${1}
208    OpenBMC Put Request  ${elog_entry[0]}/attr/Resolved  data=${valueDict}
209
210    # Verify if the callout entry is deleted.
211    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}/callout
212    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
213
214*** Keywords ***
215
216Callout Test Binary Exist
217    [Documentation]  Verify existence of prerequisite callout-test.
218
219    Open Connection And Log In
220    ${out}  ${stderr}=  Execute Command
221    ...  which /tmp/tarball/bin/callout-test  return_stderr=True
222    Should Be Empty  ${stderr}
223    Should Contain  ${out}  callout-test
224
225
226Create Test Error With Callout
227    [Documentation]  Generate test error log with callout for CPU0.
228
229    # Test error log entry example:
230    #  "/xyz/openbmc_project/logging/entry/4": {
231    #  "AdditionalData": [
232    #      "CALLOUT_DEVICE_PATH_TEST=/sys/devices/platform/fsi-master/slave@00:00",
233    #      "CALLOUT_ERRNO_TEST=0",
234    #      "DEV_ADDR=0x0DEADEAD"
235    #    ],
236    #    "Id": 4,
237    #    "Message": "example.xyz.openbmc_project.Example.Elog.TestCallout",
238    #    "Resolved": 0,
239    #    "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
240    #    "Timestamp": 1487747332528,
241    #    "Associations": [
242    #        [
243    #          "callout",
244    #          "fault",
245    #          "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
246    #        ]
247    #    ]
248    # },
249    # "/xyz/openbmc_project/logging/entry/4/callout": {
250    #    "endpoints": [
251    #        "/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0"
252    #    ]
253    # },
254
255    BMC Execute Command
256    ...  /tmp/tarball/bin/callout-test ${target_device_path}
257
258Verify Test Error Log And Callout
259    [Documentation]  Verify test error log entries.
260    ${elog_entry}=  Get Elog URL List
261    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
262
263    Should Be Equal  ${resp.json()["data"]["Message"]}
264    ...  example.xyz.openbmc_project.Example.Elog.TestCallout
265
266    Should Be Equal  ${resp.json()["data"]["Severity"]}
267    ...  xyz.openbmc_project.Logging.Entry.Level.Error
268
269    ${content}=  Read Attribute  ${elog_entry[0]}/callout  endpoints
270
271    Should Be Equal  ${content[0]}
272    ...  /xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0
273
274
275Test Setup Execution
276    [Documentation]  Do test case setup tasks.
277
278    ${status}=  Run Keyword And Return Status  Callout Test Binary Exist
279    Run Keyword If  ${status} == ${False}  Install Tarball
280    Delete All Error Logs
281
282
283Install Tarball
284    [Documentation]  Install tarball on BMC.
285
286    Run Keyword If  '${DEBUG_TARBALL_PATH}' == '${EMPTY}'  Return from Keyword
287    BMC Execute Command  rm -rf /tmp/tarball
288    Install Debug Tarball On BMC  ${DEBUG_TARBALL_PATH}
289
290
291Suite Setup Execution
292   [Documentation]  Do test case setup tasks.
293
294    Redfish.Login
295
296    Redfish Purge Event Log
297
298    Redfish Power On  stack_mode=skip  quiet=1
299
300    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
301    Run Keyword If  ${status} == ${False}  Install Tarball
302
303
304Suite Teardown Execution
305    [Documentation]  Do the post suite teardown.
306
307    Redfish.Logout
308