chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Module to test IPMI SEL Time functionality. |
George Keishing | 6e64126 | 2022-05-05 10:46:22 -0500 | [diff] [blame] | 4 | ... Pre-requisite Condition : Client Machine and BMC should be in |
| 5 | ... Same TimeZone (example : UST) |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 6 | ... |
George Keishing | 6e64126 | 2022-05-05 10:46:22 -0500 | [diff] [blame] | 7 | ... IPMI Raw command variables are defined under |
| 8 | ... ../data/ipmi_raw_command_table.py |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 9 | ... |
George Keishing | 6e64126 | 2022-05-05 10:46:22 -0500 | [diff] [blame] | 10 | ... Test the Set/Get SEL Time functionality and compare the result against |
| 11 | ... BMC Native command (date). |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 12 | ... |
| 13 | ... Set the Time Sync Mode from NTP to Manual to Set SEL Time. |
| 14 | ... Time Sync Mode change performed via REDFISH URI. |
George Keishing | 6e64126 | 2022-05-05 10:46:22 -0500 | [diff] [blame] | 15 | ... Performs the change in Time Sync Mode with Test Setup and Teardown Execution |
| 16 | ... with default NETWORK_TIMEOUT provided under ../lib/resource.robot. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 17 | ... |
George Keishing | 6e64126 | 2022-05-05 10:46:22 -0500 | [diff] [blame] | 18 | ... NETWORK_RESTART_TIME added for Set SEL Time and Add SEL Entry as the corresponding |
| 19 | ... command takes approx 5 seconds for the operation to reflect. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 20 | ... |
| 21 | ... Current SEL time identified via BMC Native command (date) and perform SEL Time operations. |
| 22 | ... |
| 23 | ... Script Verifies SEL Time for various scenarios such as, |
| 24 | ... Get current time from BMC and add future year and compare against BMC native command (date), |
| 25 | ... Gets BMC Current Time and Adds 15 minutes and compare against BMC native command (date), |
| 26 | ... Gets BMC Current Time and subtracts 1 day and compare against BMC native command (date), |
| 27 | ... Add SEL Entry for all the above scenarios and compare against BMC native command (date). |
| 28 | |
ganesanb | d0c4b80 | 2023-04-28 18:29:38 +0000 | [diff] [blame] | 29 | Resource ../lib/ipmi_client.robot |
| 30 | Resource ../lib/openbmc_ffdc.robot |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 31 | Library DateTime |
| 32 | Library Collections |
| 33 | Library String |
| 34 | Library ../lib/ipmi_utils.py |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 35 | Variables ../data/ipmi_raw_cmd_table.py |
| 36 | |
| 37 | Test Setup Test Setup Execution |
| 38 | Test Teardown Test Teardown Execution |
| 39 | |
Matt Fischer | 6fb70d9 | 2023-10-24 19:06:33 -0600 | [diff] [blame] | 40 | Test Tags IPMI_SEL_Time |
George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 41 | |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 42 | *** Variables *** |
| 43 | |
| 44 | ${NETWORK_RESTART_TIME} 5s |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 45 | @{time_difference_list} +8760:153:25 -87600:453:120 +175200:40:15 -43800:10:05 +20:35:12 -8760:00:00 |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 46 | |
George Keishing | a91601b | 2023-03-21 09:35:49 +0530 | [diff] [blame] | 47 | # Based on 13th byte of add SEL entry command as per IPMI spec |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 48 | # event_dir and event_type variable value needs to be given. |
| 49 | ${sel_no_entry_msg} SEL has no entries |
| 50 | ${event_type} Lower Non-critical going low |
| 51 | ${event_dir} Asserted |
| 52 | # number_of_times_sel_entry_added this variable is used in Verify Multiple Set SEL Time With Multiple Add SEL Entry |
| 53 | # test case. Need to give how many sel should be added with multiple date and time. |
| 54 | ${number_of_times_sel_entry_added} 6 |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 55 | |
| 56 | *** Test Cases *** |
| 57 | |
| 58 | Verify Default Get SEL Time |
| 59 | [Documentation] Verify IPMI Get SEL Time. |
| 60 | [Tags] Verify_Default_Get_SEL_Time |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 61 | |
| 62 | # Gets the current SEL time via Get SEL Time Command. |
| 63 | ${resp}= Get SEL Time Command |
| 64 | Should Not Be Empty ${resp} |
| 65 | |
| 66 | |
George Keishing | 70deec0 | 2022-05-04 14:23:22 -0500 | [diff] [blame] | 67 | Verify Set SEL Time On NTP Mode |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 68 | [Documentation] IPMI Set SEL Time without NTP |
George Keishing | 70deec0 | 2022-05-04 14:23:22 -0500 | [diff] [blame] | 69 | [Tags] Verify_Set_SEL_Time_On_NTP_Mode |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 70 | |
| 71 | # Get current time from BMC and add future year (here, 5years). |
| 72 | ${sel_date}= Get Specific Sel Date 5 |
| 73 | |
| 74 | # Gives Hexa decimal raw command data request with the prefix of 0x. |
| 75 | ${sel_date_raw}= Converting Date to HexaDecimal ${sel_date} |
| 76 | |
| 77 | ${Set_sel_time}= Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][2]}* |
| 78 | ... Run IPMI Command ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw} |
| 79 | Should Contain ${Set_sel_time} ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][1]} |
| 80 | |
| 81 | |
| 82 | Verify SEL Set Time For Specific Time |
| 83 | [Documentation] Verify IPMI Set SEL Time. |
| 84 | [Tags] Verify_SEL_Set_Time_For_Specific_Time |
| 85 | |
| 86 | # Get current time from BMC and add future year (here, 5years). |
| 87 | ${sel_date}= Get Specific Sel Date 5 |
| 88 | |
| 89 | # Gives Hexa decimal raw command data request with the prefix of 0x. |
| 90 | ${sel_date_raw}= Converting Date to HexaDecimal ${sel_date} |
| 91 | |
| 92 | # Set SEL Entry command. |
| 93 | Set SEL Time Entry Via Raw Command ${sel_date_raw} |
| 94 | |
| 95 | # Get SEL Time command. |
| 96 | ${get_sel_time}= Check Current Date Time Via IPMI |
| 97 | |
| 98 | # Identify Time difference and find the difference is less than 6 seconds. |
| 99 | # Command execution may happen at the end of millisecond so considered 6 seconds as difference. |
| 100 | ${time_difference}= Get Time Difference ${get_sel_time} ${sel_date} |
| 101 | Should Be True 0<=${time_difference}<=5 |
| 102 | ... msg=Set SEL Time Not Working |
| 103 | |
| 104 | # Get BMC time (native) and compare with set sel time given. |
| 105 | ${bmc_time}= Get Current Date from BMC |
| 106 | |
| 107 | ${difference}= Get Time Difference ${bmc_time} ${sel_date} |
| 108 | Should Be True 0<=${difference}<=6 |
| 109 | |
| 110 | |
| 111 | Verify Set SEL Time With Future Date And Time |
| 112 | [Documentation] Verify IPMI Get SEL Time by adding 15 minutes from current time. |
| 113 | [Tags] Verify_Set_SEL_Time_With_Future_Date_And_Time |
| 114 | |
| 115 | # Gets BMC Current Time and Adds 15 minutes and sets the SEL Time. |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 116 | ${sel_time} ${set_sel_time}= Identify SEL Time +06:15:00 |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 117 | |
| 118 | # Set SEL Time via IPMI command. |
| 119 | Set SEL Time Via IPMI ${sel_time} |
| 120 | |
| 121 | # Get SEL Time Command. |
| 122 | ${get_sel_time}= Check Current Date Time Via IPMI |
| 123 | |
| 124 | # Difference of time between set sel time and get time. |
| 125 | ${difference}= Get Time Difference ${get_sel_time} ${set_sel_time} |
| 126 | Should Be True 0<=${difference}<=2 |
| 127 | |
| 128 | # Difference of time between BMC Date and Get SEL Time. |
| 129 | ${bmc_time}= Get Current Date from BMC |
Sridevi Ramesh | 52b71f8 | 2025-03-21 04:18:26 -0500 | [diff] [blame] | 130 | ${difference}= Get Time Difference ${bmc_time} ${get_sel_time} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 131 | Should Be True 0<=${difference}<=2 |
| 132 | |
| 133 | |
| 134 | Verify Set SEL Time With Past Date And Time |
| 135 | [Documentation] Verify IPMI Get SEL Time for yime delay of 1 day from current dat and time. |
| 136 | [Tags] Verify_Set_SEL_Time_With_Past_Date_And_Time |
| 137 | |
| 138 | # Gets BMC current time and subtracts 1 day and sets the SEL Time. |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 139 | ${sel_time} ${set_sel_time}= Identify SEL Time -24:00:00 |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 140 | |
| 141 | ${status}= Run Keyword And Return Status Should Not Contain ${sel_time} 1969 |
| 142 | ... msg=Date cannot be less than 1970. |
| 143 | |
| 144 | IF '${status}' == '${TRUE}' |
| 145 | # Set SEL Time via IPMI command. |
| 146 | Set SEL Time Via IPMI ${sel_time} |
| 147 | # Get SEL Time Command. |
| 148 | ${get_sel_time}= Check Current Date Time Via IPMI |
| 149 | # Difference of time between set sel time and get time. |
| 150 | ${difference}= Get Time Difference ${get_sel_time} ${set_sel_time} |
| 151 | Should Be True 0<=${difference}<=2 |
| 152 | # Difference of time between BMC Date and Get SEL Time. |
| 153 | ${bmc_time}= Get Current Date from BMC |
Sridevi Ramesh | 52b71f8 | 2025-03-21 04:18:26 -0500 | [diff] [blame] | 154 | ${difference}= Get Time Difference ${bmc_time} ${get_sel_time} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 155 | Should Be True 0<=${difference}<=2 |
| 156 | ELSE |
| 157 | FAIL SEL Time cannot set Date less than 1970 |
| 158 | END |
| 159 | |
| 160 | |
| 161 | Verify SEL Set Time For Invalid Data Request |
| 162 | [Documentation] Verify IPMI Get SEL Time for invalid data request |
| 163 | [Tags] Verify_SEL_Set_Time_For_Invalid_Data_Request |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 164 | |
| 165 | # Gets BMC current date via date command. |
| 166 | ${current_date}= Get Current Date from BMC |
| 167 | |
| 168 | # Gives hexa decimal Raw command data request with the prefix of 0x. |
| 169 | ${sel_date_raw}= Converting Date to HexaDecimal ${current_date} |
| 170 | |
| 171 | # Set Invalid SEL Time with one extra request byte. |
| 172 | ${Set_seltime_invalid}= Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][4]}* |
| 173 | ... Run IPMI Command ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw} 0x00 |
| 174 | Should Contain ${Set_seltime_invalid} ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][3]} |
| 175 | |
| 176 | |
| 177 | Verify SEL Set Time For Incomplete Data Request |
| 178 | [Documentation] Verify IPMI Get SEL Time for invalid data with one byte less request data. |
| 179 | [Tags] Verify_SEL_Set_Time_For_Incomplete_Data_Request |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 180 | |
| 181 | # Gets BMC current date via date command. |
| 182 | ${current_date}= Get Current Date from BMC |
| 183 | |
| 184 | # Gives hexa decimal raw command data request with the prefix of 0x. |
| 185 | ${sel_date_raw}= Converting Date to HexaDecimal ${current_date} |
| 186 | |
| 187 | # For data request less than expected byes, remove last byte. |
| 188 | ${sel_date_raw}= Split String ${sel_date_raw} |
| 189 | Remove From List ${sel_date_raw} -1 |
| 190 | ${sel_date_raw}= Evaluate " ".join(${sel_date_raw}) |
| 191 | |
| 192 | # Set incomplete SEL Time with one less request byte. |
George Keishing | 6e64126 | 2022-05-05 10:46:22 -0500 | [diff] [blame] | 193 | ${Set_seltime_incomplete}= |
| 194 | ... Run Keyword and Expect Error *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][4]}* |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 195 | ... Run IPMI Command ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw} |
| 196 | Should Contain ${Set_seltime_incomplete} ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][3]} |
| 197 | |
| 198 | |
| 199 | Verify SEL Time In SEL Entry |
| 200 | [Documentation] Verify Configured SEL Time reflects in newly added SEL Entry. |
| 201 | [Tags] Verify_SEL_Time_In_SEL_Entry |
| 202 | |
| 203 | Clear The SEL |
| 204 | |
| 205 | # change to manual, get current time and add future year (here, 5years). |
| 206 | ${sel_date}= Get Specific Sel Date 5 |
| 207 | |
| 208 | # Gives hexa decimal raw command data request with the prefix of 0x. |
| 209 | ${sel_date_raw}= Converting Date to HexaDecimal ${sel_date} |
| 210 | |
| 211 | # Set SEL Entry Command. |
| 212 | Set SEL Time Entry Via Raw Command ${sel_date_raw} |
| 213 | |
| 214 | # Get SEL Time Command. |
| 215 | ${get_sel_time}= Check Current Date Time Via IPMI |
| 216 | |
| 217 | # Identify Time difference and find the difference is less than 6 seconds. |
| 218 | # Command execution may happen at the end of millisecond so considered 6 seconds as difference. |
| 219 | ${time_difference}= Get Time Difference ${get_sel_time} ${sel_date} |
| 220 | Should Be True 0<=${time_difference}<=5 |
| 221 | ... msg=Set SEL Time Not Working |
| 222 | |
| 223 | # Get BMC time (native) and compare with set sel time given. |
| 224 | ${bmc_time}= Get Current Date from BMC |
| 225 | |
| 226 | ${difference}= Get Time Difference ${bmc_time} ${sel_date} |
| 227 | Should Be True 0<=${difference}<=6 |
| 228 | |
| 229 | # Get any Sensor available from Sensor list. |
ganesanb | 02d1966 | 2022-05-24 15:24:23 +0530 | [diff] [blame] | 230 | ${sensor_name}= Fetch One Threshold Sensor From Sensor List |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 231 | |
| 232 | # Get Sensor ID from SDR Get "sensor". |
| 233 | ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 234 | ${sensor_number}= Get Bytes From SDR Sensor ${sensor_data1} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 235 | |
| 236 | # Get Sensor Type from SDR Get "sensor". |
| 237 | ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold) |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 238 | ${sensor_type_id}= Get Bytes From SDR Sensor ${sensor_data2} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 239 | |
| 240 | # Add SEL Entry. |
| 241 | ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number} |
| 242 | |
| 243 | # Finds the last added sel entry. |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 244 | ${resp}= Verify SEL Added ${sensor_name} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 245 | |
| 246 | # Fetches the date of the last added SEL Entry. |
| 247 | ${sel_entry_date}= Fetch Added SEL Date ${resp} |
| 248 | |
| 249 | # Identify and find the time difference is less than 60 seconds. |
| 250 | # Finding the sensor details and execution may take up to a minute. |
| 251 | # Compare date and time of Set SEL with sel entry. |
| 252 | ${d}= Get Time Difference ${sel_entry_date} ${sel_date} |
| 253 | Should Be True 0<=${d}<=60 |
| 254 | |
| 255 | |
| 256 | Verify SEL Time In SEL Entry For Future Date and Time |
| 257 | [Documentation] Verify configured SEL Time (Future Date & Time) in added SEL Entry. |
| 258 | [Tags] Verify_SEL_Time_In_SEL_Entry_For_Future_Date_and_Time |
| 259 | |
| 260 | Clear The SEL |
| 261 | |
| 262 | # Gets BMC Current Time and Adds 15 minutes and sets the SEL Time. |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 263 | ${sel_time} ${set_sel_time}= Identify SEL Time +06:15:00 |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 264 | |
| 265 | # Set SEL Time via IPMI command. |
| 266 | Set SEL Time Via IPMI ${sel_time} |
| 267 | |
| 268 | # Get SEL Time Command. |
| 269 | ${get_sel_time}= Check Current Date Time Via IPMI |
| 270 | |
| 271 | # Difference of time between set sel time and get time. |
| 272 | ${difference}= Get Time Difference ${get_sel_time} ${set_sel_time} |
| 273 | Should Be True 0<=${difference}<=2 |
| 274 | |
| 275 | # Difference of time between BMC Date and Get SEL Time. |
| 276 | ${bmc_time}= Get Current Date from BMC |
Sridevi Ramesh | 52b71f8 | 2025-03-21 04:18:26 -0500 | [diff] [blame] | 277 | ${difference}= Get Time Difference ${bmc_time} ${get_sel_time} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 278 | Should Be True 0<=${difference}<=2 |
| 279 | |
| 280 | # Get any Sensor available from Sensor list. |
ganesanb | 02d1966 | 2022-05-24 15:24:23 +0530 | [diff] [blame] | 281 | ${sensor_name}= Fetch One Threshold Sensor From Sensor List |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 282 | |
| 283 | # Get Sensor ID from SDR Get "sensor". |
| 284 | ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 285 | ${sensor_number}= Get Bytes From SDR Sensor ${sensor_data1} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 286 | |
| 287 | # Get Sensor Type from SDR Get "sensor". |
| 288 | ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold) |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 289 | ${sensor_type_id}= Get Bytes From SDR Sensor ${sensor_data2} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 290 | |
| 291 | # Add SEL Entry. |
| 292 | ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number} |
| 293 | |
| 294 | # Finds the last added sel entry. |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 295 | ${resp}= Verify SEL Added ${sensor_name} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 296 | |
| 297 | # Fetches the date of the last added SEL Entry. |
| 298 | ${sel_entry_date}= Fetch Added SEL Date ${resp} |
| 299 | |
| 300 | # Identify and find the time difference is less than 60 seconds. |
| 301 | # Finding the sensor details and execution may take up to a minute. |
| 302 | # Compare date and time of Set SEL with sel entry. |
| 303 | ${d}= Get Time Difference ${sel_entry_date} ${set_sel_time} |
| 304 | Should Be True 0<=${d}<=60 |
| 305 | |
| 306 | |
| 307 | Verify SEL Time In SEL Entry For Past Date And Time |
| 308 | [Documentation] Verify configured SEL Time (Past Date & Time) in added SEL Entry. |
George Keishing | 70deec0 | 2022-05-04 14:23:22 -0500 | [diff] [blame] | 309 | [Tags] Verify_SEL_Time_In_SEL_Entry_For_Past_Date_And_Time |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 310 | |
| 311 | Clear The SEL |
| 312 | |
| 313 | # Gets BMC Current Time and subtracts 1 day and sets the SEL Time. |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 314 | ${sel_time} ${set_sel_time}= Identify SEL Time -24:00:00 |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 315 | |
| 316 | ${status}= Run Keyword And Return Status Should Not Contain ${sel_time} 1969 |
| 317 | ... msg=Date cannot be less than 1970 |
| 318 | |
| 319 | IF '${status}' == '${TRUE}' |
| 320 | # Set SEL Time via IPMI command. |
| 321 | Set SEL Time Via IPMI ${sel_time} |
| 322 | # Get SEL Time Command. |
| 323 | ${get_sel_time}= Check Current Date Time Via IPMI |
| 324 | # Difference of time between set sel time and get time. |
| 325 | ${difference}= Get Time Difference ${get_sel_time} ${set_sel_time} |
| 326 | Should Be True 0<=${difference}<=2 |
| 327 | # Difference of time between BMC Date and Get SEL Time. |
| 328 | ${bmc_time}= Get Current Date from BMC |
Sridevi Ramesh | 52b71f8 | 2025-03-21 04:18:26 -0500 | [diff] [blame] | 329 | ${difference}= Get Time Difference ${bmc_time} ${get_sel_time} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 330 | Should Be True 0<=${difference}<=2 |
| 331 | |
| 332 | # Get any Sensor available from Sensor list. |
ganesanb | 02d1966 | 2022-05-24 15:24:23 +0530 | [diff] [blame] | 333 | ${sensor_name}= Fetch One Threshold Sensor From Sensor List |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 334 | # Get Sensor ID from SDR Get "sensor". |
| 335 | ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 336 | ${sensor_number}= Get Bytes From SDR Sensor ${sensor_data1} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 337 | |
| 338 | # Get Sensor Type from SDR Get "sensor". |
| 339 | ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold) |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 340 | ${sensor_type_id}= Get Bytes From SDR Sensor ${sensor_data2} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 341 | |
| 342 | # Add SEL Entry. |
| 343 | ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number} |
| 344 | |
| 345 | # Finds the last added sel entry. |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 346 | ${resp}= Verify SEL Added ${sensor_name} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 347 | |
| 348 | # Fetches the date of the last added SEL Entry. |
| 349 | ${sel_entry_date}= Fetch Added SEL Date ${resp} |
| 350 | |
| 351 | # Identify and find the time difference is less than 60 seconds. |
| 352 | # Finding the sensor details and execution may take up to a minute. |
| 353 | # Compare date and time of Set SEL with sel entry. |
| 354 | ${d}= Get Time Difference ${sel_entry_date} ${set_sel_time} |
| 355 | Should Be True 0<=${d}<=60 |
| 356 | ELSE |
| 357 | FAIL SEL Time cannot set Date less than 1970. |
| 358 | END |
| 359 | |
| 360 | |
| 361 | Verify Multiple Set SEL Time With Multiple Add SEL Entry |
| 362 | [Documentation] Verify SEL time in multiple addition Of SEL entry. |
| 363 | [Tags] Verify_Multiple_Set_SEL_Time_With_Multiple_Add_SEL_Entry |
| 364 | |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 365 | FOR ${i} IN RANGE ${number_of_times_sel_entry_added} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 366 | |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 367 | ${sel_time} ${set_sel_time}= Identify SEL Time ${time_difference_list[${i}]} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 368 | |
| 369 | # Set SEL Time via IPMI command. |
| 370 | Set SEL Time Via IPMI ${sel_time} |
| 371 | |
| 372 | # Clear the SEL. |
| 373 | Clear The SEL |
| 374 | |
| 375 | # Get any Sensor available from Sensor list. |
ganesanb | 02d1966 | 2022-05-24 15:24:23 +0530 | [diff] [blame] | 376 | ${sensor_name}= Fetch One Threshold Sensor From Sensor List |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 377 | |
| 378 | # Get Sensor ID from SDR Get "sensor" and Identify Sensor ID. |
| 379 | ${sensor_data1}= Fetch Sensor Details From SDR ${sensor_name} Sensor ID |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 380 | ${sensor_number}= Get Bytes From SDR Sensor ${sensor_data1} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 381 | |
| 382 | # Get Sensor Type from SDR Get "sensor" and identify Sensor Type. |
| 383 | ${sensor_data2}= Fetch Sensor Details From SDR ${sensor_name} Sensor Type (Threshold) |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 384 | ${sensor_type_id}= Get Bytes From SDR Sensor ${sensor_data2} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 385 | |
| 386 | # Add SEL Entry. |
| 387 | ${sel_create_resp}= Create SEL ${sensor_type_id} ${sensor_number} |
| 388 | |
| 389 | # Finds the last added sel entry. |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 390 | ${resp}= Verify SEL Added ${sensor_name} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 391 | |
| 392 | # Fetches the date of the last added SEL Entry. |
| 393 | ${sel_entry_date}= Fetch Added SEL Date ${resp} |
| 394 | |
| 395 | # Identify and find the time difference is less than 60 seconds. |
| 396 | # Finding the sensor details and execution may take up to a minute. |
| 397 | # Compare date and time of Set SEL with sel entry. |
| 398 | ${d}= Get Time Difference ${sel_entry_date} ${set_sel_time} |
| 399 | Should Be True ${d}<=60 |
| 400 | |
| 401 | END |
| 402 | |
| 403 | |
| 404 | *** Keywords *** |
| 405 | |
| 406 | Time Sync Mode Change Through Redfish |
| 407 | [Documentation] Export IP, token and change the time sync to manual. |
| 408 | [Arguments] ${value} |
| 409 | |
| 410 | # Description of argument(s): |
George Keishing | 6d15bf1 | 2022-05-06 11:50:44 -0500 | [diff] [blame] | 411 | # ${value} Can be either ${FALSE} or ${TRUE}. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 412 | |
| 413 | # May be changed to WebView. |
| 414 | |
| 415 | # Changing Time Sync Mode to Manual. |
| 416 | Change Time Sync Mode Via Redfish ${value} |
| 417 | |
| 418 | |
| 419 | Change Time Sync Mode Via Redfish |
| 420 | [Documentation] To change the time sync mode via Redfish. |
| 421 | [Arguments] ${value} |
| 422 | |
| 423 | # Description of argument(s): |
George Keishing | 6d15bf1 | 2022-05-06 11:50:44 -0500 | [diff] [blame] | 424 | # ${value} Can be either ${FALSE} or ${TRUE} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 425 | |
| 426 | # Creates request body for Redfish url. |
| 427 | ${mode}= Create Dictionary ProtocolEnabled=${value} |
| 428 | ${data}= Create Dictionary NTP=${mode} |
| 429 | |
| 430 | # Patches the obtained body to the given url. |
| 431 | Redfish.patch ${REDFISH_NW_PROTOCOL_URI} body=&{data} |
| 432 | ... valid_status_codes=[${HTTP_NO_CONTENT}] |
| 433 | |
| 434 | Sleep ${NETWORK_RESTART_TIME} |
| 435 | |
| 436 | |
| 437 | Get SEL Time Command |
| 438 | [Documentation] Get SEL Time command. |
| 439 | |
| 440 | # The response will be 8 byte timestamp in hexadecimal. |
| 441 | # example: If current date and time is "Wed May 4 18:55:00 UTC 2022", |
| 442 | # then, ${get_sel_time} will be "07 cc 72 62". |
| 443 | ${get_sel_time}= Run IPMI Command |
| 444 | ... ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Time'][0]} |
| 445 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 446 | RETURN ${get_sel_time} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 447 | |
| 448 | |
| 449 | Set SEL Time Entry Via Raw Command |
| 450 | [Documentation] Set SEL Time command. |
| 451 | [Arguments] ${sel_date_raw} |
| 452 | |
| 453 | # Description of argument(s): |
George Keishing | 6d15bf1 | 2022-05-06 11:50:44 -0500 | [diff] [blame] | 454 | # ${sel_date_raw} Time to set in hexadecimal bytes. |
| 455 | # Example: |
| 456 | # If date is 1st January 2022 12:30:00 PM, |
| 457 | # the hexadecimal timestamp is, 61D04948. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 458 | # then the request bytes are, |
| 459 | # ${sel_date_raw} 0x48 0x49 0xd0 0x61 |
| 460 | |
| 461 | Run IPMI Command ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw} |
| 462 | Sleep ${NETWORK_RESTART_TIME} |
| 463 | |
| 464 | |
| 465 | Clear The SEL |
| 466 | [Documentation] Clear SEL Command. |
| 467 | |
| 468 | # Clear the SEL. |
| 469 | ${out}= Run IPMI Standard Command sel clear |
| 470 | Should Contain ${out} Clearing SEL |
| 471 | Sleep 2s |
| 472 | |
| 473 | |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 474 | Verify SEL Added |
| 475 | [Documentation] Verify Added SEL. |
| 476 | [Arguments] ${sensor_name} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 477 | |
| 478 | # Description of argument(s): |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 479 | # sensor_name Name of the sensor. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 480 | |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 481 | ${resp}= Run IPMI Standard Command sel elist |
| 482 | Should Not Contain ${resp} ${sel_no_entry_msg} |
| 483 | ${get_sel_entry}= Get Lines Containing String ${resp} ${sensor_name} |
| 484 | ${sel_entry}= Get Lines Containing String ${get_sel_entry} ${event_type} |
| 485 | Should Contain ${sel_entry} ${event_dir} msg=Add SEL Entry failed. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 486 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 487 | RETURN ${sel_entry} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 488 | |
| 489 | |
| 490 | Check Current Date Time Via IPMI |
| 491 | [Documentation] Verify Current Date and Time Via IPMI user command. |
| 492 | |
| 493 | ${resp}= Run IPMI Standard Command sel time get |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 494 | RETURN ${resp} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 495 | |
| 496 | |
| 497 | Get Specific Sel Date |
| 498 | [Documentation] Gets initial time and adds year to the current date and returns future date. |
| 499 | [Arguments] ${year} |
| 500 | |
| 501 | # Description of argument(s): |
George Keishing | 6d15bf1 | 2022-05-06 11:50:44 -0500 | [diff] [blame] | 502 | # ${year} Can be any number of years (say 5 year). |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 503 | |
| 504 | ${current_date}= Get Current Date from BMC |
| 505 | |
| 506 | # Converting given years to days by multiplying with 365days and adding the days to current date. |
| 507 | ${days}= Evaluate 365*${year}+1 |
George Keishing | 6d15bf1 | 2022-05-06 11:50:44 -0500 | [diff] [blame] | 508 | ${date}= Add Time To Date |
| 509 | ... ${current_date} ${days}d result_format=%m/%d/%Y %H:%M:%S date_format=%m/%d/%Y %H:%M:%S |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 510 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 511 | RETURN ${date} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 512 | |
| 513 | |
| 514 | Converting Date to HexaDecimal |
| 515 | [Documentation] Converting the date into hexa decimal values. |
| 516 | [Arguments] ${date} |
| 517 | |
| 518 | # Description of argument(s): |
George Keishing | 6d15bf1 | 2022-05-06 11:50:44 -0500 | [diff] [blame] | 519 | # ${date} Can be any date in format %m/%d/%Y %H:%M:%S. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 520 | |
| 521 | ${epoch_date}= Convert Date ${date} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S |
| 522 | ${date}= Convert To Hex ${epoch_date} lowercase=yes |
| 523 | |
| 524 | # function calls from utils.py. |
| 525 | # Length of the date byte should be 8 so that each bytes are separated. |
| 526 | ${date}= Zfill Data ${date} 8 |
| 527 | # To split every two characters to form one byte each. |
| 528 | ${date}= Split String With Index ${date} 2 |
| 529 | # Prefix every list index value with 0x. |
| 530 | ${date}= Prefix Bytes ${date} |
| 531 | |
| 532 | # Reverse the bytes and join the list to form request Time stamp data. |
| 533 | Reverse List ${date} |
| 534 | ${date}= Evaluate " ".join(${date}) |
| 535 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 536 | RETURN ${date} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 537 | |
| 538 | |
| 539 | Get Time Difference |
| 540 | [Documentation] Converting the date into hexa decimal values. |
| 541 | [Arguments] ${date1} ${date2} |
| 542 | |
| 543 | # Description of argument(s): |
George Keishing | 6d15bf1 | 2022-05-06 11:50:44 -0500 | [diff] [blame] | 544 | # ${date1} Can be any date in format %m/%d/%Y %H:%M:%S. |
| 545 | # ${date2} Can be any date in format %m/%d/%Y %H:%M:%S. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 546 | |
| 547 | ${epoch_date1}= Convert Date ${date1} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S |
| 548 | ${epoch_date2}= Convert Date ${date2} epoch exclude_millis=yes date_format=%m/%d/%Y %H:%M:%S |
| 549 | |
| 550 | ${diff}= Evaluate int(${epoch_date1}) - int(${epoch_date2}) |
| 551 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 552 | RETURN ${diff} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 553 | |
| 554 | |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 555 | Identify SEL Time |
| 556 | [Documentation] Modify SEL Time From BMC For Set Sel Time Command. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 557 | [Arguments] ${time} |
| 558 | |
| 559 | # Description of argument(s): |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 560 | # time Can be any number of hours or minutes in format %H:%M:%S. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 561 | |
| 562 | # Gets BMC current date via date command. |
| 563 | ${current_date}= Get Current Date from BMC |
| 564 | |
ganesanb | 11fe27f | 2022-08-24 10:00:17 +0000 | [diff] [blame] | 565 | ${modifying_date_status}= Run Keyword And Return Status Should Contain ${time} + |
| 566 | |
| 567 | ${date_time}= Set Variable IF |
| 568 | ... ${modifying_date_status} == True ${time.split("+")[-1]} |
| 569 | ... ${modifying_date_status} == False ${time.split("-")[-1]} |
| 570 | |
| 571 | ${datetime} = Run Keyword IF ${modifying_date_status} == True |
| 572 | ... Add Time To Date |
| 573 | ... ${current_date} ${date_time} result_format=%m/%d/%Y %H:%M:%S date_format=%m/%d/%Y %H:%M:%S |
| 574 | ... ELSE IF ${modifying_date_status} == False |
| 575 | ... Subtract Time From Date |
| 576 | ... ${current_date} ${date_time} result_format=%m/%d/%Y %H:%M:%S date_format=%m/%d/%Y %H:%M:%S |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 577 | |
| 578 | #Set SEL Time. |
| 579 | ${quoted_date}= Fetch Date ${datetime} |
| 580 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 581 | RETURN ${quoted_date} ${datetime} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 582 | |
| 583 | |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 584 | Set SEL Time Via IPMI |
| 585 | [Documentation] Set SEL Time for given date using IPMI. |
| 586 | [Arguments] ${date_time} |
| 587 | |
| 588 | # Description of argument(s): |
George Keishing | 6d15bf1 | 2022-05-06 11:50:44 -0500 | [diff] [blame] | 589 | # ${date_time} Can be any date in format %m/%d/%Y %H:%M:%S. |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 590 | |
| 591 | ${resp}= Run IPMI Standard Command sel time set "${date_time}" |
| 592 | Should Not Contain ${resp} Unspecified error |
| 593 | |
| 594 | |
| 595 | Test Setup Execution |
| 596 | [Documentation] Test Setup Execution. |
| 597 | |
| 598 | Redfish.Login |
| 599 | # Change timesync mode to manual with timeout as per resource.robot. |
| 600 | Time Sync Mode Change Through Redfish ${FALSE} |
| 601 | Sleep ${NETWORK_TIMEOUT} |
Sridevi Ramesh | 52b71f8 | 2025-03-21 04:18:26 -0500 | [diff] [blame] | 602 | Printn |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 603 | |
| 604 | |
| 605 | Test Teardown Execution |
| 606 | [Documentation] For execution of Test teardown. |
| 607 | |
| 608 | Clear The SEL |
| 609 | |
| 610 | # Change TimeSync mode to NTP with Timeout as per default resource.robot. |
| 611 | Time Sync Mode Change Through Redfish ${TRUE} |
| 612 | Sleep ${NETWORK_TIMEOUT} |
| 613 | Redfish.Logout |
| 614 | FFDC On Test Case Fail |