xref: /openbmc/openbmc-test-automation/openpower/pel/test_bmc_pel.robot (revision 544249841c54d3c93cdafd196c3de765dd25c44b)
1faa5d20aSRahul Maheshwari*** Settings ***
2faa5d20aSRahul MaheshwariDocumentation   This suite tests Platform Event Log (PEL) functionality of OpenBMC.
3faa5d20aSRahul Maheshwari
4faa5d20aSRahul MaheshwariLibrary         ../../lib/pel_utils.py
5a17a3395SRahul MaheshwariVariables       ../../data/pel_variables.py
68f5256fcSRahul MaheshwariResource        ../../lib/list_utils.robot
7f4a01aa7SRahul MaheshwariResource        ../../lib/logging_utils.robot
81810a5b2SmanashsarmaResource        ../../lib/connection_client.robot
9faa5d20aSRahul MaheshwariResource        ../../lib/openbmc_ffdc.robot
10faa5d20aSRahul Maheshwari
11f575c90aSRahul MaheshwariTest Setup      Redfish.Login
12f575c90aSRahul MaheshwariTest Teardown   Run Keywords  Redfish.Logout  AND  FFDC On Test Case Fail
13faa5d20aSRahul Maheshwari
146fb70d98SMatt FischerTest Tags      Bmc_Pel
15faa5d20aSRahul Maheshwari
16faa5d20aSRahul Maheshwari*** Variables ***
17faa5d20aSRahul Maheshwari
18789c8021Sdnirmala@{mandatory_pel_fields}                Private Header  User Header  Primary SRC
19789c8021Sdnirmala...                                    Extended User Header  Failing MTMS
20789c8021Sdnirmala@{mandatory_Predictive_pel_fields}     Private Header  User Header  Primary SRC
21fe690af5Sdnirmala...                                    Extended User Header  Failing MTMS  User Data
22819be78fSdnirmala@{Mandatory_Informational_Pel_Fields}  Private Header  User Header  Primary SRC
23819be78fSdnirmala...                                    Extended User Header  User Data
24b8580dd1SRahul Maheshwari
25faa5d20aSRahul Maheshwari*** Test Cases ***
26faa5d20aSRahul Maheshwari
27faa5d20aSRahul MaheshwariCreate Test PEL Log And Verify
28faa5d20aSRahul Maheshwari    [Documentation]  Create PEL log using busctl command and verify via peltool.
29faa5d20aSRahul Maheshwari    [Tags]  Create_Test_PEL_Log_And_Verify
30faa5d20aSRahul Maheshwari
31f575c90aSRahul Maheshwari    Redfish Purge Event Log
32faa5d20aSRahul Maheshwari    Create Test PEL Log
33f575c90aSRahul Maheshwari    ${pel_id}=  Get PEL Log Via BMC CLI
34f575c90aSRahul Maheshwari    Should Not Be Empty  ${pel_id}  msg=System PEL log entry is empty.
35f575c90aSRahul Maheshwari
36f575c90aSRahul Maheshwari
37a17a3395SRahul MaheshwariVerify PEL Log Details
38a17a3395SRahul Maheshwari    [Documentation]  Verify PEL log details via peltool.
39a17a3395SRahul Maheshwari    [Tags]  Verify_PEL_Log_Details
40a17a3395SRahul Maheshwari
41a17a3395SRahul Maheshwari    Redfish Purge Event Log
42a17a3395SRahul Maheshwari
43a17a3395SRahul Maheshwari    ${bmc_time1}=  CLI Get BMC DateTime
44a17a3395SRahul Maheshwari    Create Test PEL Log
45a17a3395SRahul Maheshwari    ${bmc_time2}=  CLI Get BMC DateTime
46a17a3395SRahul Maheshwari
47a17a3395SRahul Maheshwari    ${pel_records}=  Peltool  -l
48a17a3395SRahul Maheshwari
49a17a3395SRahul Maheshwari    # Example output from 'Peltool  -l':
50a17a3395SRahul Maheshwari    # pel_records:
51a17a3395SRahul Maheshwari    # [0x50000012]:
52a17a3395SRahul Maheshwari    #   [CreatorID]:                  BMC
53a17a3395SRahul Maheshwari    #   [CompID]:                     0x1000
54a17a3395SRahul Maheshwari    #   [PLID]:                       0x50000012
55a17a3395SRahul Maheshwari    #   [Subsystem]:                  BMC Firmware
56a17a3395SRahul Maheshwari    #   [Message]:                    An application had an internal failure
57a17a3395SRahul Maheshwari    #   [SRC]:                        BD8D1002
58a17a3395SRahul Maheshwari    #   [Commit Time]:                03/02/2020  09:35:15
59a17a3395SRahul Maheshwari    #   [Sev]:                        Unrecoverable Error
60a17a3395SRahul Maheshwari
61a17a3395SRahul Maheshwari    ${ids}=  Get Dictionary Keys  ${pel_records}
62a17a3395SRahul Maheshwari    ${id}=  Get From List  ${ids}  0
63a17a3395SRahul Maheshwari
64a17a3395SRahul Maheshwari    @{pel_fields}=  Create List  CreatorID  Subsystem  Message  Sev
65a17a3395SRahul Maheshwari    FOR  ${field}  IN  @{pel_fields}
66a17a3395SRahul Maheshwari      Valid Value  pel_records['${id}']['${field}']  ['${PEL_DETAILS['${field}']}']
67a17a3395SRahul Maheshwari    END
68a17a3395SRahul Maheshwari
69a17a3395SRahul Maheshwari    Valid Value  pel_records['${id}']['PLID']  ['${id}']
70a17a3395SRahul Maheshwari
71a17a3395SRahul Maheshwari    # Verify if "CompID" and "SRC" fields of PEL has alphanumeric value.
72a17a3395SRahul Maheshwari    Should Match Regexp  ${pel_records['${id}']['CompID']}  [a-zA-Z0-9]
73a17a3395SRahul Maheshwari    Should Match Regexp  ${pel_records['${id}']['SRC']}  [a-zA-Z0-9]
74a17a3395SRahul Maheshwari
75a17a3395SRahul Maheshwari    ${pel_date_time}=  Convert Date  ${pel_records['${id}']['Commit Time']}
76a17a3395SRahul Maheshwari    ...  date_format=%m/%d/%Y %H:%M:%S  exclude_millis=yes
77a17a3395SRahul Maheshwari
78a17a3395SRahul Maheshwari    # Convert BMC and PEL time to epoch time before comparing.
79a17a3395SRahul Maheshwari    ${bmc_time1_epoch}=  Convert Date  ${bmc_time1}  epoch
80a17a3395SRahul Maheshwari    ${pel_time_epoch}=  Convert Date  ${pel_date_time}  epoch
81a17a3395SRahul Maheshwari    ${bmc_time2_epoch}=  Convert Date  ${bmc_time2}  epoch
82a17a3395SRahul Maheshwari
83a17a3395SRahul Maheshwari    Should Be True  ${bmc_time1_epoch} <= ${pel_time_epoch} <= ${bmc_time2_epoch}
84a17a3395SRahul Maheshwari
85a17a3395SRahul Maheshwari
863991868cSRahul MaheshwariVerify Mandatory Sections Of Error Log PEL
873991868cSRahul Maheshwari    [Documentation]  Verify mandatory sections of error log PEL.
883991868cSRahul Maheshwari    [Tags]  Verify_Mandatory_Sections_Of_Error_Log_PEL
893991868cSRahul Maheshwari
903991868cSRahul Maheshwari    Create Test PEL Log
913991868cSRahul Maheshwari
923991868cSRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
933991868cSRahul Maheshwari    ${pel_id}=  Get From List  ${pel_ids}  -1
943991868cSRahul Maheshwari    ${pel_output}=  Peltool  -i ${pel_id}
953991868cSRahul Maheshwari    ${pel_sections}=  Get Dictionary Keys  ${pel_output}
963991868cSRahul Maheshwari
97789c8021Sdnirmala    List Should Contain Sub List  ${pel_sections}  ${mandatory_pel_fields}
983991868cSRahul Maheshwari
993991868cSRahul Maheshwari
100f575c90aSRahul MaheshwariVerify PEL Log Persistence After BMC Reboot
101f575c90aSRahul Maheshwari    [Documentation]  Verify PEL log persistence after BMC reboot.
102f575c90aSRahul Maheshwari    [Tags]  Verify_PEL_Log_Persistence_After_BMC_Reboot
103f575c90aSRahul Maheshwari
104f575c90aSRahul Maheshwari    Create Test PEL Log
105f575c90aSRahul Maheshwari    ${pel_before_reboot}=  Get PEL Log Via BMC CLI
106f575c90aSRahul Maheshwari
107f575c90aSRahul Maheshwari    Redfish OBMC Reboot (off)
108f575c90aSRahul Maheshwari    ${pel_after_reboot}=  Get PEL Log Via BMC CLI
109f575c90aSRahul Maheshwari
110f575c90aSRahul Maheshwari    List Should Contain Sub List  ${pel_after_reboot}  ${pel_before_reboot}
111faa5d20aSRahul Maheshwari
112faa5d20aSRahul Maheshwari
11358b99fc9SRahul MaheshwariVerify PEL ID Numbering
11458b99fc9SRahul Maheshwari    [Documentation]  Verify PEL ID numbering.
11558b99fc9SRahul Maheshwari    [Tags]  Verify_PEL_ID_Numbering
11658b99fc9SRahul Maheshwari
11758b99fc9SRahul Maheshwari    Redfish Purge Event Log
11858b99fc9SRahul Maheshwari    Create Test PEL Log
11958b99fc9SRahul Maheshwari    Create Test PEL Log
12058b99fc9SRahul Maheshwari
12158b99fc9SRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
12258b99fc9SRahul Maheshwari
12358b99fc9SRahul Maheshwari    # Example of PEL IDs from PEL logs.
12458b99fc9SRahul Maheshwari    #  [0x50000012]:             <--- First PEL ID
12558b99fc9SRahul Maheshwari    #    [CreatorID]:                  BMC
12658b99fc9SRahul Maheshwari    #    [CompID]:                     0x1000
12758b99fc9SRahul Maheshwari    #    [PLID]:                       0x50000012
12858b99fc9SRahul Maheshwari    #    [Subsystem]:                  BMC Firmware
12958b99fc9SRahul Maheshwari    #    [Message]:                    An application had an internal failure
13058b99fc9SRahul Maheshwari    #    [SRC]:                        BD8D1002
13158b99fc9SRahul Maheshwari    #    [Commit Time]:                03/02/2020  09:35:15
13258b99fc9SRahul Maheshwari    #    [Sev]:                        Unrecoverable Error
13358b99fc9SRahul Maheshwari    #
13458b99fc9SRahul Maheshwari    #  [0x50000013]:             <--- Second PEL ID
13558b99fc9SRahul Maheshwari    #    [CreatorID]:                  BMC
13658b99fc9SRahul Maheshwari    #    [CompID]:                     0x1000
13758b99fc9SRahul Maheshwari    #    [PLID]:                       0x50000013
13858b99fc9SRahul Maheshwari    #    [Subsystem]:                  BMC Firmware
13958b99fc9SRahul Maheshwari    #    [Message]:                    An application had an internal failure
14058b99fc9SRahul Maheshwari    #    [SRC]:                        BD8D1002
14158b99fc9SRahul Maheshwari    #    [Commit Time]:                03/02/2020  09:35:15
14258b99fc9SRahul Maheshwari    #    [Sev]:                        Unrecoverable Error
14358b99fc9SRahul Maheshwari
14458b99fc9SRahul Maheshwari    Should Be True  ${pel_ids[1]} == ${pel_ids[0]}+1
14558b99fc9SRahul Maheshwari
146371e4f84SRahul MaheshwariVerify Machine Type Model And Serial Number
147371e4f84SRahul Maheshwari    [Documentation]  Verify machine type model and serial number from PEL.
148371e4f84SRahul Maheshwari    [Tags]  Verify_Machine_Type_Model_And_Serial_Number
149371e4f84SRahul Maheshwari
150371e4f84SRahul Maheshwari    Create Test PEL Log
151371e4f84SRahul Maheshwari
152371e4f84SRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
153371e4f84SRahul Maheshwari    ${id}=  Get From List  ${pel_ids}  -1
15456dba360SRahul Maheshwari
155371e4f84SRahul Maheshwari    ${pel_serial_number}=  Get PEL Field Value  ${id}  Failing MTMS  Serial Number
15656dba360SRahul Maheshwari    ${pel_serial_number}=  Replace String Using Regexp  ${pel_serial_number}  ^0+  ${EMPTY}
157371e4f84SRahul Maheshwari    ${pel_machine_type_model}=  Get PEL Field Value  ${id}  Failing MTMS  Machine Type Model
15856dba360SRahul Maheshwari    ${pel_machine_type_model}=  Replace String Using Regexp  ${pel_machine_type_model}  ^0+  ${EMPTY}
159371e4f84SRahul Maheshwari
160371e4f84SRahul Maheshwari    # Example of "Machine Type Model" and "Serial Number" fields value from "Failing MTMS" section of PEL.
161371e4f84SRahul Maheshwari    #  [Failing MTMS]:
162371e4f84SRahul Maheshwari    #    [Created by]:                                 0x2000
163371e4f84SRahul Maheshwari    #    [Machine Type Model]:                         1234-ABC   <---- Machine type
164371e4f84SRahul Maheshwari    #    [Section Version]:                            1
165371e4f84SRahul Maheshwari    #    [Serial Number]:                              ABCDEFG    <---- Serial number
166371e4f84SRahul Maheshwari    #    [Sub-section type]:                           0
167371e4f84SRahul Maheshwari
168c32434a3SYi Hu    ${redfish_machine_model}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}/  Model
16956dba360SRahul Maheshwari    ${redfish_machine_model}=  Replace String Using Regexp  ${redfish_machine_model}  ^0+  ${EMPTY}
170c32434a3SYi Hu    ${redfish_serial_number}=  Redfish.Get Attribute  /redfish/v1/Systems/${SYSTEM_ID}/  SerialNumber
17156dba360SRahul Maheshwari    ${redfish_serial_number}=  Replace String Using Regexp  ${redfish_serial_number}  ^0+  ${EMPTY}
172371e4f84SRahul Maheshwari
173371e4f84SRahul Maheshwari    Valid Value  pel_machine_type_model  ['${redfish_machine_model}']
174371e4f84SRahul Maheshwari    Valid Value  pel_serial_number  ['${redfish_serial_number}']
175371e4f84SRahul Maheshwari
176371e4f84SRahul Maheshwari    # Check "Machine Type Model" and "Serial Number" fields value from "Extended User Header" section of PEL.
177371e4f84SRahul Maheshwari    ${pel_machine_type_model}=  Get PEL Field Value  ${id}  Extended User Header  Reporting Machine Type
17856dba360SRahul Maheshwari    ${pel_machine_type_model}=  Replace String Using Regexp  ${pel_machine_type_model}  ^0+  ${EMPTY}
179371e4f84SRahul Maheshwari    ${pel_serial_number}=  Get PEL Field Value  ${id}  Extended User Header  Reporting Serial Number
18056dba360SRahul Maheshwari    ${pel_serial_number}=  Replace String Using Regexp  ${pel_serial_number}  ^0+  ${EMPTY}
181371e4f84SRahul Maheshwari
182371e4f84SRahul Maheshwari    Valid Value  pel_machine_type_model  ['${redfish_machine_model}']
183371e4f84SRahul Maheshwari    Valid Value  pel_serial_number  ['${redfish_serial_number}']
184371e4f84SRahul Maheshwari
18558b99fc9SRahul Maheshwari
1861bea6ccfSRahul MaheshwariVerify Host Off State From PEL
1871bea6ccfSRahul Maheshwari    [Documentation]  Verify Host off state from PEL.
1881bea6ccfSRahul Maheshwari    [Tags]  Verify_Host_Off_State_From_PEL
1891bea6ccfSRahul Maheshwari
1901bea6ccfSRahul Maheshwari    Redfish Power Off  stack_mode=skip
1911bea6ccfSRahul Maheshwari    Create Test PEL Log
1921bea6ccfSRahul Maheshwari
1931bea6ccfSRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
1941bea6ccfSRahul Maheshwari    ${id}=  Get From List  ${pel_ids}  -1
1951bea6ccfSRahul Maheshwari    ${pel_host_state}=  Get PEL Field Value  ${id}  User Data  HostState
1961bea6ccfSRahul Maheshwari
1971bea6ccfSRahul Maheshwari    Valid Value  pel_host_state  ['Off']
1981bea6ccfSRahul Maheshwari
1991bea6ccfSRahul Maheshwari
200b50aa77bSdnirmalaVerify Host On State From PEL
201b50aa77bSdnirmala    [Documentation]  Verify Host on state from PEL.
202b50aa77bSdnirmala    [Tags]  Verify_Host_On_State_From_PEL
203b50aa77bSdnirmala
204b50aa77bSdnirmala    Redfish Power On  stack_mode=skip
20519794f05Sdnirmala    Redfish Purge Event Log
20619794f05Sdnirmala
207b50aa77bSdnirmala    Create Test PEL Log
208b50aa77bSdnirmala
209b50aa77bSdnirmala    ${pel_ids}=  Get PEL Log Via BMC CLI
210b50aa77bSdnirmala    ${id}=  Get From List  ${pel_ids}  -1
211b50aa77bSdnirmala    ${pel_host_state}=  Get PEL Field Value  ${id}  User Data  HostState
212b50aa77bSdnirmala
213b50aa77bSdnirmala    Valid Value  pel_host_state  ['Running']
214b50aa77bSdnirmala
215b50aa77bSdnirmala
2161bea6ccfSRahul MaheshwariVerify BMC Version From PEL
2171bea6ccfSRahul Maheshwari    [Documentation]  Verify BMC Version from PEL.
2181bea6ccfSRahul Maheshwari    [Tags]  Verify_BMC_Version_From_PEL
2191bea6ccfSRahul Maheshwari
2201bea6ccfSRahul Maheshwari    Create Test PEL Log
2211bea6ccfSRahul Maheshwari
2221bea6ccfSRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
2231bea6ccfSRahul Maheshwari    ${id}=  Get From List  ${pel_ids}  -1
224f6600f83SRahul Maheshwari    ${pel_bmc_version}=  Get PEL Field Value  ${id}  User Data  FW Version ID
2251bea6ccfSRahul Maheshwari
2261bea6ccfSRahul Maheshwari    ${bmc_version}=  Get BMC Version
2271bea6ccfSRahul Maheshwari    Valid Value  bmc_version  ['${bmc_version}']
2281bea6ccfSRahul Maheshwari
2291bea6ccfSRahul Maheshwari
2308f5256fcSRahul MaheshwariVerify PEL Log After Host Poweron
2318f5256fcSRahul Maheshwari    [Documentation]  Verify PEL log generation while booting host.
2328f5256fcSRahul Maheshwari    [Tags]  Verify_PEL_Log_After_Host_Poweron
2338f5256fcSRahul Maheshwari
2348f5256fcSRahul Maheshwari    Redfish Power Off  stack_mode=skip
2358f5256fcSRahul Maheshwari    Redfish Purge Event Log
2368f5256fcSRahul Maheshwari    Redfish Power On  stack_mode=skip
2378f5256fcSRahul Maheshwari
2388f5256fcSRahul Maheshwari    ${pel_informational_error}=  Get PEL Log IDs  User Header  Event Severity  Informational Event
2398f5256fcSRahul Maheshwari    ${pel_bmc_created_error}=  Get PEL Log IDs  Private Header  Creator Subsystem  BMC
2408f5256fcSRahul Maheshwari
2418f5256fcSRahul Maheshwari    # Get BMC created non-infomational error.
2428f5256fcSRahul Maheshwari    ${pel_bmc_error}=  Subtract Lists  ${pel_bmc_created_error}  ${pel_informational_error}
2438f5256fcSRahul Maheshwari
2448f5256fcSRahul Maheshwari    Should Be Empty  ${pel_bmc_error}  msg=Unexpected error log generated during Host poweron.
2458f5256fcSRahul Maheshwari
2468f5256fcSRahul Maheshwari
247089615b4SRahul MaheshwariVerify BMC Event Log ID
248089615b4SRahul Maheshwari    [Documentation]  Verify BMC Event Log ID from PEL.
249089615b4SRahul Maheshwari    [Tags]  Verify_BMC_Event_Log_ID
250089615b4SRahul Maheshwari
251089615b4SRahul Maheshwari    Redfish Purge Event Log
252089615b4SRahul Maheshwari    Create Test PEL Log
253089615b4SRahul Maheshwari
254089615b4SRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
255089615b4SRahul Maheshwari    ${pel_bmc_event_log_id}=  Get PEL Field Value  ${pel_ids[0]}  Private Header  BMC Event Log Id
256089615b4SRahul Maheshwari
257089615b4SRahul Maheshwari    # Example "BMC Event Log Id" field value from "Private Header" section of PEL.
258089615b4SRahul Maheshwari    #  [Private Header]:
259089615b4SRahul Maheshwari    #    [Created at]:                 08/24/1928 12:04:06
260089615b4SRahul Maheshwari    #    [Created by]:                 0x584D
261089615b4SRahul Maheshwari    #    [Sub-section type]:           0
262089615b4SRahul Maheshwari    #    [Entry Id]:                   0x50000BB7
263089615b4SRahul Maheshwari    #    [Platform Log Id]:            0x8200061D
264089615b4SRahul Maheshwari    #    [CSSVER]:
265089615b4SRahul Maheshwari    #    [Section Version]:            1
266089615b4SRahul Maheshwari    #    [Creator Subsystem]:          PHYP
267089615b4SRahul Maheshwari    #    [BMC Event Log Id]:           341      <---- BMC event log id value
268089615b4SRahul Maheshwari    #    [Committed at]:               03/25/1920 12:06:22
269089615b4SRahul Maheshwari
270c32434a3SYi Hu    ${redfish_event_logs}=  Redfish.Get Properties  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries
271089615b4SRahul Maheshwari
272089615b4SRahul Maheshwari    # Example of redfish_event_logs output:
273089615b4SRahul Maheshwari    # redfish_event_logs:
274089615b4SRahul Maheshwari    #  [@odata.id]:                    /redfish/v1/Systems/system/LogServices/EventLog/Entries
275089615b4SRahul Maheshwari    #  [Name]:                         System Event Log Entries
276089615b4SRahul Maheshwari    #  [Members@odata.count]:          1
277089615b4SRahul Maheshwari    #  [@odata.type]:                  #LogEntryCollection.LogEntryCollection
278089615b4SRahul Maheshwari    #  [Description]:                  Collection of System Event Log Entries
279089615b4SRahul Maheshwari    #  [Members]:
280089615b4SRahul Maheshwari    #    [0]:
281089615b4SRahul Maheshwari    #      [@odata.id]:                /redfish/v1/Systems/system/LogServices/EventLog/Entries/235
282089615b4SRahul Maheshwari    #      [Name]:                     System Event Log Entry
283089615b4SRahul Maheshwari    #      [Severity]:                 Critical
284089615b4SRahul Maheshwari    #      [EntryType]:                Event
285089615b4SRahul Maheshwari    #      [Created]:                  2020-04-02T07:25:13+00:00
286089615b4SRahul Maheshwari    #      [@odata.type]:              #LogEntry.v1_5_1.LogEntry
287089615b4SRahul Maheshwari    #      [Id]:                       235          <----- Event log ID
288089615b4SRahul Maheshwari    #      [Message]:                  xyz.openbmc_project.Common.Error.InternalFailure
289089615b4SRahul Maheshwari
290089615b4SRahul Maheshwari    Valid Value  pel_bmc_event_log_id  ['${redfish_event_logs['Members'][0]['Id']}']
291089615b4SRahul Maheshwari
292089615b4SRahul Maheshwari
29397d7ab87SRahul MaheshwariVerify FRU Callout
29497d7ab87SRahul Maheshwari    [Documentation]  Verify FRU callout entries from PEL log.
29597d7ab87SRahul Maheshwari    [Tags]  Verify_FRU_Callout
29697d7ab87SRahul Maheshwari
297d395d468Sdnirmala    # Power off the system to avoid unnecessary error logs during test.
298d395d468Sdnirmala    Redfish Power Off  stack_mode=skip
29997d7ab87SRahul Maheshwari    Create Test PEL Log  FRU Callout
30097d7ab87SRahul Maheshwari
30197d7ab87SRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
30297d7ab87SRahul Maheshwari    ${id}=  Get From List  ${pel_ids}  -1
30397d7ab87SRahul Maheshwari    ${pel_callout_section}=  Get PEL Field Value  ${id}  Primary SRC  Callout Section
30497d7ab87SRahul Maheshwari
30597d7ab87SRahul Maheshwari    # Example of PEL Callout Section from "peltool -i <id>" command.
30697d7ab87SRahul Maheshwari    #  [Callouts]:
30797d7ab87SRahul Maheshwari    #    [0]:
30897d7ab87SRahul Maheshwari    #      [FRU Type]:                 Normal Hardware FRU
30997d7ab87SRahul Maheshwari    #      [Priority]:                 Mandatory, replace all with this type as a unit
31097d7ab87SRahul Maheshwari    #      [Location Code]:            U78DA.ND1.1234567-P0
31197d7ab87SRahul Maheshwari    #      [Part Number]:              F191014
31297d7ab87SRahul Maheshwari    #      [CCIN]:                     2E2D
31397d7ab87SRahul Maheshwari    #      [Serial Number]:            YL2E2D010000
31497d7ab87SRahul Maheshwari    #  [Callout Count]:                1
31597d7ab87SRahul Maheshwari
31697d7ab87SRahul Maheshwari    Valid Value  pel_callout_section['Callout Count']  ['1']
31797d7ab87SRahul Maheshwari    Valid Value  pel_callout_section['Callouts'][0]['FRU Type']  ['Normal Hardware FRU']
31897d7ab87SRahul Maheshwari    Should Contain  ${pel_callout_section['Callouts'][0]['Priority']}  Mandatory
31997d7ab87SRahul Maheshwari
32097d7ab87SRahul Maheshwari    # Verify Location Code field of PEL callout with motherboard's Location Code.
32197d7ab87SRahul Maheshwari    ${busctl_output}=  BMC Execute Command  ${CMD_INVENTORY_PREFIX} com.ibm.ipzvpd.Location LocationCode
32297d7ab87SRahul Maheshwari    Should Be Equal  ${pel_callout_section['Callouts'][0]['Location Code']}
32397d7ab87SRahul Maheshwari    ...  ${busctl_output[0].split('"')[1].strip('"')}
32497d7ab87SRahul Maheshwari
32597d7ab87SRahul Maheshwari    # TODO: Compare CCIN and part number fields of PEL callout with Redfish or busctl output.
32697d7ab87SRahul Maheshwari    Should Match Regexp  ${pel_callout_section['Callouts'][0]['CCIN']}  [a-zA-Z0-9]
32797d7ab87SRahul Maheshwari    Should Match Regexp  ${pel_callout_section['Callouts'][0]['Part Number']}  [a-zA-Z0-9]
32897d7ab87SRahul Maheshwari
32997d7ab87SRahul Maheshwari    # Verify Serial Number field of PEL callout with motherboard's Serial Number.
33097d7ab87SRahul Maheshwari    ${busctl_output}=  BMC Execute Command
33197d7ab87SRahul Maheshwari    ...  ${CMD_INVENTORY_PREFIX} xyz.openbmc_project.Inventory.Decorator.Asset SerialNumber
33297d7ab87SRahul Maheshwari    Should Be Equal  ${pel_callout_section['Callouts'][0]['Serial Number']}
33397d7ab87SRahul Maheshwari    ...  ${busctl_output[0].split('"')[1].strip('"')}
33497d7ab87SRahul Maheshwari
33597d7ab87SRahul Maheshwari
33697d7ab87SRahul MaheshwariVerify Procedure And Symbolic FRU Callout
33797d7ab87SRahul Maheshwari    [Documentation]  Verify procedure and symbolic FRU callout from PEL log.
33897d7ab87SRahul Maheshwari    [Tags]  Verify_Procedure_And_Symbolic_FRU_Callout
33997d7ab87SRahul Maheshwari
34097d7ab87SRahul Maheshwari    Create Test PEL Log   Procedure And Symbolic FRU Callout
34197d7ab87SRahul Maheshwari
34297d7ab87SRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
34397d7ab87SRahul Maheshwari    ${id}=  Get From List  ${pel_ids}  -1
34497d7ab87SRahul Maheshwari    ${pel_callout_section}=  Get PEL Field Value  ${id}  Primary SRC  Callout Section
34597d7ab87SRahul Maheshwari
34697d7ab87SRahul Maheshwari    # Example of PEL Callout Section from "peltool -i <id>" command.
34797d7ab87SRahul Maheshwari    #  [Callouts]:
34897d7ab87SRahul Maheshwari    #    [0]:
34997d7ab87SRahul Maheshwari    #      [Priority]:                                 Mandatory, replace all with this type as a unit
35097d7ab87SRahul Maheshwari    #      [Procedure Number]:                         BMCSP02
35197d7ab87SRahul Maheshwari    #      [FRU Type]:                                 Maintenance Procedure Required
35297d7ab87SRahul Maheshwari    #    [1]:
35397d7ab87SRahul Maheshwari    #      [Priority]:                                 Medium Priority
35497d7ab87SRahul Maheshwari    #      [Part Number]:                              SVCDOCS
35597d7ab87SRahul Maheshwari    #      [FRU Type]:                                 Symbolic FRU
35697d7ab87SRahul Maheshwari    #  [Callout Count]:                                2
35797d7ab87SRahul Maheshwari
35897d7ab87SRahul Maheshwari    Valid Value  pel_callout_section['Callout Count']  ['2']
35997d7ab87SRahul Maheshwari
36097d7ab87SRahul Maheshwari    # Verify procedural callout info.
36197d7ab87SRahul Maheshwari
36297d7ab87SRahul Maheshwari    Valid Value  pel_callout_section['Callouts'][0]['FRU Type']  ['Maintenance Procedure Required']
36397d7ab87SRahul Maheshwari    Should Contain  ${pel_callout_section['Callouts'][0]['Priority']}  Mandatory
36497d7ab87SRahul Maheshwari    # Verify if "Procedure Number" field of PEL has an alphanumeric value.
3656acf0ee3SRahul Maheshwari    Should Match Regexp  ${pel_callout_section['Callouts'][0]['Procedure']}  [a-zA-Z0-9]
36697d7ab87SRahul Maheshwari
36797d7ab87SRahul Maheshwari    # Verify procedural callout info.
36897d7ab87SRahul Maheshwari
36997d7ab87SRahul Maheshwari    Valid Value  pel_callout_section['Callouts'][1]['FRU Type']  ['Symbolic FRU']
37097d7ab87SRahul Maheshwari    Should Contain  ${pel_callout_section['Callouts'][1]['Priority']}  Medium Priority
37197d7ab87SRahul Maheshwari    # Verify if "Part Number" field of Symbolic FRU has an alphanumeric value.
37297d7ab87SRahul Maheshwari    Should Match Regexp  ${pel_callout_section['Callouts'][1]['Part Number']}  [a-zA-Z0-9]
37397d7ab87SRahul Maheshwari
37497d7ab87SRahul Maheshwari
375f4a01aa7SRahul MaheshwariVerify PEL Log Entry For Event Log
376f4a01aa7SRahul Maheshwari    [Documentation]  Create an event log and verify PEL log entry in BMC for the same.
377f4a01aa7SRahul Maheshwari    [Tags]  Verify_PEL_Log_Entry_For_Event_Log
378f4a01aa7SRahul Maheshwari
379f4a01aa7SRahul Maheshwari    Redfish Purge Event Log
38071d589c9SRahul Maheshwari
38171d589c9SRahul Maheshwari    # Create an unrecoverable error log.
38271d589c9SRahul Maheshwari    Create Test PEL Log  Unrecoverable Error
383f4a01aa7SRahul Maheshwari
384f4a01aa7SRahul Maheshwari    ${elog_entry}=  Get Event Logs
385f4a01aa7SRahul Maheshwari    # Example of Redfish event logs:
386f4a01aa7SRahul Maheshwari    # elog_entry:
387f4a01aa7SRahul Maheshwari    #  [0]:
38871d589c9SRahul Maheshwari    #    [Message]:                             BD802003 event in subsystem: Platform Firmware
38901cea4a9Sdnirmala    #    [Created]:                             2023-05-08T10:19:30.412+00:00
390f4a01aa7SRahul Maheshwari    #    [Id]:                                  1
391f4a01aa7SRahul Maheshwari    #    [@odata.id]:                           /redfish/v1/Systems/system/LogServices/EventLog/Entries/1
392f4a01aa7SRahul Maheshwari    #    [@odata.type]:                         #LogEntry.v1_4_0.LogEntry
393f4a01aa7SRahul Maheshwari    #    [EntryType]:                           Event
394f4a01aa7SRahul Maheshwari    #    [Severity]:                            Critical
395f4a01aa7SRahul Maheshwari    #    [Name]:                                System Event Log Entry
396f4a01aa7SRahul Maheshwari
39701cea4a9Sdnirmala    ${redfish_log_time}=  Convert Date  ${elog_entry[0]["Created"].split('.')[0]}  epoch
398f4a01aa7SRahul Maheshwari
399f4a01aa7SRahul Maheshwari    ${pel_records}=  Peltool  -l
400f4a01aa7SRahul Maheshwari    # Example output from 'Peltool  -l':
401f4a01aa7SRahul Maheshwari    # pel_records:
402f4a01aa7SRahul Maheshwari    # [0x50000023]:
40371d589c9SRahul Maheshwari    #   [SRC]:                                   BD802003
404f4a01aa7SRahul Maheshwari    #   [CreatorID]:                             BMC
40571d589c9SRahul Maheshwari    #   [Message]:                               This is a test error
40671d589c9SRahul Maheshwari    #   [CompID]:                                0x2000
40771d589c9SRahul Maheshwari    #   [PLID]:                                  0x500053D9
408f4a01aa7SRahul Maheshwari    #   [Commit Time]:                           04/20/2020 01:55:22
40971d589c9SRahul Maheshwari    #   [Subsystem]:                             Platform Firmware
410f4a01aa7SRahul Maheshwari    #   [Sev]:                                   Unrecoverable Error
411f4a01aa7SRahul Maheshwari
412f4a01aa7SRahul Maheshwari    ${ids}=  Get Dictionary Keys  ${pel_records}
413f4a01aa7SRahul Maheshwari    ${id}=  Get From List  ${ids}  0
414f4a01aa7SRahul Maheshwari    ${pel_log_time}=  Convert Date  ${pel_records['${id}']['Commit Time']}  epoch
415f4a01aa7SRahul Maheshwari    ...  date_format=%m/%d/%Y %H:%M:%S
416f4a01aa7SRahul Maheshwari
417f4a01aa7SRahul Maheshwari    # Verify that both Redfish event and PEL has log entry for internal error with same time stamp.
41871d589c9SRahul Maheshwari    Should Contain Any  ${pel_records['${id}']['Message']}  test error  ignore_case=True
41940ade897SRahul Maheshwari    Should Contain  ${elog_entry[0]['Message']}
42071d589c9SRahul Maheshwari    ...  ${pel_records['${id}']['SRC']}  ignore_case=True
421f4a01aa7SRahul Maheshwari
422f4a01aa7SRahul Maheshwari    Should Be Equal  ${redfish_log_time}  ${pel_log_time}
423f4a01aa7SRahul Maheshwari
424f4a01aa7SRahul Maheshwari
425326d064eSRahul MaheshwariVerify Delete All PEL
426326d064eSRahul Maheshwari    [Documentation]  Verify deleting all PEL logs.
427326d064eSRahul Maheshwari    [Tags]  Verify_Delete_All_PEL
428326d064eSRahul Maheshwari
429326d064eSRahul Maheshwari    Create Test PEL Log
430326d064eSRahul Maheshwari    Create Test PEL Log
431*54424984SSridevi Ramesh    Peltool  --delete-all  parse_json=False
432326d064eSRahul Maheshwari
433326d064eSRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
434326d064eSRahul Maheshwari    Should Be Empty  ${pel_ids}
435326d064eSRahul Maheshwari
436326d064eSRahul Maheshwari
4374e935384SmanashsarmaVerify Informational Error Log
4384e935384Smanashsarma    [Documentation]  Create an informational error log and verify.
4394e935384Smanashsarma    [Tags]  Verify_Informational_Error_Log
4404e935384Smanashsarma
4414e935384Smanashsarma    Redfish Purge Event Log
4424e935384Smanashsarma    # Create an informational error log.
4434e935384Smanashsarma    BMC Execute Command  ${CMD_INFORMATIONAL_ERROR}
4444e935384Smanashsarma    ${pel_records}=  Peltool  -lfh
4454e935384Smanashsarma
4464e935384Smanashsarma    # An example of information error log data:
4474e935384Smanashsarma    # {
4484e935384Smanashsarma    #    "0x500006A0": {
4494e935384Smanashsarma    #            "SRC": "BD8D1002",
4504e935384Smanashsarma    #            "Message": "An application had an internal failure",
4514e935384Smanashsarma    #            "PLID": "0x500006A0",
4524e935384Smanashsarma    #            "CreatorID": "BMC",
4534e935384Smanashsarma    #            "Subsystem": "BMC Firmware",
4544e935384Smanashsarma    #            "Commit Time": "10/14/2020 11:41:38",
4554e935384Smanashsarma    #            "Sev": "Informational Event",
4564e935384Smanashsarma    #            "CompID": "0x1000"
4574e935384Smanashsarma    #    }
4584e935384Smanashsarma    # }
4594e935384Smanashsarma
4604e935384Smanashsarma    ${ids}=  Get Dictionary Keys  ${pel_records}
4614e935384Smanashsarma    ${id}=  Get From List  ${ids}  0
4624e935384Smanashsarma    Should Contain  ${pel_records['${id}']['Sev']}  Informational
4634e935384Smanashsarma
4644e935384Smanashsarma
46515fe5638SmanashsarmaVerify Predictable Error Log
46615fe5638Smanashsarma    [Documentation]  Create a predictive error and verify.
46715fe5638Smanashsarma    [Tags]  Verify_Predictable_Error_Log
46815fe5638Smanashsarma
46915fe5638Smanashsarma    # Create a predictable error log.
47015fe5638Smanashsarma    BMC Execute Command  ${CMD_PREDICTIVE_ERROR}
47115fe5638Smanashsarma    ${pel_records}=  Peltool  -l
47215fe5638Smanashsarma
47315fe5638Smanashsarma    # An example of predictive error log data:
47415fe5638Smanashsarma    # {
47515fe5638Smanashsarma    #    "0x5000069E": {
47615fe5638Smanashsarma    #            "SRC": "BD8D1002",
47715fe5638Smanashsarma    #            "Message": "An application had an internal failure",
47815fe5638Smanashsarma    #            "PLID": "0x5000069E",
47915fe5638Smanashsarma    #            "CreatorID": "BMC",
48015fe5638Smanashsarma    #            "Subsystem": "BMC Firmware",
48115fe5638Smanashsarma    #            "Commit Time": "10/14/2020 11:40:07",
48215fe5638Smanashsarma    #            "Sev": "Predictive Error",
48315fe5638Smanashsarma    #            "CompID": "0x1000"
48415fe5638Smanashsarma    #    }
48515fe5638Smanashsarma    # }
48615fe5638Smanashsarma
48715fe5638Smanashsarma    ${pel_ids}=  Get PEL Log Via BMC CLI
48815fe5638Smanashsarma    ${id}=  Get From List  ${pel_ids}  -1
48915fe5638Smanashsarma    Should Contain  ${pel_records['${id}']['Sev']}  Predictive
49015fe5638Smanashsarma
49115fe5638Smanashsarma
49215fe5638SmanashsarmaVerify Unrecoverable Error Log
49315fe5638Smanashsarma    [Documentation]  Create an unrecoverable error and verify.
49415fe5638Smanashsarma    [Tags]  Verify_Unrecoverable_Error_Log
49515fe5638Smanashsarma
49615fe5638Smanashsarma    # Create an internal failure error log.
49715fe5638Smanashsarma    BMC Execute Command  ${CMD_UNRECOVERABLE_ERROR}
49815fe5638Smanashsarma    ${pel_records}=  Peltool  -l
49915fe5638Smanashsarma
50015fe5638Smanashsarma    # An example of unrecoverable error log data:
50115fe5638Smanashsarma    # {
50215fe5638Smanashsarma    #    "0x50000CC5": {
50315fe5638Smanashsarma    #            "SRC": "BD8D1002",
50415fe5638Smanashsarma    #            "Message": "An application had an internal failure",
50515fe5638Smanashsarma    #            "PLID": "0x50000CC5",
50615fe5638Smanashsarma    #            "CreatorID": "BMC",
50715fe5638Smanashsarma    #            "Subsystem": "BMC Firmware",
50815fe5638Smanashsarma    #            "Commit Time": "04/01/2020 16:44:55",
50915fe5638Smanashsarma    #            "Sev": "Unrecoverable Error",
51015fe5638Smanashsarma    #            "CompID": "0x1000"
51115fe5638Smanashsarma    #    }
51215fe5638Smanashsarma    # }
51315fe5638Smanashsarma
51415fe5638Smanashsarma    ${pel_ids}=  Get PEL Log Via BMC CLI
51515fe5638Smanashsarma    ${id}=  Get From List  ${pel_ids}  -1
51615fe5638Smanashsarma    Should Contain  ${pel_records['${id}']['Sev']}  Unrecoverable
51715fe5638Smanashsarma
51815fe5638Smanashsarma
519595282d6SmanashsarmaVerify Error Logging Rotation Policy
520595282d6Smanashsarma    [Documentation]  Verify error logging rotation policy.
521595282d6Smanashsarma    [Tags]  Verify_Error_Logging_Rotation_Policy
522595282d6Smanashsarma    [Template]  Error Logging Rotation Policy
523d073a0a3Smanashsarma
524557b6320Smanashsarma    # Error logs to be created                                % of total logging space when error
525557b6320Smanashsarma    #                                                         log exceeds max limit.
526557b6320Smanashsarma    Informational BMC 3000                                                       15
527557b6320Smanashsarma    Predictive BMC 3000                                                          30
528557b6320Smanashsarma    Unrecoverable BMC 3000                                                       30
529557b6320Smanashsarma    Informational BMC 1500, Predictive BMC 1500                                  45
530557b6320Smanashsarma    Informational BMC 1500, Unrecoverable BMC 1500                               45
531557b6320Smanashsarma    Unrecoverable BMC 1500, Predictive BMC 1500                                  30
532b4cacb5aSRahul Maheshwari
533b4cacb5aSRahul Maheshwari
534b4cacb5aSRahul MaheshwariVerify Error Logging Rotation Policy With All Types Of Errors
535b4cacb5aSRahul Maheshwari    [Documentation]  Verify error logging rotation policy with all types of errors.
5364203fad2SGeorge Keishing    [Tags]  Verify_Error_Logging_Rotation_Policy_With_All_Types_Of_Errors
537b4cacb5aSRahul Maheshwari    [Template]  Error Logging Rotation Policy
538b4cacb5aSRahul Maheshwari
539b4cacb5aSRahul Maheshwari    # Error logs to be created                                           % of total logging space when error
540b4cacb5aSRahul Maheshwari    #                                                                    log exceeds max limit.
541557b6320Smanashsarma    Unrecoverable BMC 1000, Informational BMC 1000, Predictive BMC 1000          45
542c5131664Smanashsarma
5431810a5b2Smanashsarma
5441810a5b2SmanashsarmaVerify Error Logging Rotation Policy With HOST Error Logs
5451810a5b2Smanashsarma    [Documentation]  Verify error logging rotation policy for non bmc error logs.
5461810a5b2Smanashsarma    [Tags]  Verify_Error_Logging_Rotation_Policy_With_HOST_Error_Logs
5471810a5b2Smanashsarma    [Setup]  Run Keywords  Open Connection for SCP  AND  scp.Put File  ${UNRECOVERABLE_FILE_PATH}
5484baa6a77Smanashsarma    ...  /tmp/FILE_HOST_UNRECOVERABLE  AND  scp.Put File  ${INFORMATIONAL_FILE_PATH}
5494baa6a77Smanashsarma    ...  /tmp/FILE_HOST_INFORMATIONAL
5501810a5b2Smanashsarma    [Template]  Error Logging Rotation Policy
5511810a5b2Smanashsarma
5521810a5b2Smanashsarma    # Error logs to be created                                % of total logging space when error
5531810a5b2Smanashsarma    #                                                         log exceeds max limit.
5544baa6a77Smanashsarma    Informational HOST 3000                                                   15
5551810a5b2Smanashsarma    Unrecoverable HOST 3000                                                   30
5564baa6a77Smanashsarma    Informational HOST 1500, Informational BMC 1500                           30
5574baa6a77Smanashsarma    Informational HOST 1500, Unrecoverable BMC 1500                           45
5581810a5b2Smanashsarma    Unrecoverable HOST 1500, Informational BMC 1500                           45
5591810a5b2Smanashsarma    Unrecoverable HOST 1500, Predictive BMC 1500                              60
560b4cacb5aSRahul Maheshwari
561b4cacb5aSRahul Maheshwari
562b4cacb5aSRahul MaheshwariVerify Error Logging Rotation Policy With Unrecoverable HOST And BMC Error Logs
563b4cacb5aSRahul Maheshwari    [Documentation]  Verify error logging rotation policy with unrecoverable HOST and BMC error logs.
564b4cacb5aSRahul Maheshwari    [Tags]  Verify_Error_Logging_Rotation_Policy_With_Unrecoverable_HOST_And_BMC_Error_Logs
565b4cacb5aSRahul Maheshwari    [Setup]  Run Keywords  Open Connection for SCP  AND  scp.Put File  ${UNRECOVERABLE_FILE_PATH}
566e54d16f5SRahul Maheshwari    ...  /tmp/FILE_NBMC_UNRECOVERABLE  AND  Redfish.Login
567b4cacb5aSRahul Maheshwari    [Template]  Error Logging Rotation Policy
568b4cacb5aSRahul Maheshwari
569b4cacb5aSRahul Maheshwari    # Error logs to be created                                % of total logging space when error
570b4cacb5aSRahul Maheshwari    #                                                         log exceeds max limit.
5711810a5b2Smanashsarma    Unrecoverable HOST 1500, Unrecoverable BMC 1500                           60
5721810a5b2Smanashsarma
5731810a5b2Smanashsarma
5746f1f2a4eSmanashsarmaVerify Old Logs Are Deleted When Count Crosses Max
5756f1f2a4eSmanashsarma    [Documentation]  Verify that when the count crosses max, older logs are deleted.
5766f1f2a4eSmanashsarma    [Tags]  Verify_Old_Logs_Are_Deleted_When_Count_Crosses_Max
5776f1f2a4eSmanashsarma
5786f1f2a4eSmanashsarma    Redfish Purge Event Log
579caf6bd13Smanashsarma    # One information log is created after purging error log and additional 2999 are created.
580caf6bd13Smanashsarma    # In total, 3000 error logs are available.
581caf6bd13Smanashsarma    FOR  ${count}  IN RANGE  1  ${3000}
5826f1f2a4eSmanashsarma        BMC Execute Command  ${CMD_PREDICTIVE_ERROR}
5836f1f2a4eSmanashsarma    END
5846f1f2a4eSmanashsarma
5856f1f2a4eSmanashsarma    # Retrieve the IDs of the logs.
5866f1f2a4eSmanashsarma    ${pel_ids}=  Get PEL Log Via BMC CLI
587dd132687Smanashsarma    ${1st_id}=  Get From List  ${pel_ids}  0
588dd132687Smanashsarma    ${3000th_id}=  Get From List  ${pel_ids}  2999
5896f1f2a4eSmanashsarma
5906f1f2a4eSmanashsarma    # Now create 3001st log to cross threshold limit and trigger error logs rotation.
5916f1f2a4eSmanashsarma    BMC Execute Command  ${CMD_PREDICTIVE_ERROR}
592dd132687Smanashsarma
5936f1f2a4eSmanashsarma    # Wait few seconds for error logs rotation to complete.
5946f1f2a4eSmanashsarma    Sleep  10s
5956f1f2a4eSmanashsarma
5966f1f2a4eSmanashsarma    # Now verify that first log is no more available but the 3000th is available.
597dd132687Smanashsarma    ${status}  ${output}=  Run Keyword And Ignore Error  Peltool  -i ${1st_id}
598dd132687Smanashsarma    Should Be True  '${status}' == 'FAIL'
5996f1f2a4eSmanashsarma    Should Contain  ${output}  PEL not found
600dd132687Smanashsarma
601dd132687Smanashsarma    ${status}  ${output}=  Run Keyword And Ignore Error  Peltool  -i ${3000th_id}
602dd132687Smanashsarma    Should Be True  '${status}' == 'PASS'
6036f1f2a4eSmanashsarma    Should Not Contain  ${output}  PEL not found
6046f1f2a4eSmanashsarma
6056f1f2a4eSmanashsarma
6065f201204SmanashsarmaVerify Reverse Order Of PEL Logs
6075f201204Smanashsarma    [Documentation]  Verify PEL command to output PEL logs in reverse order.
6084203fad2SGeorge Keishing    [Tags]  Verify_Reverse_Order_Of_PEL_Logs
6095f201204Smanashsarma
6105f201204Smanashsarma    Redfish Purge Event Log
611c5131664Smanashsarma
612c5131664Smanashsarma    # Below commands create unrecoverable error log at first and then the predictable error.
6135f201204Smanashsarma    BMC Execute Command  ${CMD_UNRECOVERABLE_ERROR}
6145f201204Smanashsarma    BMC Execute Command  ${CMD_PREDICTIVE_ERROR}
6155f201204Smanashsarma
616c5131664Smanashsarma    # Using peltool -lr, recent PELs appear first. Hence the ID of first PEL is greater than the next.
617c5131664Smanashsarma    ${pel_records}=  peltool  -lr
6185f201204Smanashsarma
619c5131664Smanashsarma    # It is found that, variables like dictionary always keep items in sorted order that makes
620c5131664Smanashsarma    # this verification not possible, hence json is used to keep the items original order.
621c5131664Smanashsarma    ${pel_records}=  Convert To String  ${pel_records}
622c5131664Smanashsarma    ${json_string}=  Replace String  ${pel_records}  '  "
623c5131664Smanashsarma    ${json_object}=  Evaluate  json.loads('''${json_string}''')  json
624c5131664Smanashsarma
625c5131664Smanashsarma    ${list}=  Convert To List  ${json_object}
626c5131664Smanashsarma
627c5131664Smanashsarma    ${id1}=  Get From List   ${list}  0
628c5131664Smanashsarma    ${id1}=  Convert To Integer  ${id1}
629c5131664Smanashsarma    ${id2}=  Get From List   ${list}  1
630c5131664Smanashsarma    ${id2}=  Convert To Integer  ${id2}
631c5131664Smanashsarma
632c5131664Smanashsarma    Should Be True  ${id1} > ${id2}
6335f201204Smanashsarma
6345f201204Smanashsarma
6356d75bd8dSmanashsarmaVerify Total PEL Count
6366d75bd8dSmanashsarma    [Documentation]  Verify total PEL count returned by peltool command.
6376d75bd8dSmanashsarma    [Tags]  Verify_Total_PEL_Count
6386d75bd8dSmanashsarma
6396d75bd8dSmanashsarma    # Initially remove all logs.
6406d75bd8dSmanashsarma    Redfish Purge Event Log
6416d75bd8dSmanashsarma
6426d75bd8dSmanashsarma    # Generate a random number between 1-20.
6436d75bd8dSmanashsarma    ${random}=  Evaluate  random.randint(1, 20)  modules=random
6446d75bd8dSmanashsarma
6456d75bd8dSmanashsarma    # Generate predictive error log multiple times.
6466d75bd8dSmanashsarma    FOR  ${count}  IN RANGE  0  ${random}
6476d75bd8dSmanashsarma      BMC Execute Command  ${CMD_PREDICTIVE_ERROR}
6486d75bd8dSmanashsarma    END
6496d75bd8dSmanashsarma
6506d75bd8dSmanashsarma    # Check PEL log count via peltool command and compare it with actual generated log count.
6516d75bd8dSmanashsarma    ${pel_records}=  peltool  -n
6526d75bd8dSmanashsarma
6536d75bd8dSmanashsarma    Should Be Equal  ${pel_records['Number of PELs found']}   ${random}
6546d75bd8dSmanashsarma
6556d75bd8dSmanashsarma
656407dedabSmanashsarmaVerify Listing Information Error
657407dedabSmanashsarma    [Documentation]  Verify that information error logs can only be listed using -lfh option of peltool.
658407dedabSmanashsarma    [Tags]  Verify_Listing_Information_Error
659407dedabSmanashsarma
660407dedabSmanashsarma    # Initially remove all logs.
661407dedabSmanashsarma    Redfish Purge Event Log
662407dedabSmanashsarma    BMC Execute Command  ${CMD_INFORMATIONAL_ERROR}
663407dedabSmanashsarma
664407dedabSmanashsarma    # Generate informational logs and verify that it would not get listed by peltool's list command.
665407dedabSmanashsarma    ${pel_records}=  peltool  -l
66631d807bcSmanashsarma    ${ids}=  Get Dictionary Keys  ${pel_records}
66731d807bcSmanashsarma    Should Be Empty  ${ids}
668407dedabSmanashsarma
669407dedabSmanashsarma    # Verify that information logs get listed using peltool's list command with -lfh option.
670407dedabSmanashsarma    ${pel_records}=  peltool  -lfh
67131d807bcSmanashsarma    ${ids}=  Get Dictionary Keys  ${pel_records}
67231d807bcSmanashsarma    Should Not Be Empty  ${ids}
67331d807bcSmanashsarma    ${id}=  Get From List  ${ids}  0
674407dedabSmanashsarma    Should Contain  ${pel_records['${id}']['Sev']}  Informational
675407dedabSmanashsarma
676407dedabSmanashsarma
67754539ff7SmanashsarmaVerify PEL Delete
67854539ff7Smanashsarma    [Documentation]  Verify that peltool command can delete PEL log based on id.
67954539ff7Smanashsarma    [Tags]  Verify_PEL_Delete
68054539ff7Smanashsarma
68154539ff7Smanashsarma    BMC Execute Command  ${CMD_PREDICTIVE_ERROR}
68254539ff7Smanashsarma    ${pel_ids}=  Get PEL Log Via BMC CLI
68354539ff7Smanashsarma    ${id}=  Get From List  ${pel_ids}  -1
684*54424984SSridevi Ramesh    Peltool  -d ${id}  parse_json=False
6855eab56cfSRahul Maheshwari    Run Keyword and Expect Error  *PEL not found*  Peltool  -i ${id}
68654539ff7Smanashsarma
68754539ff7Smanashsarma
688fe690af5SdnirmalaVerify Mandatory Fields For Predictive Error
689fe690af5Sdnirmala    [Documentation]  Verify mandatory fields of predictive errors from pel information.
690fe690af5Sdnirmala    [Tags]  Verify_Mandatory_Fields_For_Predictive_Error
691fe690af5Sdnirmala
692fe690af5Sdnirmala    # Inject predictive error.
693fe690af5Sdnirmala    BMC Execute Command  ${CMD_PREDICTIVE_ERROR}
694fe690af5Sdnirmala
695fe690af5Sdnirmala    ${pel_ids}=  Get PEL Log Via BMC CLI
696fe690af5Sdnirmala    ${pel_id}=  Get From List  ${pel_ids}  -1
697fe690af5Sdnirmala    ${pel_output}=  Peltool  -i ${pel_id}
698fe690af5Sdnirmala    # Get all fields in predictive error log.
699fe690af5Sdnirmala    ${pel_sections}=  Get Dictionary Keys  ${pel_output}
700fe690af5Sdnirmala
701789c8021Sdnirmala    List Should Contain Sub List  ${pel_sections}  ${mandatory_Predictive_pel_fields}
702fe690af5Sdnirmala
703fe690af5Sdnirmala
704819be78fSdnirmalaVerify Mandatory Fields For Informational Error
705819be78fSdnirmala    [Documentation]  Verify mandatory fields of informational error from pel information.
706819be78fSdnirmala    [Tags]  Verify_Mandatory_Fields_For_Informational_Error
707819be78fSdnirmala
708819be78fSdnirmala    # Inject informational error.
709819be78fSdnirmala    BMC Execute Command  ${CMD_INFORMATIONAL_ERROR}
710819be78fSdnirmala    ${pel_records}=  Peltool  -lfh
711819be78fSdnirmala
712819be78fSdnirmala    ${ids}=  Get Dictionary Keys  ${pel_records}
713819be78fSdnirmala    ${pel_id}=  Get From List  ${ids}  -1
714819be78fSdnirmala    ${pel_output}=  Peltool  -i ${pel_id}
715819be78fSdnirmala
716819be78fSdnirmala    # Get all fields in the informational error log.
717819be78fSdnirmala    ${pel_sections}=  Get Dictionary Keys  ${pel_output}
718819be78fSdnirmala    FOR  ${section}  IN  @{Mandatory_Informational_Pel_Fields}
719819be78fSdnirmala        ${contains}=  Evaluate  "${section}" in "${pel_sections}"
720819be78fSdnirmala        Should Be True  ${contains}
721819be78fSdnirmala    END
722819be78fSdnirmala
723819be78fSdnirmala
724a861e14cSdnirmalaVerify PEL Log Offloaded To Host
725a861e14cSdnirmala    [Documentation]  Verify host transmission state of offloaded PEL logs.
726a861e14cSdnirmala    [Tags]  Verify_PEL_Log_Offloaded_To_Host
727a861e14cSdnirmala    [Template]  Verify PEL Transmission To Host
728a861e14cSdnirmala
729a861e14cSdnirmala    # error_type            host_state      expected_transmission_state
730a861e14cSdnirmala      predictive_error      On              Acked
731b75a8558Sdnirmala      unrecoverable_error   On              Acked
732b75a8558Sdnirmala      informational_error   On              Acked
733a861e14cSdnirmala
734a861e14cSdnirmala
735789c8021SdnirmalaVerify PEL Log Not Offloaded To Host
736789c8021Sdnirmala    [Documentation]  Verify host transmission state of not offloaded PEL logs.
737789c8021Sdnirmala    [Tags]  Verify_PEL_Log_Not_Offloaded_To_Host
738789c8021Sdnirmala    [Template]  Verify PEL Transmission To Host
739789c8021Sdnirmala
740789c8021Sdnirmala    # error_type            host_state      expected_transmission_state
741789c8021Sdnirmala      predictive_error      Off             Not Sent
742b75a8558Sdnirmala      unrecoverable_error   Off             Not Sent
743b75a8558Sdnirmala      informational_error   Off             Not Sent
744789c8021Sdnirmala
745789c8021Sdnirmala
746faa5d20aSRahul Maheshwari*** Keywords ***
747faa5d20aSRahul Maheshwari
748595282d6SmanashsarmaError Logging Rotation Policy
749595282d6Smanashsarma    [Documentation]  Verify that when maximum log limit is reached, given error logging type
750595282d6Smanashsarma    ...  are deleted when reached their max allocated space.
751595282d6Smanashsarma    [Arguments]  ${error_log_type}  ${max_allocated_space_percentage}
752595282d6Smanashsarma
753595282d6Smanashsarma    # Description of argument(s):
754557b6320Smanashsarma    # error_log                           Error logs to be created (E.g. Informational BMC 3000
755557b6320Smanashsarma    #                                     stands for BMC created 3000 informational error logs).
756595282d6Smanashsarma    # max_allocated_space_percentage      The maximum percentage of disk usage for given error
757595282d6Smanashsarma    #                                     log type when maximum count/log size is reached.
758595282d6Smanashsarma    #                                     The maximum error log count is 3000.
759595282d6Smanashsarma
7606beaeab1SGeorge Keishing    Redfish.Login
7616beaeab1SGeorge Keishing
762595282d6Smanashsarma    # Initially remove all logs. Purging is done to ensure that, only specific logs are present
763595282d6Smanashsarma    # in BMC during the test.
764595282d6Smanashsarma    Redfish Purge Event Log
765595282d6Smanashsarma
766557b6320Smanashsarma    @{lists}=  Split String  ${error_log_type}  ,${SPACE}
767595282d6Smanashsarma
768557b6320Smanashsarma    ${length}=  Get Length  ${lists}
769595282d6Smanashsarma
770557b6320Smanashsarma    FOR  ${list}  IN RANGE  ${length}
771557b6320Smanashsarma        @{words}=  Split String  ${lists}[${list}]  ${SPACE}
772557b6320Smanashsarma        Create Error Log  ${words}[0]  ${words}[1]  ${words}[2]
773595282d6Smanashsarma    END
774595282d6Smanashsarma
775557b6320Smanashsarma    # Create an additional error log to exceed max error logs limit.
776557b6320Smanashsarma    BMC Execute Command  ${CMD_UNRECOVERABLE_ERROR}
777557b6320Smanashsarma
778595282d6Smanashsarma    # Delay for BMC to perform delete older error logs when log limit exceeds.
779595282d6Smanashsarma    Sleep  10s
780595282d6Smanashsarma
781595282d6Smanashsarma    # Verify disk usage is around max allocated space. Maximum usage is around 3MB not exactly 3MB
782595282d6Smanashsarma    # (for informational log) and around 6 MB for unrecoverable / predictive error log. So, usage
783595282d6Smanashsarma    # percentage is NOT exactly 15% and 30%. So, an error/accuracy factor 0.5 percent is added.
784595282d6Smanashsarma
785595282d6Smanashsarma    ${disk_usage_percentage}=  Get Disk Usage For Error Logs
786595282d6Smanashsarma    ${percent_diff}=  Evaluate  ${disk_usage_percentage} - ${max_allocated_space_percentage}
787595282d6Smanashsarma    ${percent_diff}=   Evaluate  abs(${percent_diff})
7884baa6a77Smanashsarma
7894baa6a77Smanashsarma    ${trimmed_as_expected}=  Run Keyword If  ${disk_usage_percentage} > ${max_allocated_space_percentage}
7904baa6a77Smanashsarma    ...  Evaluate  ${percent_diff} <= 0.5
7914baa6a77Smanashsarma    ...  ELSE
7924baa6a77Smanashsarma    ...  Set Variable  True
7934baa6a77Smanashsarma
7944baa6a77Smanashsarma    # Check PEL log count via peltool command and compare it with actual generated log count.
7954baa6a77Smanashsarma    ${pel_records}=  peltool  -n
7964baa6a77Smanashsarma    ${no_pel_records}=  Set Variable  ${pel_records["Number of PELs found"]}
7974baa6a77Smanashsarma    # Number of logs can be 80% of the total logs created after trimming.
7984baa6a77Smanashsarma    ${expected_max_record}=   Evaluate  3000 * 0.8
7994baa6a77Smanashsarma
800b78bca24SGeorge Keishing    Run Keyword If  ${trimmed_as_expected} == False
801b78bca24SGeorge Keishing    ...  Should Be True  ${no_pel_records} <= ${expected_max_record}
802595282d6Smanashsarma
803595282d6Smanashsarma
804557b6320SmanashsarmaCreate Error Log
805f9248957SGeorge Keishing    [Documentation]  Create an error log.
806557b6320Smanashsarma    [Arguments]  ${error_severity}   ${error_creator}   ${count}
807557b6320Smanashsarma
808557b6320Smanashsarma    # Description of argument(s):
809557b6320Smanashsarma    # error_severity             Severity of the error (E.g. Informational, Unrecoberable or Predictive)
810557b6320Smanashsarma    # error_creator              Name of error log's creator(E.g BMC, Host Boot)
811557b6320Smanashsarma    # count                      Number of error logs to be generated.
812557b6320Smanashsarma
813557b6320Smanashsarma    FOR  ${i}  IN RANGE  0  ${count}
814557b6320Smanashsarma        ${cmd}=  Set Variable If
8155eab56cfSRahul Maheshwari        ...  '${error_severity}' == 'Informational' and '${error_creator}' == 'BMC'  ${CMD_INFORMATIONAL_ERROR}
816952bad1dSRahul Maheshwari        ...  '${error_severity}' == 'Informational' and '${error_creator}' == 'HOST'  ${CMD_INFORMATIONAL_HOST_ERROR}
8175eab56cfSRahul Maheshwari        ...  '${error_severity}' == 'Predictive' and '${error_creator}' == 'BMC'  ${CMD_PREDICTIVE_ERROR}
8185eab56cfSRahul Maheshwari        ...  '${error_severity}' == 'Unrecoverable' and '${error_creator}' == 'BMC'  ${CMD_UNRECOVERABLE_ERROR}
8195eab56cfSRahul Maheshwari        ...  '${error_severity}' == 'Unrecoverable' and '${error_creator}' == 'HOST'  ${CMD_UNRECOVERABLE_HOST_ERROR}
820557b6320Smanashsarma        BMC Execute Command  ${cmd}
821557b6320Smanashsarma    END
822557b6320Smanashsarma
823557b6320Smanashsarma
824d073a0a3SmanashsarmaGet Disk Usage For Error Logs
825d073a0a3Smanashsarma    [Documentation]  Get disk usage percentage for error logs.
826d073a0a3Smanashsarma
827d073a0a3Smanashsarma    ${usage_output}  ${stderr}  ${rc}=  BMC Execute Command  du /var/lib/phosphor-logging/errors
828d073a0a3Smanashsarma
829d073a0a3Smanashsarma    ${usage_output}=  Fetch From Left  ${usage_output}  \/
830d073a0a3Smanashsarma
831c91aadd2SGeorge Keishing    # Convert disk usage unit from KB to MB.
832d073a0a3Smanashsarma    ${usage_output}=  Evaluate  ${usage_output} / 1024
833d073a0a3Smanashsarma
834d073a0a3Smanashsarma    # Logging disk capacity limit is set to 20MB. So calculating the log usage percentage.
835d073a0a3Smanashsarma    ${usage_percent}=  Evaluate  ${usage_output} / 20 * 100
836d073a0a3Smanashsarma
837409df05dSGeorge Keishing    RETURN  ${usage_percent}
838d073a0a3Smanashsarma
839d073a0a3Smanashsarma
8408f5256fcSRahul MaheshwariGet PEL Log IDs
8418f5256fcSRahul Maheshwari    [Documentation]  Returns the list of PEL log IDs which contains given field's value.
8428f5256fcSRahul Maheshwari    [Arguments]  ${pel_section}  ${pel_field}  @{pel_field_value}
8438f5256fcSRahul Maheshwari
8448f5256fcSRahul Maheshwari    # Description of argument(s):
8458f5256fcSRahul Maheshwari    # pel_section      The section of PEL (e.g. Private Header, User Header).
8468f5256fcSRahul Maheshwari    # pel_field        The PEL field (e.g. Event Severity, Event Type).
8478f5256fcSRahul Maheshwari    # pel_field_value  The list of PEL's field value (e.g. Unrecoverable Error).
8488f5256fcSRahul Maheshwari
8498f5256fcSRahul Maheshwari    ${pel_ids}=  Get PEL Log Via BMC CLI
8508f5256fcSRahul Maheshwari    @{pel_id_list}=  Create List
8518f5256fcSRahul Maheshwari
8528f5256fcSRahul Maheshwari    FOR  ${id}  IN  @{pel_ids}
8538f5256fcSRahul Maheshwari      ${pel_output}=  Peltool  -i ${id}
8548f5256fcSRahul Maheshwari      # Example of PEL output from "peltool -i <id>" command.
8558f5256fcSRahul Maheshwari      #  [Private Header]:
8568f5256fcSRahul Maheshwari      #    [Created at]:                                 08/24/1928 12:04:06
8578f5256fcSRahul Maheshwari      #    [Created by]:                                 0x584D
8588f5256fcSRahul Maheshwari      #    [Sub-section type]:                           0
8598f5256fcSRahul Maheshwari      #    [Entry Id]:                                   0x50000BB7
8608f5256fcSRahul Maheshwari      #    [Platform Log Id]:                            0x8200061D
8618f5256fcSRahul Maheshwari      #    [CSSVER]:
8628f5256fcSRahul Maheshwari      #    [Section Version]:                            1
8638f5256fcSRahul Maheshwari      #    [Creator Subsystem]:                          PHYP
8648f5256fcSRahul Maheshwari      #    [BMC Event Log Id]:                           341
8658f5256fcSRahul Maheshwari      #    [Committed at]:                               03/25/1920 12:06:22
8668f5256fcSRahul Maheshwari      #  [User Header]:
8678f5256fcSRahul Maheshwari      #    [Log Committed by]:                           0x4552
8688f5256fcSRahul Maheshwari      #    [Action Flags]:
8698f5256fcSRahul Maheshwari      #      [0]:                                        Report Externally
8708f5256fcSRahul Maheshwari      #    [Subsystem]:                                  I/O Subsystem
8718f5256fcSRahul Maheshwari      #    [Event Type]:                                 Miscellaneous, Informational Only
8728f5256fcSRahul Maheshwari      #    [Sub-section type]:                           0
8738f5256fcSRahul Maheshwari      #    [Event Scope]:                                Entire Platform
8748f5256fcSRahul Maheshwari      #    [Event Severity]:                             Informational Event
8758f5256fcSRahul Maheshwari      #    [Host Transmission]:                          Not Sent
8768f5256fcSRahul Maheshwari      #    [Section Version]:                            1
8778f5256fcSRahul Maheshwari
8788f5256fcSRahul Maheshwari      ${pel_section_output}=  Get From Dictionary  ${pel_output}  ${pel_section}
8798f5256fcSRahul Maheshwari      ${pel_field_output}=  Get From Dictionary  ${pel_section_output}  ${pel_field}
8808f5256fcSRahul Maheshwari      Run Keyword If  '${pel_field_output}' in @{pel_field_value}  Append To List  ${pel_id_list}  ${id}
8818f5256fcSRahul Maheshwari    END
8828f5256fcSRahul Maheshwari    Sort List  ${pel_id_list}
8838f5256fcSRahul Maheshwari
884409df05dSGeorge Keishing    RETURN  ${pel_id_list}
8858f5256fcSRahul Maheshwari
8868f5256fcSRahul Maheshwari
887f575c90aSRahul MaheshwariGet PEL Log Via BMC CLI
888f575c90aSRahul Maheshwari    [Documentation]  Returns the list of PEL IDs using BMC CLI.
889faa5d20aSRahul Maheshwari
890faa5d20aSRahul Maheshwari    ${pel_records}=  Peltool  -l
891f575c90aSRahul Maheshwari    ${ids}=  Get Dictionary Keys  ${pel_records}
8921cffc4b1SRahul Maheshwari    Sort List  ${ids}
893faa5d20aSRahul Maheshwari
894409df05dSGeorge Keishing    RETURN  ${ids}
89560b58a8bSRahul Maheshwari
89660b58a8bSRahul Maheshwari
89760b58a8bSRahul MaheshwariGet PEL Field Value
89860b58a8bSRahul Maheshwari    [Documentation]  Returns the value of given PEL's field.
89960b58a8bSRahul Maheshwari    [Arguments]  ${pel_id}  ${pel_section}  ${pel_field}
90060b58a8bSRahul Maheshwari
90160b58a8bSRahul Maheshwari    # Description of argument(s):
90260b58a8bSRahul Maheshwari    # pel_id           The ID of PEL (e.g. 0x5000002D, 0x5000002E).
90360b58a8bSRahul Maheshwari    # pel_section      The section of PEL (e.g. Private Header, User Header)
90460b58a8bSRahul Maheshwari    # pel_field        The PEL field (e.g. Event Severity, Event Type).
90560b58a8bSRahul Maheshwari
90660b58a8bSRahul Maheshwari    ${pel_output}=  Peltool  -i ${pel_id}
90760b58a8bSRahul Maheshwari
90860b58a8bSRahul Maheshwari    # Example of PEL output from "peltool -i <id>" command.
90960b58a8bSRahul Maheshwari    #  [Private Header]:
91060b58a8bSRahul Maheshwari    #    [Created at]:                                 08/24/1928 12:04:06
91160b58a8bSRahul Maheshwari    #    [Created by]:                                 0x584D
91260b58a8bSRahul Maheshwari    #    [Sub-section type]:                           0
91360b58a8bSRahul Maheshwari    #    [Entry Id]:                                   0x50000BB7
91460b58a8bSRahul Maheshwari    #    [Platform Log Id]:                            0x8200061D
91560b58a8bSRahul Maheshwari    #    [CSSVER]:
91660b58a8bSRahul Maheshwari    #    [Section Version]:                            1
91760b58a8bSRahul Maheshwari    #    [Creator Subsystem]:                          PHYP
91860b58a8bSRahul Maheshwari    #    [BMC Event Log Id]:                           341
91960b58a8bSRahul Maheshwari    #    [Committed at]:                               03/25/1920 12:06:22
92060b58a8bSRahul Maheshwari    #  [User Header]:
92160b58a8bSRahul Maheshwari    #    [Log Committed by]:                           0x4552
92260b58a8bSRahul Maheshwari    #    [Action Flags]:
92360b58a8bSRahul Maheshwari    #      [0]:                                        Report Externally
92460b58a8bSRahul Maheshwari    #    [Subsystem]:                                  I/O Subsystem
92560b58a8bSRahul Maheshwari    #    [Event Type]:                                 Miscellaneous, Informational Only
92660b58a8bSRahul Maheshwari    #    [Sub-section type]:                           0
92760b58a8bSRahul Maheshwari    #    [Event Scope]:                                Entire Platform
92860b58a8bSRahul Maheshwari    #    [Event Severity]:                             Informational Event
92960b58a8bSRahul Maheshwari    #    [Host Transmission]:                          Not Sent
93060b58a8bSRahul Maheshwari    #    [Section Version]:                            1
93160b58a8bSRahul Maheshwari
93260b58a8bSRahul Maheshwari    ${pel_section_output}=  Get From Dictionary  ${pel_output}  ${pel_section}
93360b58a8bSRahul Maheshwari    ${pel_field_output}=  Get From Dictionary  ${pel_section_output}  ${pel_field}
93460b58a8bSRahul Maheshwari
935409df05dSGeorge Keishing    RETURN  ${pel_field_output}
936789c8021Sdnirmala
937789c8021Sdnirmala
938789c8021SdnirmalaVerify PEL Transmission To Host
939789c8021Sdnirmala    [Documentation]  Inject PEL log of given type and verify its host transmission state.
940789c8021Sdnirmala    [Arguments]  ${error_type}  ${host_state}  ${expected_transmission_state}
941789c8021Sdnirmala
942789c8021Sdnirmala    # Description of argument(s):
943789c8021Sdnirmala    # error_type                         Type of error log to be injected.
944789c8021Sdnirmala    # host_state                         Host state which is required before error log injection.
945789c8021Sdnirmala    # expected_transmission_state        Expected host transmission state of PEL log.
946789c8021Sdnirmala
947789c8021Sdnirmala    # Get system in required state.
948789c8021Sdnirmala    Run Keyword If  '${host_state}' == 'Off'
949789c8021Sdnirmala    ...  Redfish Power Off  stack_mode=skip
950789c8021Sdnirmala    ...  ELSE IF  '${host_state}' == 'On'
951f3bbd1b0Sdnirmala    ...  Run Keywords  Redfish Power On  stack_mode=skip  AND
952f3bbd1b0Sdnirmala    ...  Wait For Host To Ping  ${OS_HOST}  5 min  10 sec
953b75a8558Sdnirmala
954cec17c7dSdnirmala    Redfish Purge Event Log
955cec17c7dSdnirmala
956789c8021Sdnirmala    # Inject required error log.
957789c8021Sdnirmala    Run Keyword If  "${error_type}" == "informational_error"
958789c8021Sdnirmala    ...  BMC Execute Command  ${CMD_INFORMATIONAL_ERROR}
959789c8021Sdnirmala    ...  ELSE IF  "${error_type}" == "unrecoverable_error"
960789c8021Sdnirmala    ...  BMC Execute Command  ${CMD_UNRECOVERABLE_ERROR}
961789c8021Sdnirmala    ...  ELSE IF  "${error_type}" == "predictive_error"
962789c8021Sdnirmala    ...  BMC Execute Command  ${CMD_PREDICTIVE_ERROR}
963789c8021Sdnirmala
964cec17c7dSdnirmala    ${pel_records}=  Get Pel Data From Bmc  True  True
965cec17c7dSdnirmala    ${ids}=  Get Dictionary Keys  ${pel_records}
966cec17c7dSdnirmala    ${pel_id}=  Get From List  ${ids}  -1
967cec17c7dSdnirmala
968789c8021Sdnirmala    # Check host transmission state for the cases where PEL is
969789c8021Sdnirmala    # expected to be  offloaded to HOST.
970789c8021Sdnirmala    Run Keyword If  "${expected_transmission_state}" == "Acked"
971b75a8558Sdnirmala    ...  Wait Until Keyword Succeeds  15 min  10 sec
972cec17c7dSdnirmala    ...  Check If PEL Transmission State Is Expected  ${pel_id}  Acked
973789c8021Sdnirmala
974789c8021Sdnirmala    # Adding delay before checking host transmission for the cases where PEL is
975789c8021Sdnirmala    # not expected to be offloaded to HOST.
976789c8021Sdnirmala    Run Keyword If  "${expected_transmission_state}" == "Not sent"
977789c8021Sdnirmala    ...  Run Keywords  Sleep  120s  AND
978cec17c7dSdnirmala    ...  Check If PEL Transmission State Is Expected  ${pel_id}  Not sent
979789c8021Sdnirmala
980789c8021Sdnirmala
981789c8021SdnirmalaCheck If PEL Transmission State Is Expected
982789c8021Sdnirmala    [Documentation]  Check if PEL's host transmission state is matching expected state.
983cec17c7dSdnirmala    [Arguments]  ${pel_id}  ${expected_transmission_state}
984789c8021Sdnirmala
985789c8021Sdnirmala    # Description of argument(s):
986789c8021Sdnirmala    # expected_transmission_state       Expected transmission state of PEL log.
987789c8021Sdnirmala
988789c8021Sdnirmala    # Check the transmission details in the error log.
989789c8021Sdnirmala    ${host_transmission}=  Get PEL Field Value  ${pel_id}  User Header  Host Transmission
990789c8021Sdnirmala    Should Be Equal  ${host_transmission}  ${expected_transmission_state}
991