1*** Settings ***
2
3Documentation       eSEL's Test cases.
4
5Resource            ../../../lib/ipmi_client.robot
6Resource            ../../../lib/openbmc_ffdc.robot
7Resource            ../../../lib/utils.robot
8Resource            ../../../lib/boot_utils.robot
9Resource            ../../../lib/esel_utils.robot
10Resource            ../../../lib/boot_utils.robot
11Variables           ../../../data/variables.py
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  eSEL_Logging
19
20*** Variables ***
21
22${stack_mode}       skip
23
24${LOGGING_SERVICE}  xyz.openbmc_project.Logging.service
25
26${ESEL_DATA}        ESEL=00 00 df 00 00 00 00 20 00 04 12 35 6f aa 00 00
27
28*** Test Cases ***
29
30Verify eSEL Using Redfish
31    [Documentation]  Generate eSEL log and verify using redfish.
32    [Tags]  Verify_eSEL_Using_Redfish
33
34    Create eSEL
35    Event Log Should Exist
36
37
38Verify eSEL Entries Using Redfish
39    [Documentation]  Verify that eSEL entries have data.
40    [Tags]  Verify_eSEL_Entries_Using_Redfish
41
42    Create eSEL
43    Redfish.Login
44    Verify eSEL Entries
45
46
47# TODO: openbmc/openbmc-test-automation#1789
48Verify eSEL Description And EntryID Using REST
49    [Documentation]  Create eSEL log and verify "Description" and "EntryID"
50    ...  are not empty via REST.
51    [Tags]  Verify_eSEL_Description_And_EntryID_Using_REST
52
53    # {
54    # "AdditionalData": [
55    #     "CALLOUT_INVENTORY_PATH=",
56    #     "ESEL=00 00 df 00 00 00 00 20 00 04 12 35 6f aa 00 00",
57    #     "_PID=1175"
58    # ],
59    # "Description": "An error was detected with the base platform,
60    #  but was not able to be deciphered. Contact your next level of support.",
61    # "EventID": "FQPSPAA0011M",
62    # "Id": 1,
63    # "Message": "org.open_power.Host.Error.Event",
64    # "Resolved": 0,
65    # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
66    # "Timestamp": 1524233022072,
67    # "Associations": [
68    #    [
69    #        "callout",
70    #        "fault",
71    #        ""
72    #    ]
73    # ]
74
75    Create eSEL
76
77    ${elog_entry}=  Get URL List  ${BMC_LOGGING_ENTRY}
78    ${desc}=  Read Attribute  ${elog_entry[0]}  Description
79    Should Not Be Empty  ${desc}  msg=${desc} is not populated.
80
81    ${event_id}=  Read Attribute  ${elog_entry[0]}  EventID
82    Should Not Be Equal  ${event_id}  ${None}
83    ...  msg=${event_id} is populated default "None".
84
85
86Verify Multiple eSEL Using Redfish
87    [Documentation]  Generate multiple eSEL log and verify using redfish
88    [Tags]  Verify_Multiple_eSEL_Using_Redfish
89
90    Create eSEL
91    Create eSEL
92    ${entries}=  Count eSEL Entries
93    Should Be Equal As Integers  ${entries}  ${2}
94    ...  msg=Expecting 2 eSELs but found ${entries}.
95
96
97# TODO: openbmc/openbmc-test-automation#1789
98Check eSEL AdditionalData
99    [Documentation]  Generate eSEL log and verify AdditionalData is
100    ...              not empty.
101    [Tags]  Check_eSEL_AdditionalData
102
103    Create eSEL
104    ${elog_entry}=  Get URL List  ${BMC_LOGGING_ENTRY}
105    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
106    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
107    ${jsondata}=  To JSON  ${resp.content}
108    # "/xyz/openbmc_project/logging/entry/1": {
109    #    "Timestamp": 1487743771812,
110    #    "AdditionalData": [],
111    #    "Message": "org.open_power.Error.Host.Event.Event",
112    #    "Id": 1,
113    #    "Severity": "xyz.openbmc_project.Logging.Entry.Level.Emergency"
114    # }
115    Should Not Be Empty  ${jsondata["data"]["AdditionalData"]}
116
117
118Test Wrong Reservation_ID
119    [Documentation]  This testcase is to test BMC can handle multi-requestor's
120    ...              oem partial add command with incorrect reservation id.
121    ...              It simulates sending partial add command with fake content
122    ...              and wrong Reservation ID. This command will be rejected.
123    [Tags]  Test_Wrong_Reservation_ID
124
125    ${rev_id_1}=   Run Inband IPMI Raw Command  0x0a 0x42
126    ${rev_id_ls}=   Get Substring   ${rev_id_1}   1   3
127    ${rev_id_ms}=   Get Substring   ${rev_id_1}   -2
128    Run Inband IPMI Raw Command   0x0a 0x42
129    ${output}=  Check IPMI OEMpartialadd Reject
130    ...  0x3a 0xf0 0x${rev_id_ls} 0x${rev_id_ms} 0 0 0 0 0 1 2 3 4 5 6 7 8 9 0xa 0xb 0xc 0xd 0xe 0xf
131    Should Contain   ${output}   Reservation cancelled
132
133Test Correct Reservation_ID
134    [Documentation]  This testcase is to test BMC can handle multi-requestor's
135    ...              oem partial add command with correct reservation id. It
136    ...              simulates sending partial add command with fake content
137    ...              and correct Reservation ID. This command will be accepted.
138    [Tags]  Test_Correct_Reservation_ID
139
140    Run Inband IPMI Raw Command  0x0a 0x42
141    ${rev_id_2}=    Run Inband IPMI Raw Command  0x0a 0x42
142    ${rev_id_ls}=   Get Substring   ${rev_id_2}   1   3
143    ${rev_id_ms}=   Get Substring   ${rev_id_2}   -2
144    ${output}=  Check IPMI OEMpartialadd Accept
145    ...  0x3a 0xf0 0x${rev_id_ls} 0x${rev_id_ms} 0 0 0 0 0 1 2 3 4 5 6 7 8 9 0xa 0xb 0xc 0xd 0xe 0xf
146    Should Be Empty    ${output}
147
148
149*** Keywords ***
150
151
152Suite Teardown Execution
153    [Documentation]  Cleanup test logs and connection.
154    Close All Connections
155    Redfish.Logout
156
157
158Restart Logging Service
159    [Documentation]  Restart Logging to clear eSEL log.
160    ${MainPID}  ${stderr}=  Execute Command
161    ...  systemctl restart ${LOGGING_SERVICE}  return_stderr=True
162    Should Be Empty  ${stderr}
163
164    Sleep  10s  reason=Wait for service to restart properly.
165
166
167Run IPMI Command Returned
168    [Documentation]  Run the IPMI command and return the output.
169    [Arguments]    ${args}
170    ${output_1}=    Execute Command   /tmp/ipmitool -I dbus raw ${args}
171    [Return]    ${output_1}
172
173
174Check IPMI OEMpartialadd Reject
175    [Documentation]  Check if IPMI rejects the OEM partial add command.
176    [Arguments]    ${args}
177    Login To OS Host  ${OS_HOST}  ${OS_USERNAME}  ${OS_PASSWORD}
178    ${stdout}  ${stderr}  ${output_2}=  Execute Command  ipmitool raw ${args}
179    ...        return_stdout=True  return_stderr=True  return_rc=True
180    [Return]  ${stderr}
181
182
183Test Setup Execution
184   [Documentation]  Do test case setup tasks.
185
186    Redfish.Login
187    Redfish Purge Event Log
188
189
190Suite Setup Execution
191    [Documentation]  Validates input parameters & check if HOST OS is up.
192
193    Should Not Be Empty
194    ...   ${OS_HOST}  msg=You must provide DNS name/IP of the OS host.
195    Should Not Be Empty
196    ...   ${OS_USERNAME}  msg=You must provide OS host user name.
197    Should Not Be Empty
198    ...   ${OS_PASSWORD}  msg=You must provide OS host user password.
199
200    # Boot to OS.
201    Redfish Power On
202
203    Redfish.Login
204    Redfish Purge Event Log
205
206    Login To OS Host  ${OS_HOST}  ${OS_USERNAME}  ${OS_PASSWORD}
207    Open Connection And Log In
208
209
210Check IPMI OEMpartialadd Accept
211    [Documentation]  Check if IPMI accepts the OEM partial add command.
212    [Arguments]    ${args}
213    Login To OS Host  ${OS_HOST}  ${OS_USERNAME}  ${OS_PASSWORD}
214    ${stdout}  ${stderr}  ${output_3}=  Execute Command  ipmitool raw ${args}
215    ...         return_stdout=True  return_stderr=True  return_rc=True
216    Should Be Equal  ${output_3}  ${0}  msg=${stderr}
217    [Return]  ${stderr}
218
219
220Event Log Should Exist
221    [Documentation]  Event log entries should exist.
222
223    ${elogs}=  Get Event Logs
224    Should Not Be Empty  ${elogs}  msg=System event log entry is not empty.
225