1*** Settings ***
2Documentation   This suite tests Platform Event Log (PEL) functionality of OpenBMC.
3
4Library         ../../lib/pel_utils.py
5Variables       ../../data/pel_variables.py
6Resource        ../../lib/list_utils.robot
7Resource        ../../lib/openbmc_ffdc.robot
8
9Test Setup      Redfish.Login
10Test Teardown   Run Keywords  Redfish.Logout  AND  FFDC On Test Case Fail
11
12
13*** Variables ***
14
15${CMD_INTERNAL_FAILURE}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
16...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.InternalFailure
17...  xyz.openbmc_project.Logging.Entry.Level.Error 0
18
19${CMD_FRU_CALLOUT}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
20...  xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.Timeout
21...  xyz.openbmc_project.Logging.Entry.Level.Error 2 "TIMEOUT_IN_MSEC" "5"
22...  "CALLOUT_INVENTORY_PATH" "/xyz/openbmc_project/inventory/system/chassis/motherboard"
23
24${CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT}  busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
25...  xyz.openbmc_project.Logging.Create Create ssa{ss} org.open_power.Logging.Error.TestError1
26...  xyz.openbmc_project.Logging.Entry.Level.Error 0
27
28${CMD_INVENTORY_PREFIX}  busctl get-property xyz.openbmc_project.Inventory.Manager
29...  /xyz/openbmc_project/inventory/system/chassis/motherboard
30
31@{mandatory_pel_fileds}   Private Header  User Header  Primary SRC  Extended User Header  Failing MTMS
32
33
34*** Test Cases ***
35
36Create Test PEL Log And Verify
37    [Documentation]  Create PEL log using busctl command and verify via peltool.
38    [Tags]  Create_Test_PEL_Log_And_Verify
39
40    Redfish Purge Event Log
41    Create Test PEL Log
42    ${pel_id}=  Get PEL Log Via BMC CLI
43    Should Not Be Empty  ${pel_id}  msg=System PEL log entry is empty.
44
45
46Verify PEL Log Details
47    [Documentation]  Verify PEL log details via peltool.
48    [Tags]  Verify_PEL_Log_Details
49
50    Redfish Purge Event Log
51
52    ${bmc_time1}=  CLI Get BMC DateTime
53    Create Test PEL Log
54    ${bmc_time2}=  CLI Get BMC DateTime
55
56    ${pel_records}=  Peltool  -l
57
58    # Example output from 'Peltool  -l':
59    # pel_records:
60    # [0x50000012]:
61    #   [CreatorID]:                  BMC
62    #   [CompID]:                     0x1000
63    #   [PLID]:                       0x50000012
64    #   [Subsystem]:                  BMC Firmware
65    #   [Message]:                    An application had an internal failure
66    #   [SRC]:                        BD8D1002
67    #   [Commit Time]:                03/02/2020  09:35:15
68    #   [Sev]:                        Unrecoverable Error
69
70    ${ids}=  Get Dictionary Keys  ${pel_records}
71    ${id}=  Get From List  ${ids}  0
72
73    @{pel_fields}=  Create List  CreatorID  Subsystem  Message  Sev
74    FOR  ${field}  IN  @{pel_fields}
75      Valid Value  pel_records['${id}']['${field}']  ['${PEL_DETAILS['${field}']}']
76    END
77
78    Valid Value  pel_records['${id}']['PLID']  ['${id}']
79
80    # Verify if "CompID" and "SRC" fields of PEL has alphanumeric value.
81    Should Match Regexp  ${pel_records['${id}']['CompID']}  [a-zA-Z0-9]
82    Should Match Regexp  ${pel_records['${id}']['SRC']}  [a-zA-Z0-9]
83
84    ${pel_date_time}=  Convert Date  ${pel_records['${id}']['Commit Time']}
85    ...  date_format=%m/%d/%Y %H:%M:%S  exclude_millis=yes
86
87    # Convert BMC and PEL time to epoch time before comparing.
88    ${bmc_time1_epoch}=  Convert Date  ${bmc_time1}  epoch
89    ${pel_time_epoch}=  Convert Date  ${pel_date_time}  epoch
90    ${bmc_time2_epoch}=  Convert Date  ${bmc_time2}  epoch
91
92    Should Be True  ${bmc_time1_epoch} <= ${pel_time_epoch} <= ${bmc_time2_epoch}
93
94
95Verify Mandatory Sections Of Error Log PEL
96    [Documentation]  Verify mandatory sections of error log PEL.
97    [Tags]  Verify_Mandatory_Sections_Of_Error_Log_PEL
98
99    Create Test PEL Log
100
101    ${pel_ids}=  Get PEL Log Via BMC CLI
102    ${pel_id}=  Get From List  ${pel_ids}  -1
103    ${pel_output}=  Peltool  -i ${pel_id}
104    ${pel_sections}=  Get Dictionary Keys  ${pel_output}
105
106    List Should Contain Sub List  ${pel_sections}  ${mandatory_pel_fileds}
107
108
109Verify PEL Log Persistence After BMC Reboot
110    [Documentation]  Verify PEL log persistence after BMC reboot.
111    [Tags]  Verify_PEL_Log_Persistence_After_BMC_Reboot
112
113    Create Test PEL Log
114    ${pel_before_reboot}=  Get PEL Log Via BMC CLI
115
116    Redfish OBMC Reboot (off)
117    ${pel_after_reboot}=  Get PEL Log Via BMC CLI
118
119    List Should Contain Sub List  ${pel_after_reboot}  ${pel_before_reboot}
120
121
122Verify PEL ID Numbering
123    [Documentation]  Verify PEL ID numbering.
124    [Tags]  Verify_PEL_ID_Numbering
125
126    Redfish Purge Event Log
127    Create Test PEL Log
128    Create Test PEL Log
129
130    ${pel_ids}=  Get PEL Log Via BMC CLI
131
132    # Example of PEL IDs from PEL logs.
133    #  [0x50000012]:             <--- First PEL ID
134    #    [CreatorID]:                  BMC
135    #    [CompID]:                     0x1000
136    #    [PLID]:                       0x50000012
137    #    [Subsystem]:                  BMC Firmware
138    #    [Message]:                    An application had an internal failure
139    #    [SRC]:                        BD8D1002
140    #    [Commit Time]:                03/02/2020  09:35:15
141    #    [Sev]:                        Unrecoverable Error
142    #
143    #  [0x50000013]:             <--- Second PEL ID
144    #    [CreatorID]:                  BMC
145    #    [CompID]:                     0x1000
146    #    [PLID]:                       0x50000013
147    #    [Subsystem]:                  BMC Firmware
148    #    [Message]:                    An application had an internal failure
149    #    [SRC]:                        BD8D1002
150    #    [Commit Time]:                03/02/2020  09:35:15
151    #    [Sev]:                        Unrecoverable Error
152
153    Should Be True  ${pel_ids[1]} == ${pel_ids[0]}+1
154
155Verify Machine Type Model And Serial Number
156    [Documentation]  Verify machine type model and serial number from PEL.
157    [Tags]  Verify_Machine_Type_Model_And_Serial_Number
158
159    Create Test PEL Log
160
161    ${pel_ids}=  Get PEL Log Via BMC CLI
162    ${id}=  Get From List  ${pel_ids}  -1
163
164    ${pel_serial_number}=  Get PEL Field Value  ${id}  Failing MTMS  Serial Number
165    ${pel_serial_number}=  Replace String Using Regexp  ${pel_serial_number}  ^0+  ${EMPTY}
166    ${pel_machine_type_model}=  Get PEL Field Value  ${id}  Failing MTMS  Machine Type Model
167    ${pel_machine_type_model}=  Replace String Using Regexp  ${pel_machine_type_model}  ^0+  ${EMPTY}
168
169    # Example of "Machine Type Model" and "Serial Number" fields value from "Failing MTMS" section of PEL.
170    #  [Failing MTMS]:
171    #    [Created by]:                                 0x2000
172    #    [Machine Type Model]:                         1234-ABC   <---- Machine type
173    #    [Section Version]:                            1
174    #    [Serial Number]:                              ABCDEFG    <---- Serial number
175    #    [Sub-section type]:                           0
176
177    ${redfish_machine_model}=  Redfish.Get Attribute  /redfish/v1/Systems/system/  Model
178    ${redfish_machine_model}=  Replace String Using Regexp  ${redfish_machine_model}  ^0+  ${EMPTY}
179    ${redfish_serial_number}=  Redfish.Get Attribute  /redfish/v1/Systems/system/  SerialNumber
180    ${redfish_serial_number}=  Replace String Using Regexp  ${redfish_serial_number}  ^0+  ${EMPTY}
181
182    Valid Value  pel_machine_type_model  ['${redfish_machine_model}']
183    Valid Value  pel_serial_number  ['${redfish_serial_number}']
184
185    # Check "Machine Type Model" and "Serial Number" fields value from "Extended User Header" section of PEL.
186    ${pel_machine_type_model}=  Get PEL Field Value  ${id}  Extended User Header  Reporting Machine Type
187    ${pel_machine_type_model}=  Replace String Using Regexp  ${pel_machine_type_model}  ^0+  ${EMPTY}
188    ${pel_serial_number}=  Get PEL Field Value  ${id}  Extended User Header  Reporting Serial Number
189    ${pel_serial_number}=  Replace String Using Regexp  ${pel_serial_number}  ^0+  ${EMPTY}
190
191    Valid Value  pel_machine_type_model  ['${redfish_machine_model}']
192    Valid Value  pel_serial_number  ['${redfish_serial_number}']
193
194
195Verify Host Off State From PEL
196    [Documentation]  Verify Host off state from PEL.
197    [Tags]  Verify_Host_Off_State_From_PEL
198
199    Redfish Power Off  stack_mode=skip
200    Create Test PEL Log
201
202    ${pel_ids}=  Get PEL Log Via BMC CLI
203    ${id}=  Get From List  ${pel_ids}  -1
204    ${pel_host_state}=  Get PEL Field Value  ${id}  User Data  HostState
205
206    Valid Value  pel_host_state  ['Off']
207
208
209Verify BMC Version From PEL
210    [Documentation]  Verify BMC Version from PEL.
211    [Tags]  Verify_BMC_Version_From_PEL
212
213    Create Test PEL Log
214
215    ${pel_ids}=  Get PEL Log Via BMC CLI
216    ${id}=  Get From List  ${pel_ids}  -1
217    ${pel_bmc_version}=  Get PEL Field Value  ${id}  User Data  BMC Version ID
218
219    ${bmc_version}=  Get BMC Version
220    Valid Value  bmc_version  ['${bmc_version}']
221
222
223Verify PEL Log After Host Poweron
224    [Documentation]  Verify PEL log generation while booting host.
225    [Tags]  Verify_PEL_Log_After_Host_Poweron
226
227    Redfish Power Off  stack_mode=skip
228    Redfish Purge Event Log
229    Redfish Power On  stack_mode=skip
230
231    ${pel_informational_error}=  Get PEL Log IDs  User Header  Event Severity  Informational Event
232    ${pel_bmc_created_error}=  Get PEL Log IDs  Private Header  Creator Subsystem  BMC
233
234    # Get BMC created non-infomational error.
235    ${pel_bmc_error}=  Subtract Lists  ${pel_bmc_created_error}  ${pel_informational_error}
236
237    Should Be Empty  ${pel_bmc_error}  msg=Unexpected error log generated during Host poweron.
238
239
240Verify BMC Event Log ID
241    [Documentation]  Verify BMC Event Log ID from PEL.
242    [Tags]  Verify_BMC_Event_Log_ID
243
244    Redfish Purge Event Log
245    Create Test PEL Log
246
247    ${pel_ids}=  Get PEL Log Via BMC CLI
248    ${pel_bmc_event_log_id}=  Get PEL Field Value  ${pel_ids[0]}  Private Header  BMC Event Log Id
249
250    # Example "BMC Event Log Id" field value from "Private Header" section of PEL.
251    #  [Private Header]:
252    #    [Created at]:                 08/24/1928 12:04:06
253    #    [Created by]:                 0x584D
254    #    [Sub-section type]:           0
255    #    [Entry Id]:                   0x50000BB7
256    #    [Platform Log Id]:            0x8200061D
257    #    [CSSVER]:
258    #    [Section Version]:            1
259    #    [Creator Subsystem]:          PHYP
260    #    [BMC Event Log Id]:           341      <---- BMC event log id value
261    #    [Committed at]:               03/25/1920 12:06:22
262
263    ${redfish_event_logs}=  Redfish.Get Properties  /redfish/v1/Systems/system/LogServices/EventLog/Entries
264
265    # Example of redfish_event_logs output:
266    # redfish_event_logs:
267    #  [@odata.id]:                    /redfish/v1/Systems/system/LogServices/EventLog/Entries
268    #  [Name]:                         System Event Log Entries
269    #  [Members@odata.count]:          1
270    #  [@odata.type]:                  #LogEntryCollection.LogEntryCollection
271    #  [Description]:                  Collection of System Event Log Entries
272    #  [Members]:
273    #    [0]:
274    #      [@odata.id]:                /redfish/v1/Systems/system/LogServices/EventLog/Entries/235
275    #      [Name]:                     System Event Log Entry
276    #      [Severity]:                 Critical
277    #      [EntryType]:                Event
278    #      [Created]:                  2020-04-02T07:25:13+00:00
279    #      [@odata.type]:              #LogEntry.v1_5_1.LogEntry
280    #      [Id]:                       235          <----- Event log ID
281    #      [Message]:                  xyz.openbmc_project.Common.Error.InternalFailure
282
283    Valid Value  pel_bmc_event_log_id  ['${redfish_event_logs['Members'][0]['Id']}']
284
285
286Verify FRU Callout
287    [Documentation]  Verify FRU callout entries from PEL log.
288    [Tags]  Verify_FRU_Callout
289
290    Create Test PEL Log  FRU Callout
291
292    ${pel_ids}=  Get PEL Log Via BMC CLI
293    ${id}=  Get From List  ${pel_ids}  -1
294    ${pel_callout_section}=  Get PEL Field Value  ${id}  Primary SRC  Callout Section
295
296    # Example of PEL Callout Section from "peltool -i <id>" command.
297    #  [Callouts]:
298    #    [0]:
299    #      [FRU Type]:                 Normal Hardware FRU
300    #      [Priority]:                 Mandatory, replace all with this type as a unit
301    #      [Location Code]:            U78DA.ND1.1234567-P0
302    #      [Part Number]:              F191014
303    #      [CCIN]:                     2E2D
304    #      [Serial Number]:            YL2E2D010000
305    #  [Callout Count]:                1
306
307    Valid Value  pel_callout_section['Callout Count']  ['1']
308    Valid Value  pel_callout_section['Callouts'][0]['FRU Type']  ['Normal Hardware FRU']
309    Should Contain  ${pel_callout_section['Callouts'][0]['Priority']}  Mandatory
310
311    # Verify Location Code field of PEL callout with motherboard's Location Code.
312    ${busctl_output}=  BMC Execute Command  ${CMD_INVENTORY_PREFIX} com.ibm.ipzvpd.Location LocationCode
313    Should Be Equal  ${pel_callout_section['Callouts'][0]['Location Code']}
314    ...  ${busctl_output[0].split('"')[1].strip('"')}
315
316    # TODO: Compare CCIN and part number fields of PEL callout with Redfish or busctl output.
317    Should Match Regexp  ${pel_callout_section['Callouts'][0]['CCIN']}  [a-zA-Z0-9]
318    Should Match Regexp  ${pel_callout_section['Callouts'][0]['Part Number']}  [a-zA-Z0-9]
319
320    # Verify Serial Number field of PEL callout with motherboard's Serial Number.
321    ${busctl_output}=  BMC Execute Command
322    ...  ${CMD_INVENTORY_PREFIX} xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
323    Should Be Equal  ${pel_callout_section['Callouts'][0]['Serial Number']}
324    ...  ${busctl_output[0].split('"')[1].strip('"')}
325
326
327Verify Procedure And Symbolic FRU Callout
328    [Documentation]  Verify procedure and symbolic FRU callout from PEL log.
329    [Tags]  Verify_Procedure_And_Symbolic_FRU_Callout
330
331    Create Test PEL Log   Procedure And Symbolic FRU Callout
332
333    ${pel_ids}=  Get PEL Log Via BMC CLI
334    ${id}=  Get From List  ${pel_ids}  -1
335    ${pel_callout_section}=  Get PEL Field Value  ${id}  Primary SRC  Callout Section
336
337    # Example of PEL Callout Section from "peltool -i <id>" command.
338    #  [Callouts]:
339    #    [0]:
340    #      [Priority]:                                 Mandatory, replace all with this type as a unit
341    #      [Procedure Number]:                         BMCSP02
342    #      [FRU Type]:                                 Maintenance Procedure Required
343    #    [1]:
344    #      [Priority]:                                 Medium Priority
345    #      [Part Number]:                              SVCDOCS
346    #      [FRU Type]:                                 Symbolic FRU
347    #  [Callout Count]:                                2
348
349    Valid Value  pel_callout_section['Callout Count']  ['2']
350
351    # Verify procedural callout info.
352
353    Valid Value  pel_callout_section['Callouts'][0]['FRU Type']  ['Maintenance Procedure Required']
354    Should Contain  ${pel_callout_section['Callouts'][0]['Priority']}  Mandatory
355    # Verify if "Procedure Number" field of PEL has an alphanumeric value.
356    Should Match Regexp  ${pel_callout_section['Callouts'][0]['Procedure Number']}  [a-zA-Z0-9]
357
358    # Verify procedural callout info.
359
360    Valid Value  pel_callout_section['Callouts'][1]['FRU Type']  ['Symbolic FRU']
361    Should Contain  ${pel_callout_section['Callouts'][1]['Priority']}  Medium Priority
362    # Verify if "Part Number" field of Symbolic FRU has an alphanumeric value.
363    Should Match Regexp  ${pel_callout_section['Callouts'][1]['Part Number']}  [a-zA-Z0-9]
364
365
366Verify Delete All PEL
367    [Documentation]  Verify deleting all PEL logs.
368    [Tags]  Verify_Delete_All_PEL
369
370    Create Test PEL Log
371    Create Test PEL Log
372    Peltool  --delete-all  False
373
374    ${pel_ids}=  Get PEL Log Via BMC CLI
375    Should Be Empty  ${pel_ids}
376
377
378*** Keywords ***
379
380Create Test PEL Log
381    [Documentation]  Generate test PEL log.
382    [Arguments]  ${pel_type}=Internal Failure
383
384    # Description of argument(s):
385    # pel_type      The PEL type (e.g. Internal Failure, FRU Callout, Procedural Callout).
386
387    # Test PEL log entry example:
388    # {
389    #    "0x5000002D": {
390    #            "SRC": "BD8D1002",
391    #            "Message": "An application had an internal failure",
392    #            "PLID": "0x5000002D",
393    #            "CreatorID": "BMC",
394    #            "Subsystem": "BMC Firmware",
395    #            "Commit Time": "02/25/2020  04:47:09",
396    #            "Sev": "Unrecoverable Error",
397    #            "CompID": "0x1000"
398    #    }
399    # }
400
401    Run Keyword If  '${pel_type}' == 'Internal Failure'
402    ...   BMC Execute Command  ${CMD_INTERNAL_FAILURE}
403    ...  ELSE IF  '${pel_type}' == 'FRU Callout'
404    ...   BMC Execute Command  ${CMD_FRU_CALLOUT}
405    ...  ELSE IF  '${pel_type}' == 'Procedure And Symbolic FRU Callout'
406    ...   BMC Execute Command  ${CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT}
407
408
409Get PEL Log IDs
410    [Documentation]  Returns the list of PEL log IDs which contains given field's value.
411    [Arguments]  ${pel_section}  ${pel_field}  @{pel_field_value}
412
413    # Description of argument(s):
414    # pel_section      The section of PEL (e.g. Private Header, User Header).
415    # pel_field        The PEL field (e.g. Event Severity, Event Type).
416    # pel_field_value  The list of PEL's field value (e.g. Unrecoverable Error).
417
418    ${pel_ids}=  Get PEL Log Via BMC CLI
419    @{pel_id_list}=  Create List
420
421    FOR  ${id}  IN  @{pel_ids}
422      ${pel_output}=  Peltool  -i ${id}
423      # Example of PEL output from "peltool -i <id>" command.
424      #  [Private Header]:
425      #    [Created at]:                                 08/24/1928 12:04:06
426      #    [Created by]:                                 0x584D
427      #    [Sub-section type]:                           0
428      #    [Entry Id]:                                   0x50000BB7
429      #    [Platform Log Id]:                            0x8200061D
430      #    [CSSVER]:
431      #    [Section Version]:                            1
432      #    [Creator Subsystem]:                          PHYP
433      #    [BMC Event Log Id]:                           341
434      #    [Committed at]:                               03/25/1920 12:06:22
435      #  [User Header]:
436      #    [Log Committed by]:                           0x4552
437      #    [Action Flags]:
438      #      [0]:                                        Report Externally
439      #    [Subsystem]:                                  I/O Subsystem
440      #    [Event Type]:                                 Miscellaneous, Informational Only
441      #    [Sub-section type]:                           0
442      #    [Event Scope]:                                Entire Platform
443      #    [Event Severity]:                             Informational Event
444      #    [Host Transmission]:                          Not Sent
445      #    [Section Version]:                            1
446
447      ${pel_section_output}=  Get From Dictionary  ${pel_output}  ${pel_section}
448      ${pel_field_output}=  Get From Dictionary  ${pel_section_output}  ${pel_field}
449      Run Keyword If  '${pel_field_output}' in @{pel_field_value}  Append To List  ${pel_id_list}  ${id}
450    END
451    Sort List  ${pel_id_list}
452
453    [Return]  ${pel_id_list}
454
455
456Get PEL Log Via BMC CLI
457    [Documentation]  Returns the list of PEL IDs using BMC CLI.
458
459    ${pel_records}=  Peltool  -l
460    ${ids}=  Get Dictionary Keys  ${pel_records}
461    Sort List  ${ids}
462
463    [Return]  ${ids}
464
465
466Get PEL Field Value
467    [Documentation]  Returns the value of given PEL's field.
468    [Arguments]  ${pel_id}  ${pel_section}  ${pel_field}
469
470    # Description of argument(s):
471    # pel_id           The ID of PEL (e.g. 0x5000002D, 0x5000002E).
472    # pel_section      The section of PEL (e.g. Private Header, User Header)
473    # pel_field        The PEL field (e.g. Event Severity, Event Type).
474
475    ${pel_output}=  Peltool  -i ${pel_id}
476
477    # Example of PEL output from "peltool -i <id>" command.
478    #  [Private Header]:
479    #    [Created at]:                                 08/24/1928 12:04:06
480    #    [Created by]:                                 0x584D
481    #    [Sub-section type]:                           0
482    #    [Entry Id]:                                   0x50000BB7
483    #    [Platform Log Id]:                            0x8200061D
484    #    [CSSVER]:
485    #    [Section Version]:                            1
486    #    [Creator Subsystem]:                          PHYP
487    #    [BMC Event Log Id]:                           341
488    #    [Committed at]:                               03/25/1920 12:06:22
489    #  [User Header]:
490    #    [Log Committed by]:                           0x4552
491    #    [Action Flags]:
492    #      [0]:                                        Report Externally
493    #    [Subsystem]:                                  I/O Subsystem
494    #    [Event Type]:                                 Miscellaneous, Informational Only
495    #    [Sub-section type]:                           0
496    #    [Event Scope]:                                Entire Platform
497    #    [Event Severity]:                             Informational Event
498    #    [Host Transmission]:                          Not Sent
499    #    [Section Version]:                            1
500
501    ${pel_section_output}=  Get From Dictionary  ${pel_output}  ${pel_section}
502    ${pel_field_output}=  Get From Dictionary  ${pel_section_output}  ${pel_field}
503
504    [Return]  ${pel_field_output}
505