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