blob: fa9a6b582812e2cd5646d30ddffd4a14424cf4a8 [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
136 ${time_diff}= Evaluate ${time_diff} < 10
137 Should Be Equal ${time_diff} ${TRUE} Time difference greater than 10 seconds.
138
139 # Verify HttpOperation in task payload.
140 Should Be Equal ${resp["Payload"]["HttpOperation"]} POST
141
142 # Verify TargetUri.
143 Should Be Equal ${resp["Payload"]["TargetUri"]}
144 ... ${resp_obj.request.path}
145
146 Wait For Task Completion ${task_id} ${allowed_task_completion_state}
147 ... check_state=${TRUE}
148
149 # Verify task monitor URI after task completion.
150 ${resp}= Redfish.Get /redfish/v1/TaskService/Tasks/${task_id}/Monitor
151 ... valid_status_codes=[${HTTP_NOT_FOUND}]
152
153 # Verify end time is greater than start time post task completion.
154 ${resp}= Redfish.Get Properties /redfish/v1/TaskService/Tasks/${task_id}
155
156 ${end_time}= Get Regexp Matches ${resp["EndTime"]}
157 ... ${TIME_REGEXP_PATTERN} 1
158
159 # Compare start time and end time displayed in task service URI.
160 ${time_diff}= Subtract Date From Date ${end_time[0]} ${start_time[0]}
161
162 ${time_diff}= Evaluate ${time_diff} >= 0
163
164 Should Be Equal ${time_diff} ${TRUE}
165 ... End time not greater than start time.
166
167
168Verify Task Persistency Post BMC Reboot
169 [Documentation] Verify task collection persistency post BMC reboot.
170 [Tags] Verify_Task_Persistency_Post_BMC_Reboot
171
172 Verify Generate Task Instance Completion
173
174 ${initial_task_count}= Redfish.Get Attribute /redfish/v1/TaskService/Tasks
175 ... Members@odata.count
176
177 Redfish BMC Reset Operation reset_type=ForceRestart
178
179 ${current_task_count}= Redfish.Get Attribute /redfish/v1/TaskService/Tasks
180 ... Members@odata.count
181
182 Should Be Equal As Integers ${initial_task_count} ${current_task_count}
183
184
185*** Keywords ***
186
187Suite Setup Execution
188 [Documentation] Do suite setup operation.
189
190 Redfish.login
191 Load Task Service Properties Data
192
193
194Suite Teardown Execution
195 [Documentation] Do suite teardown operation.
196
197 Run Keyword And Ignore Error Redfish.Logout
198 Close All Connections
199
200
201Generate Task Instance
202 [Documentation] Trigger Redfish event to generate task instance
203 ... and return the task id.
204 [Arguments] ${task_type}=bmc_dump
205
206 # Description of argument(s):
207 # task_type Default value for task_type is bmc_dump. When 'task_type'
208 # is 'bmc_dump', then keyword will initiate bmc user dump
209 # creation and will return the task id and response object.
210
211 IF '${task_type}' == 'bmc_dump'
212 ${task_id} ${resp}= Create BMC User Dump
213 ELSE
214 Fail Task type "${task_type}" is unknown.
215 END
216
217 Return From Keyword ${task_id} ${resp}
218
219
220Verify Generate Task Instance Completion
221 [Documentation] Trigger Redfish event to generate task and wait until
222 ... task gets completed.
223 [Arguments] ${task_type}=bmc_dump
224
225 # Description of argument(s):
226 # task_type If 'task_type' set as 'bmc_dump', the keyword will
227 # initiate bmc user dump creation and wait until
228 # task is completed. Default value of task_type
229 # is bmc_dump.
230
231 ${task_id} ${resp}= Generate Task Instance ${task_type}
232 Wait For Task Completion ${task_id} ${allowed_task_completion_state}
233
234
235Load Task Service Properties Data
236 [Documentation] Load the task service related properties from json file.
237
George Keishingdd804162023-01-30 05:21:27 -0600238 # User input -v TASK_JSON_FILE_PATH:<path> else default path.
239 ${task_json_file}= Get Variable Value ${TASK_JSON_FILE_PATH} data/task_state.json
240
241 ${json}= OperatingSystem.Get File ${task_json_file}
aravinth0510350edc82022-09-30 06:33:48 +0000242 ${properties}= Evaluate json.loads('''${json}''') json
243
244 Set Suite Variable ${allowed_completed_task_overwrite_policy}
245 ... ${properties["TaskService"]["CompletedTaskOverWritePolicy"]["AllowedValues"]}
246
247 Set Suite Variable ${allowed_task_state}
248 ... ${properties["Task"]["TaskState"]["AllowedValues"]}
249
250 Set Suite Variable ${allowed_task_completion_state}
251 ... ${properties["Task"]["TaskState"]["AllowedCompletionTaskState"]}
252
253 Set Suite Variable ${valid_status}
George Keishingdd804162023-01-30 05:21:27 -0600254 ... ${properties["TaskService"]["Status"]}