Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite is for testing System time in Open BMC. |
| 3 | |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 4 | Resource ../lib/rest_client.robot |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 5 | Resource ../lib/ipmi_client.robot |
George Keishing | d55a4be | 2016-08-26 03:28:17 -0500 | [diff] [blame] | 6 | Resource ../lib/openbmc_ffdc.robot |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 7 | Resource ../lib/resource.txt |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 8 | |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 9 | Library OperatingSystem |
| 10 | Library DateTime |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 11 | |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 12 | Suite Setup Open Connection And Log In |
| 13 | Suite Teardown Close All Connections |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 14 | Test Teardown Post Test Execution |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 15 | |
| 16 | *** Variables *** |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 17 | ${SYSTEM_TIME_INVALID} 01/01/1969 00:00:00 |
| 18 | ${SYSTEM_TIME_VALID} 02/29/2016 09:10:00 |
| 19 | ${SYSTEM_TIME_VALID_EPOCH} 1456737000 #Equivalent epoch time for 02/29/2016 09:10:00 |
| 20 | ${ALLOWED_TIME_DIFF} 3 |
| 21 | ${SETTING_HOST} ${SETTINGS_URI}host0 |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 22 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 23 | *** Test Cases *** |
| 24 | |
| 25 | Get System Time |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 26 | [Documentation] Get system time using IPMI and verify that it matches |
| 27 | ... with BMC date time. |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 28 | [Tags] Get_System_Time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 29 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 30 | ${resp}= Run IPMI Standard Command sel time get |
| 31 | ${ipmidate}= Convert Date ${resp} date_format=%m/%d/%Y %H:%M:%S |
| 32 | ... exclude_millis=yes |
| 33 | ${bmcdate}= Get BMC Time Using IPMI |
| 34 | ${diff}= Subtract Date From Date ${bmcdate} ${ipmidate} |
| 35 | Should Be True ${diff} < ${ALLOWED_TIME_DIFF} |
| 36 | ... Open BMC time does not match with IPMI sel time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 37 | |
| 38 | Set Valid System Time |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 39 | [Documentation] Set system time using IPMI and verify that it is |
| 40 | ... correctly set in BMC. |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 41 | [Tags] Set_Valid_System_Time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 42 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 43 | ${resp}= Run IPMI Standard Command sel time set "${SYSTEM_TIME_VALID}" |
| 44 | ${setdate}= Convert Date ${SYSTEM_TIME_VALID} |
| 45 | ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes |
| 46 | ${bmcdate}= Get BMC Time Using IPMI |
| 47 | ${diff}= Subtract Date From Date ${bmcdate} ${setdate} |
| 48 | Should Be True ${diff} < ${ALLOWED_TIME_DIFF} |
| 49 | ... Open BMC time does not match with set time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 50 | |
| 51 | Set Invalid System Time |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 52 | [Documentation] Set system time with invalid time using IPMI and verify |
| 53 | ... that it should throw error. |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 54 | [Tags] Set_Invalid_System_Time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 55 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 56 | ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command |
| 57 | ... sel time set "${SYSTEM_TIME_INVALID}" |
| 58 | Should Start With ${msg} Specified time could not be parsed |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 59 | |
| 60 | Set System Time with no time |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 61 | [Documentation] Set system time with no time using IPMI and verify |
| 62 | ... that it should throw error. |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 63 | [Tags] Set_System_Time_with_no_time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 64 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 65 | ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command |
| 66 | ... sel time set "" |
| 67 | Should Start With ${msg} Specified time could not be parsed |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 68 | |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 69 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 70 | Set BMC Time With BMC And Manual |
| 71 | #Operation Owner Mode Status BMC Time Host Time |
| 72 | Set BMC Time BMC MANUAL ok Set Change |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 73 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 74 | [Documentation] Set BMC time when time owner is BMC and time mode is |
| 75 | ... manual. |
| 76 | [Tags] Set_BMC_Time_With_BMC_And_Manual |
| 77 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 78 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 79 | Set BMC Time With Both And Manual |
| 80 | #Operation Owner Mode Status BMC Time Host Time |
| 81 | Set BMC Time BOTH MANUAL ok Set Change |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 82 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 83 | [Documentation] Set BMC time when time owner is Both and time mode is |
| 84 | ... manual. |
| 85 | [Tags] Set_BMC_Time_With_Both_And_Manual |
| 86 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 87 | |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 88 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 89 | Set BMC Time With Split And Manual |
| 90 | #Operation Owner Mode Status BMC Time Host Time |
| 91 | Set BMC Time SPLIT MANUAL ok Set No Change |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 92 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 93 | [Documentation] Set BMC time when time owner is Split and time mode is |
| 94 | ... manual. |
| 95 | [Tags] Set_BMC_Time_With_Split_And_Manual |
| 96 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 97 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 98 | Set BMC Time With BMC And NTP |
| 99 | #Operation Owner Mode Status BMC Time Host Time |
| 100 | Set BMC Time BMC NTP error Not Set No Change |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 101 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 102 | [Documentation] Set BMC time when time owner is BMC and time mode is |
| 103 | ... NTP. |
| 104 | [Tags] Set_BMC_Time_With_BMC_And_NTP |
| 105 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 106 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 107 | Set BMC Time With Host And Manual |
| 108 | #Operation Owner Mode Status BMC Time Host Time |
| 109 | Set BMC Time HOST MANUAL error Not Set No Change |
| 110 | [Documentation] Set BMC time when time owner is Host and time mode is |
| 111 | ... Manual. |
| 112 | [Tags] Set_BMC_Time_With_Host_And_Manual |
| 113 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 114 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 115 | Set BMC Time With Both And NTP |
| 116 | #Operation Owner Mode Status BMC Time Host Time |
| 117 | Set BMC Time BOTH NTP error Not Set No Change |
| 118 | |
| 119 | [Documentation] Set BMC time when time owner is Both and time mode is |
| 120 | ... NTP. |
| 121 | [Tags] Set_BMC_Time_With_Both_And_NTP |
| 122 | [Template] Set Time Using REST |
| 123 | |
| 124 | Set BMC Time With Split And NTP |
| 125 | #Operation Owner Mode Status BMC Time Host Time |
| 126 | Set BMC Time SPLIT NTP error Not Set No Change |
| 127 | |
| 128 | [Documentation] Set BMC time when time owner is Split and time mode is |
| 129 | ... NTP. |
| 130 | [Tags] Set_BMC_Time_With_Split_And_NTP |
| 131 | [Template] Set Time Using REST |
| 132 | |
| 133 | Set Host Time With Host And Manual |
| 134 | #Operation Owner Mode Status BMC Time Host Time |
| 135 | Set Host Time HOST MANUAL ok Change Set |
| 136 | |
| 137 | [Documentation] Set host time when time owner is host and time mode is |
| 138 | ... manual. |
| 139 | [Tags] Set_Host_Time_With_Host_And_Manual |
| 140 | [Template] Set Time Using REST |
| 141 | |
| 142 | Set Host Time With Both And Manual |
| 143 | #Operation Owner Mode Status BMC Time Host Time |
| 144 | Set Host Time BOTH MANUAL ok Change Set |
| 145 | |
| 146 | [Documentation] Set host time when time owner is both and time mode is |
| 147 | ... manual. |
| 148 | [Tags] Set_Host_Time_With_Both_And_Manual |
| 149 | [Template] Set Time Using REST |
| 150 | |
| 151 | Set Host Time With Both And NTP |
| 152 | #Operation Owner Mode Status BMC Time Host Time |
| 153 | Set Host Time BOTH NTP ok No Change Set |
| 154 | |
| 155 | [Documentation] Set host time when time owner is both and time mode is |
| 156 | ... NTP. |
| 157 | [Tags] Set_Host_Time_With_Both_And_NTP |
| 158 | [Template] Set Time Using REST |
| 159 | |
| 160 | Set Host Time With Split And Manual |
| 161 | #Operation Owner Mode Status BMC Time Host Time |
| 162 | Set Host Time SPLIT MANUAL ok No Change Set |
| 163 | |
| 164 | [Documentation] Set host time when time owner is split and time mode is |
| 165 | ... manual. |
| 166 | [Tags] Set_Host_Time_With_Split_And_Manual |
| 167 | [Template] Set Time Using REST |
| 168 | |
| 169 | Set Host Time With Split And NTP |
| 170 | #Operation Owner Mode Status BMC Time HOST Time |
| 171 | Set Host Time SPLIT NTP ok No Change Set |
| 172 | |
| 173 | [Documentation] Set host time when time owner is split and time mode is |
| 174 | ... NTP. |
| 175 | [Tags] Set_Host_Time_With_Split_And_NTP |
| 176 | [Template] Set Time Using REST |
| 177 | |
| 178 | Set Host Time With BMC And Manual |
| 179 | #Operation Owner Mode Status BMC Time HOST Time |
| 180 | Set Host Time BMC MANUAL error No Change Not Set |
| 181 | [Documentation] Set host time when time owner is BMC and time mode is |
| 182 | ... Manual. |
| 183 | [Tags] Set_Host_Time_With_BMC_And_Manual |
| 184 | [Template] Set Time Using REST |
| 185 | |
| 186 | Set Host Time With BMC Owner NTP |
| 187 | #Operation Owner Mode Status BMC Time HOST Time |
| 188 | Set Host Time BMC NTP error No Change Not Set |
| 189 | [Documentation] Set host time when time owner is BMC and time mode is |
| 190 | ... NTP. |
| 191 | [Tags] Set_Host_Time_With_BMC_And_NTP |
| 192 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 193 | |
| 194 | Set Invalid Time Mode |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 195 | [Documentation] Set time mode with invalid value using REST and verify |
| 196 | ... that it should throw error. |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 197 | [Tags] Set_Invalid_Time_Mode |
| 198 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 199 | ${timemode}= Set Variable abc |
| 200 | ${valueDict}= Create Dictionary data=${timemode} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 201 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 202 | ${resp}= OpenBMC Put Request |
| 203 | ... ${SETTING_HOST}/attr/time_mode data=${valueDict} |
| 204 | ${jsondata}= to JSON ${resp.content} |
| 205 | Should Be Equal ${jsondata['status']} error |
| 206 | |
| 207 | ${mode}= Read Attribute ${SETTING_HOST} time_mode |
| 208 | Should Not Be Equal ${mode} abc |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 209 | |
| 210 | Set Invalid Time Owner |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 211 | [Documentation] Set time owner with invalid value using REST and verify |
| 212 | ... that it should throw error. |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 213 | [Tags] Set_Invalid_Time_Owner |
| 214 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 215 | ${timeowner}= Set Variable xyz |
| 216 | ${valueDict}= Create Dictionary data=${timeowner} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 217 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 218 | ${resp}= OpenBMC Put Request |
| 219 | ... ${SETTING_HOST}/attr/time_owner data=${valueDict} |
| 220 | ${jsondata}= to JSON ${resp.content} |
| 221 | Should Be Equal ${jsondata['status']} error |
| 222 | |
| 223 | ${owner}= Read Attribute ${SETTING_HOST} time_owner |
| 224 | Should Not Be Equal ${owner} xyz |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 225 | |
| 226 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 227 | *** Keywords *** |
| 228 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 229 | Get BMC Time Using IPMI |
| 230 | [Documentation] Returns BMC time of the system via IPMI |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 231 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 232 | ${stdout} ${stderr} ${output}= |
| 233 | ... Execute Command date "+%m/%d/%Y %H:%M:%S" |
| 234 | ... return_stdout=True return_stderr= True return_rc=True |
| 235 | Should Be Equal ${output} ${0} msg=${stderr} |
| 236 | |
| 237 | ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S |
| 238 | ... exclude_millis=yes |
| 239 | Should Not Be Empty ${resp} |
| 240 | [Return] ${resp} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 241 | |
| 242 | Set Time Owner |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 243 | [Arguments] ${args} |
| 244 | [Documentation] Set time owner of the system via REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 245 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 246 | ${timeowner}= Set Variable ${args} |
| 247 | ${valueDict}= Create Dictionary data=${timeowner} |
| 248 | |
| 249 | ${resp}= OpenBMC Put Request |
| 250 | ... ${SETTING_HOST}/attr/time_owner data=${valueDict} |
| 251 | ${jsondata}= to JSON ${resp.content} |
| 252 | |
| 253 | @{states}= Create List BMC_READY HOST_POWERED_OFF |
| 254 | ${bmc_state}= Get BMC State |
| 255 | |
| 256 | Run Keyword If '${bmc_state}' in ${states} |
| 257 | ... Log System is in off state so owner change will get applied. |
| 258 | ... ELSE Run keyword |
| 259 | ... Initiate Power Off |
| 260 | |
| 261 | ${owner}= Read Attribute ${SETTING_HOST} time_owner |
| 262 | Should Be Equal ${owner} ${args} |
| 263 | |
| 264 | ${current_mode}= |
| 265 | ... Read Attribute ${TIME_MANAGER_URI.rstrip("/")} curr_time_owner |
| 266 | Should Be Equal ${current_mode} ${args} |
| 267 | |
| 268 | [Return] ${jsondata['status']} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 269 | |
| 270 | Set Time Mode |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 271 | [Arguments] ${args} |
| 272 | [Documentation] Set time mode of the system via REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 273 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 274 | ${timemode}= Set Variable ${args} |
| 275 | ${valueDict}= Create Dictionary data=${timemode} |
| 276 | |
| 277 | ${resp}= OpenBMC Put Request |
| 278 | ... ${SETTING_HOST}/attr/time_mode data=${valueDict} |
| 279 | ${jsondata}= to JSON ${resp.content} |
| 280 | Sleep 5s |
| 281 | |
| 282 | ${mode}= Read Attribute ${SETTING_HOST} time_mode |
| 283 | Should Be Equal ${mode} ${args} |
| 284 | |
| 285 | ${current_mode}= |
| 286 | ... Read Attribute ${TIME_MANAGER_URI.rstrip("/")} curr_time_mode |
| 287 | Should Be Equal ${current_mode} ${args} |
| 288 | |
| 289 | Get BMC Time Using REST |
| 290 | [Documentation] Returns BMC time of the system via REST |
| 291 | ... Time Format : YYYY-MM-DD hh:mm:ss.mil |
| 292 | ... eg. 2016-12-14 07:09:58.000 |
| 293 | |
| 294 | @{time_owner}= Create List BMC |
| 295 | ${data}= Create Dictionary data=@{time_owner} |
| 296 | ${resp}= OpenBMC Post Request |
| 297 | ... ${TIME_MANAGER_URI}action/GetTime data=${data} |
| 298 | ${jsondata}= To JSON ${resp.content} |
| 299 | ${time_epoch}= Get From List ${jsondata["data"]} 0 |
| 300 | ${resp}= Convert Date |
| 301 | ... ${time_epoch} date_format=%a %b %d %H:%M:%S %Y %Z |
| 302 | [Return] ${resp} |
| 303 | |
| 304 | Get HOST Time Using REST |
| 305 | [Documentation] Returns HOST time of the system via REST |
| 306 | ... Time Format : YYYY-MM-DD hh:mm:ss.mil |
| 307 | ... eg. 2016-12-14 07:09:58.000 |
| 308 | |
| 309 | @{time_owner}= Create List HOST |
| 310 | ${data}= Create Dictionary data=@{time_owner} |
| 311 | ${resp}= OpenBMC Post Request |
| 312 | ... ${TIME_MANAGER_URI}action/GetTime data=${data} |
| 313 | ${jsondata}= To JSON ${resp.content} |
| 314 | ${time_epoch}= Get From List ${jsondata["data"]} 0 |
| 315 | ${resp}= Convert Date |
| 316 | ... ${time_epoch} date_format=%a %b %d %H:%M:%S %Y %Z |
| 317 | [Return] ${resp} |
| 318 | |
| 319 | Set Time Using REST |
| 320 | [Arguments] ${operation} ${owner} ${mode} ${status} ${bmc_time} |
| 321 | ... ${host_time} |
| 322 | [Documentation] Set BMC or Host time on system via REST. |
| 323 | ... Description of arguments: |
| 324 | ... operation : Set BMC/Host time |
| 325 | ... owner: Time owner |
| 326 | ... mode: Time mode |
| 327 | ... status: Expected status of set BMC time URI |
| 328 | ... bmc_time: Status of BMC time after operation |
| 329 | ... host_time: Status of HOST time after operation |
| 330 | ... Set - Given time is set |
| 331 | ... Not Set - Given time is not set |
| 332 | ... Change - time is change |
| 333 | ... No Change - time is not change |
| 334 | |
| 335 | Set Time Owner ${owner} |
| 336 | Set Time Mode ${mode} |
| 337 | |
| 338 | ${setdate}= Convert Date ${SYSTEM_TIME_VALID} |
| 339 | ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes |
| 340 | |
| 341 | @{bmc_date_list}= Create List BMC ${setdate} |
| 342 | @{host_date_list}= Create List HOST ${SYSTEM_TIME_VALID_EPOCH} |
| 343 | |
| 344 | ${time_owner_date}= Set Variable If |
| 345 | ... '${operation}' == 'Set BMC Time' ${bmc_date_list} |
| 346 | ... '${operation}' == 'Set Host Time' ${host_date_list} |
| 347 | |
| 348 | ${old_bmc_time}= Get BMC Time Using REST |
| 349 | ${old_host_time}= Get HOST Time Using REST |
| 350 | |
| 351 | ${data}= Create Dictionary data=${time_owner_date} |
| 352 | ${resp}= OpenBMC Post Request |
| 353 | ... ${TIME_MANAGER_URI}action/SetTime data=${data} |
| 354 | ${jsondata}= To JSON ${resp.content} |
| 355 | Should Be Equal As Strings ${jsondata['status']} ${status} |
| 356 | |
| 357 | ${new_bmc_time}= Get BMC Time Using REST |
| 358 | ${new_host_time}= Get HOST Time Using REST |
| 359 | |
| 360 | ${bmc_diff_set_new}= |
| 361 | ... Subtract Date From Date ${setdate} ${new_bmc_time} |
| 362 | ${bmc_diff_set_new}= Evaluate abs(${bmc_diff_set_new}) |
| 363 | ${bmc_diff_old_new}= |
| 364 | ... Subtract Date From Date ${old_bmc_time} ${new_bmc_time} |
| 365 | ${bmc_diff_old_new}= Evaluate abs(${bmc_diff_old_new}) |
| 366 | |
| 367 | ${host_diff_set_new}= |
| 368 | ... Subtract Date From Date ${setdate} ${new_host_time} |
| 369 | ${host_diff_set_new}= Evaluate abs(${host_diff_set_new}) |
| 370 | ${host_diff_old_new}= |
| 371 | ... Subtract Date From Date ${old_host_time} ${new_host_time} |
| 372 | ${host_diff_old_new}= Evaluate abs(${host_diff_old_new}) |
| 373 | |
| 374 | Run Keyword If '${bmc_time}' == 'Not Set' |
| 375 | ... Should Be True ${bmc_diff_set_new} >= ${ALLOWED_TIME_DIFF} |
| 376 | ... ELSE IF '${bmc_time}' == 'Set' |
| 377 | ... Should Be True ${bmc_diff_set_new} <= ${ALLOWED_TIME_DIFF} |
| 378 | ... ELSE IF '${bmc_time}' == 'No Change' |
| 379 | ... Should Be True ${bmc_diff_old_new} <= ${ALLOWED_TIME_DIFF} |
| 380 | ... ELSE IF '${bmc_time}' == 'Change' |
| 381 | ... Should Be True ${bmc_diff_old_new} >= ${ALLOWED_TIME_DIFF} |
| 382 | |
| 383 | Run Keyword If '${host_time}' == 'No Change' |
| 384 | ... Should Be True ${host_diff_old_new} <= ${ALLOWED_TIME_DIFF} |
| 385 | ... ELSE IF '${host_time}' == 'Change' |
| 386 | ... Should Be True ${host_diff_old_new} >= ${ALLOWED_TIME_DIFF} |
| 387 | ... ELSE IF '${host_time}' == 'Not Set' |
| 388 | ... Should Be True ${host_diff_set_new} >= ${ALLOWED_TIME_DIFF} |
| 389 | ... ELSE IF '${host_time}' == 'Set' |
| 390 | ... Should Be True ${host_diff_set_new} <= ${ALLOWED_TIME_DIFF} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 391 | |
| 392 | |
| 393 | Post Test Execution |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 394 | [Documentation] Perform operations after test execution. Capture FFDC |
| 395 | ... in case of test case failure and sets default values for time mode |
| 396 | ... and owner. |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 397 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 398 | Run Keyword If Test Failed FFDC On Test Case Fail |
| 399 | Set Time Owner BMC |
| 400 | Set Time Mode NTP |