blob: 2b5d7ad8a93c19cd3cff6cefe82c2a55c36d03db [file] [log] [blame]
aravinth0510350edc82022-09-30 06:33:48 +00001*** Settings ***
2
3Documentation Test task service and tasks URI functionality of OpenBMC.
4
5Library OperatingSystem
6
7Resource ../../lib/resource.robot
8Resource ../../lib/bmc_redfish_resource.robot
9Resource ../../lib/dump_utils.robot
10Resource ../../lib/openbmc_ffdc.robot
11
12Suite Setup Suite Setup Execution
13Suite Teardown Suite Teardown Execution
14Test Teardown FFDC On Test Case Fail
15
aravinth0510350edc82022-09-30 06:33:48 +000016*** Variables ***
17${TIME_REGEXP_PATTERN} (.+)[\\-|\\+]\\d\\d\\:\\d\\d
18
aravinth0510350edc82022-09-30 06:33:48 +000019*** Test Cases ***
20
21Verify Task Service Attributes
22 [Documentation] Validate attributes and default values in task service URI.
23 [Tags] Verify_Task_Service_Attributes
24
25 # {
26 # "@odata.id": "/redfish/v1/TaskService",
27 # "@odata.type": "#TaskService.v1_1_4.TaskService",
28 # "CompletedTaskOverWritePolicy": "Oldest",
29 # "DateTime": "2022-08-08T06:04:11+00:00",
30 # "Id": "TaskService",
31 # "LifeCycleEventOnTaskStateChange": true,
32 # "Name": "Task Service",
33 # "ServiceEnabled": true,
34 # "Status": {
35 # "Health": "OK",
36 # "HealthRollup": "OK",
37 # "State": "Enabled"
38 # },
39 # "Tasks": {
40 # "@odata.id": "/redfish/v1/TaskService/Tasks"
41 # }
42 # }
43
44 ${resp}= Redfish.Get Properties /redfish/v1/TaskService
45
46 # Verify CompletedTaskOverWritePolicy is a valid value.
47 Should Be True
48 ... '${resp["CompletedTaskOverWritePolicy"]}' in ${allowed_completed_task_overwrite_policy}
49
50 # Verify service enabled property.
51 Should Be Equal ${resp["ServiceEnabled"]} ${TRUE}
52
53 # Verify status.
54 Dictionaries Should Be Equal ${resp["Status"]} ${valid_status}
55
56 # Get current time from BMC console.
57 ${cur_time}= Get Current Date from BMC
58
59 # Remove offset from task service time.
60 ${bmc_time}= Get Regexp Matches ${resp["DateTime"]}
61 ... ${TIME_REGEXP_PATTERN} 1
62
63 ${time_diff}= Subtract Date From Date ${cur_time} ${bmc_time[0]}
64 ... date1_format=%m/%d/%Y %H:%M:%S date2_format=%Y-%m-%dT%H:%M:%S
65
66 # Compare system time and time displayed in task service URI.
67 ${time_diff}= Evaluate ${time_diff} < 5
68
69 Should Be Equal ${time_diff} ${TRUE}
70 ... Time Difference between BMC time and time displayed in task URI is higher.
71
72
73Test Generated Task Instance Validity And Task State
74 [Documentation] Trigger a Redfish event that generates task instance and
75 ... verify the values of generated task instance.
76 [Tags] Test_Generated_Task_Instance_Validity_And_Task_State
77
78 # {
79 # "@odata.id": "/redfish/v1/TaskService/Tasks/3",
80 # "@odata.type": "#Task.v1_4_3.Task",
81 # "Id": "3",
82 # "Messages": [
83 # {
84 # "@odata.type": "#Message.v1_0_0.Message",
85 # "Message": "The task with id 3 has started.",
86 # "MessageArgs": [
87 # "3"
88 # ],
89 # "MessageId": "TaskEvent.1.0.1.TaskStarted",
90 # "Resolution": "None.",
91 # "Severity": "OK"
92 # }
93 # ],
94 # "Name": "Task 3",
95 # "Payload": {
96 # "HttpHeaders": [
97 # "User-Agent: PostmanRuntime/7.26.8",
98 # "Accept: */*",
99 # "Host: 10.0.123.113",
100 # "Accept-Encoding: gzip, deflate, br",
101 # "Connection: keep-alive",
102 # "Content-Length: 41"
103 # ],
104 # "HttpOperation": "POST",
105 # "JsonBody": "{\n \"DiagnosticDataType\": \"Manager\"\n}",
106 # "TargetUri": "/redfish/v1/Managers/bmc/LogServices/Dump/Actions
107 # /LogService.CollectDiagnosticData"
108 # },
109 # "PercentComplete": 0,
110 # "StartTime": "2022-08-09T12:57:06+00:00",
111 # "TaskMonitor": "/redfish/v1/TaskService/Tasks/3/Monitor",
112 # "TaskState": "Running",
113 # "TaskStatus": "OK"
114 # }
115
116 # Trigger a Redfish event that generates task instance.
117 ${task_id} ${resp_obj}= Generate Task Instance
118
119 # Verify task monitor before task completion.
120 ${resp}= Redfish.Get /redfish/v1/TaskService/Tasks/${task_id}/Monitor
121 ... valid_status_codes=[${HTTP_ACCEPTED}]
122
123 # Get current time from BMC console before generating task.
124 ${cur_time}= Get Current Date from BMC
125
126 # Verify task start time is within 10s of current time.
127 ${resp}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
128
129 ${start_time}= Get Regexp Matches ${resp["StartTime"]}
130 ... ${TIME_REGEXP_PATTERN} 1
131
132 # Compare system time and time displayed in task service URI.
133 ${time_diff}= Subtract Date From Date ${cur_time} ${start_time[0]}
134 ... date1_format=%m/%d/%Y %H:%M:%S date2_format=%Y-%m-%dT%H:%M:%S
135
George Keishing206f6ed2023-01-30 08:05:45 -0600136
aravinth0510350edc82022-09-30 06:33:48 +0000137 ${time_diff}= Evaluate ${time_diff} < 10
138 Should Be Equal ${time_diff} ${TRUE} Time difference greater than 10 seconds.
139
140 # Verify HttpOperation in task payload.
141 Should Be Equal ${resp["Payload"]["HttpOperation"]} POST
142
143 # Verify TargetUri.
144 Should Be Equal ${resp["Payload"]["TargetUri"]}
145 ... ${resp_obj.request.path}
146
147 Wait For Task Completion ${task_id} ${allowed_task_completion_state}
148 ... check_state=${TRUE}
149
150 # Verify task monitor URI after task completion.
151 ${resp}= Redfish.Get /redfish/v1/TaskService/Tasks/${task_id}/Monitor
152 ... valid_status_codes=[${HTTP_NOT_FOUND}]
153
154 # Verify end time is greater than start time post task completion.
155 ${resp}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
156
157 ${end_time}= Get Regexp Matches ${resp["EndTime"]}
158 ... ${TIME_REGEXP_PATTERN} 1
159
160 # Compare start time and end time displayed in task service URI.
161 ${time_diff}= Subtract Date From Date ${end_time[0]} ${start_time[0]}
162
163 ${time_diff}= Evaluate ${time_diff} >= 0
164
165 Should Be Equal ${time_diff} ${TRUE}
166 ... End time not greater than start time.
167
168
169Verify Task Persistency Post BMC Reboot
170 [Documentation] Verify task collection persistency post BMC reboot.
171 [Tags] Verify_Task_Persistency_Post_BMC_Reboot
172
173 Verify Generate Task Instance Completion
174
175 ${initial_task_count}= Redfish.Get Attribute /redfish/v1/TaskService/Tasks
176 ... Members@odata.count
177
178 Redfish BMC Reset Operation reset_type=ForceRestart
179
180 ${current_task_count}= Redfish.Get Attribute /redfish/v1/TaskService/Tasks
181 ... Members@odata.count
182
183 Should Be Equal As Integers ${initial_task_count} ${current_task_count}
184
185
186*** Keywords ***
187
188Suite Setup Execution
189 [Documentation] Do suite setup operation.
190
191 Redfish.login
192 Load Task Service Properties Data
193
194
195Suite Teardown Execution
196 [Documentation] Do suite teardown operation.
197
198 Run Keyword And Ignore Error Redfish.Logout
199 Close All Connections
200
201
202Generate Task Instance
203 [Documentation] Trigger Redfish event to generate task instance
204 ... and return the task id.
205 [Arguments] ${task_type}=bmc_dump
206
207 # Description of argument(s):
208 # task_type Default value for task_type is bmc_dump. When 'task_type'
209 # is 'bmc_dump', then keyword will initiate bmc user dump
210 # creation and will return the task id and response object.
211
212 IF '${task_type}' == 'bmc_dump'
213 ${task_id} ${resp}= Create BMC User Dump
214 ELSE
215 Fail Task type "${task_type}" is unknown.
216 END
217
218 Return From Keyword ${task_id} ${resp}
219
220
221Verify Generate Task Instance Completion
222 [Documentation] Trigger Redfish event to generate task and wait until
223 ... task gets completed.
224 [Arguments] ${task_type}=bmc_dump
225
226 # Description of argument(s):
227 # task_type If 'task_type' set as 'bmc_dump', the keyword will
228 # initiate bmc user dump creation and wait until
229 # task is completed. Default value of task_type
230 # is bmc_dump.
231
232 ${task_id} ${resp}= Generate Task Instance ${task_type}
233 Wait For Task Completion ${task_id} ${allowed_task_completion_state}
234
235
236Load Task Service Properties Data
237 [Documentation] Load the task service related properties from json file.
238
George Keishingdd804162023-01-30 05:21:27 -0600239 # User input -v TASK_JSON_FILE_PATH:<path> else default path.
240 ${task_json_file}= Get Variable Value ${TASK_JSON_FILE_PATH} data/task_state.json
241
242 ${json}= OperatingSystem.Get File ${task_json_file}
aravinth0510350edc82022-09-30 06:33:48 +0000243 ${properties}= Evaluate json.loads('''${json}''') json
244
245 Set Suite Variable ${allowed_completed_task_overwrite_policy}
246 ... ${properties["TaskService"]["CompletedTaskOverWritePolicy"]["AllowedValues"]}
247
248 Set Suite Variable ${allowed_task_state}
249 ... ${properties["Task"]["TaskState"]["AllowedValues"]}
250
251 Set Suite Variable ${allowed_task_completion_state}
252 ... ${properties["Task"]["TaskState"]["AllowedCompletionTaskState"]}
253
254 Set Suite Variable ${valid_status}
George Keishingdd804162023-01-30 05:21:27 -0600255 ... ${properties["TaskService"]["Status"]}
George Keishing206f6ed2023-01-30 08:05:45 -0600256
257
258Get Current Date from BMC
259 [Documentation] Runs the date command from BMC and returns current date and time.
260
261 # Get Current Date from BMC
262 ${date} ${stderr} ${rc}= BMC Execute Command date
263
264 # Split the string and remove first and 2nd last value from
265 # the list and join to form %d %b %H:%M:%S %Y date format.
266
267 ${date}= Split String ${date}
268
269 Remove From List ${date} 0
270 Remove From List ${date} -2
271 ${date}= Evaluate " ".join(${date})
272
273 # Convert the date format to %m/%d/%Y %H:%M:%S
274 ${date}= Convert Date ${date} date_format=%b %d %H:%M:%S %Y result_format=%m/%d/%Y %H:%M:%S exclude_millis=True
275
276 [Return] ${date}