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