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 |
Rahul Maheshwari | 2c72504 | 2017-01-29 22:55:28 -0600 | [diff] [blame] | 7 | Resource ../lib/state_manager.robot |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 8 | Resource ../lib/resource.txt |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 9 | |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 10 | Library OperatingSystem |
| 11 | Library DateTime |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 12 | |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 13 | Suite Setup Open Connection And Log In |
| 14 | Suite Teardown Close All Connections |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 15 | Test Teardown Post Test Execution |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 16 | |
| 17 | *** Variables *** |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 18 | ${SYSTEM_TIME_INVALID} 01/01/1969 00:00:00 |
| 19 | ${SYSTEM_TIME_VALID} 02/29/2016 09:10:00 |
| 20 | ${SYSTEM_TIME_VALID_EPOCH} 1456737000 #Equivalent epoch time for 02/29/2016 09:10:00 |
| 21 | ${ALLOWED_TIME_DIFF} 3 |
| 22 | ${SETTING_HOST} ${SETTINGS_URI}host0 |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 23 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 24 | *** Test Cases *** |
| 25 | |
| 26 | Get System Time |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 27 | [Documentation] Get system time using IPMI and verify that it matches |
| 28 | ... with BMC date time. |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 29 | [Tags] Get_System_Time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 30 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 31 | ${resp}= Run IPMI Standard Command sel time get |
| 32 | ${ipmidate}= Convert Date ${resp} date_format=%m/%d/%Y %H:%M:%S |
| 33 | ... exclude_millis=yes |
| 34 | ${bmcdate}= Get BMC Time Using IPMI |
| 35 | ${diff}= Subtract Date From Date ${bmcdate} ${ipmidate} |
| 36 | Should Be True ${diff} < ${ALLOWED_TIME_DIFF} |
| 37 | ... Open BMC time does not match with IPMI sel time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 38 | |
| 39 | Set Valid System Time |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 40 | [Documentation] Set system time using IPMI and verify that it is |
| 41 | ... correctly set in BMC. |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 42 | [Tags] Set_Valid_System_Time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 43 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 44 | ${resp}= Run IPMI Standard Command sel time set "${SYSTEM_TIME_VALID}" |
| 45 | ${setdate}= Convert Date ${SYSTEM_TIME_VALID} |
| 46 | ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes |
| 47 | ${bmcdate}= Get BMC Time Using IPMI |
| 48 | ${diff}= Subtract Date From Date ${bmcdate} ${setdate} |
| 49 | Should Be True ${diff} < ${ALLOWED_TIME_DIFF} |
| 50 | ... Open BMC time does not match with set time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 51 | |
| 52 | Set Invalid System Time |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 53 | [Documentation] Set system time with invalid time using IPMI and verify |
| 54 | ... that it should throw error. |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 55 | [Tags] Set_Invalid_System_Time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 56 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 57 | ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command |
| 58 | ... sel time set "${SYSTEM_TIME_INVALID}" |
| 59 | Should Start With ${msg} Specified time could not be parsed |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 60 | |
| 61 | Set System Time with no time |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 62 | [Documentation] Set system time with no time using IPMI and verify |
| 63 | ... that it should throw error. |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 64 | [Tags] Set_System_Time_with_no_time |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 65 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 66 | ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command |
| 67 | ... sel time set "" |
| 68 | Should Start With ${msg} Specified time could not be parsed |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 69 | |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 70 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 71 | Set BMC Time With BMC And Manual |
| 72 | #Operation Owner Mode Status BMC Time Host Time |
| 73 | Set BMC Time BMC MANUAL ok Set Change |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 74 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 75 | [Documentation] Set BMC time when time owner is BMC and time mode is |
| 76 | ... manual. |
| 77 | [Tags] Set_BMC_Time_With_BMC_And_Manual |
| 78 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 79 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 80 | Set BMC Time With Both And Manual |
| 81 | #Operation Owner Mode Status BMC Time Host Time |
| 82 | Set BMC Time BOTH MANUAL ok Set Change |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 83 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 84 | [Documentation] Set BMC time when time owner is Both and time mode is |
| 85 | ... manual. |
| 86 | [Tags] Set_BMC_Time_With_Both_And_Manual |
| 87 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 88 | |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 89 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 90 | Set BMC Time With Split And Manual |
| 91 | #Operation Owner Mode Status BMC Time Host Time |
| 92 | Set BMC Time SPLIT MANUAL ok Set No Change |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 93 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 94 | [Documentation] Set BMC time when time owner is Split and time mode is |
| 95 | ... manual. |
| 96 | [Tags] Set_BMC_Time_With_Split_And_Manual |
| 97 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 98 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 99 | Set BMC Time With BMC And NTP |
| 100 | #Operation Owner Mode Status BMC Time Host Time |
| 101 | Set BMC Time BMC NTP error Not Set No Change |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 102 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 103 | [Documentation] Set BMC time when time owner is BMC and time mode is |
| 104 | ... NTP. |
| 105 | [Tags] Set_BMC_Time_With_BMC_And_NTP |
| 106 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 107 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 108 | Set BMC Time With Host And Manual |
| 109 | #Operation Owner Mode Status BMC Time Host Time |
| 110 | Set BMC Time HOST MANUAL error Not Set No Change |
| 111 | [Documentation] Set BMC time when time owner is Host and time mode is |
| 112 | ... Manual. |
| 113 | [Tags] Set_BMC_Time_With_Host_And_Manual |
| 114 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 115 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 116 | Set BMC Time With Both And NTP |
| 117 | #Operation Owner Mode Status BMC Time Host Time |
| 118 | Set BMC Time BOTH NTP error Not Set No Change |
| 119 | |
| 120 | [Documentation] Set BMC time when time owner is Both and time mode is |
| 121 | ... NTP. |
| 122 | [Tags] Set_BMC_Time_With_Both_And_NTP |
| 123 | [Template] Set Time Using REST |
| 124 | |
| 125 | Set BMC Time With Split And NTP |
| 126 | #Operation Owner Mode Status BMC Time Host Time |
| 127 | Set BMC Time SPLIT NTP error Not Set No Change |
| 128 | |
| 129 | [Documentation] Set BMC time when time owner is Split and time mode is |
| 130 | ... NTP. |
| 131 | [Tags] Set_BMC_Time_With_Split_And_NTP |
| 132 | [Template] Set Time Using REST |
| 133 | |
| 134 | Set Host Time With Host And Manual |
| 135 | #Operation Owner Mode Status BMC Time Host Time |
| 136 | Set Host Time HOST MANUAL ok Change Set |
| 137 | |
| 138 | [Documentation] Set host time when time owner is host and time mode is |
| 139 | ... manual. |
| 140 | [Tags] Set_Host_Time_With_Host_And_Manual |
| 141 | [Template] Set Time Using REST |
| 142 | |
| 143 | Set Host Time With Both And Manual |
| 144 | #Operation Owner Mode Status BMC Time Host Time |
| 145 | Set Host Time BOTH MANUAL ok Change Set |
| 146 | |
| 147 | [Documentation] Set host time when time owner is both and time mode is |
| 148 | ... manual. |
| 149 | [Tags] Set_Host_Time_With_Both_And_Manual |
| 150 | [Template] Set Time Using REST |
| 151 | |
| 152 | Set Host Time With Both And NTP |
| 153 | #Operation Owner Mode Status BMC Time Host Time |
| 154 | Set Host Time BOTH NTP ok No Change Set |
| 155 | |
| 156 | [Documentation] Set host time when time owner is both and time mode is |
| 157 | ... NTP. |
| 158 | [Tags] Set_Host_Time_With_Both_And_NTP |
| 159 | [Template] Set Time Using REST |
| 160 | |
| 161 | Set Host Time With Split And Manual |
| 162 | #Operation Owner Mode Status BMC Time Host Time |
| 163 | Set Host Time SPLIT MANUAL ok No Change Set |
| 164 | |
| 165 | [Documentation] Set host time when time owner is split and time mode is |
| 166 | ... manual. |
| 167 | [Tags] Set_Host_Time_With_Split_And_Manual |
| 168 | [Template] Set Time Using REST |
| 169 | |
| 170 | Set Host Time With Split And NTP |
| 171 | #Operation Owner Mode Status BMC Time HOST Time |
| 172 | Set Host Time SPLIT NTP ok No Change Set |
| 173 | |
| 174 | [Documentation] Set host time when time owner is split and time mode is |
| 175 | ... NTP. |
| 176 | [Tags] Set_Host_Time_With_Split_And_NTP |
| 177 | [Template] Set Time Using REST |
| 178 | |
| 179 | Set Host Time With BMC And Manual |
| 180 | #Operation Owner Mode Status BMC Time HOST Time |
| 181 | Set Host Time BMC MANUAL error No Change Not Set |
| 182 | [Documentation] Set host time when time owner is BMC and time mode is |
| 183 | ... Manual. |
| 184 | [Tags] Set_Host_Time_With_BMC_And_Manual |
| 185 | [Template] Set Time Using REST |
| 186 | |
| 187 | Set Host Time With BMC Owner NTP |
| 188 | #Operation Owner Mode Status BMC Time HOST Time |
| 189 | Set Host Time BMC NTP error No Change Not Set |
| 190 | [Documentation] Set host time when time owner is BMC and time mode is |
| 191 | ... NTP. |
| 192 | [Tags] Set_Host_Time_With_BMC_And_NTP |
| 193 | [Template] Set Time Using REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 194 | |
| 195 | Set Invalid Time Mode |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 196 | [Documentation] Set time mode with invalid value using REST and verify |
| 197 | ... that it should throw error. |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 198 | [Tags] Set_Invalid_Time_Mode |
| 199 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 200 | ${timemode}= Set Variable abc |
| 201 | ${valueDict}= Create Dictionary data=${timemode} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 202 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 203 | ${resp}= OpenBMC Put Request |
| 204 | ... ${SETTING_HOST}/attr/time_mode data=${valueDict} |
| 205 | ${jsondata}= to JSON ${resp.content} |
| 206 | Should Be Equal ${jsondata['status']} error |
| 207 | |
| 208 | ${mode}= Read Attribute ${SETTING_HOST} time_mode |
| 209 | Should Not Be Equal ${mode} abc |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 210 | |
| 211 | Set Invalid Time Owner |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 212 | [Documentation] Set time owner with invalid value using REST and verify |
| 213 | ... that it should throw error. |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 214 | [Tags] Set_Invalid_Time_Owner |
| 215 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 216 | ${timeowner}= Set Variable xyz |
| 217 | ${valueDict}= Create Dictionary data=${timeowner} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 218 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 219 | ${resp}= OpenBMC Put Request |
| 220 | ... ${SETTING_HOST}/attr/time_owner data=${valueDict} |
| 221 | ${jsondata}= to JSON ${resp.content} |
| 222 | Should Be Equal ${jsondata['status']} error |
| 223 | |
| 224 | ${owner}= Read Attribute ${SETTING_HOST} time_owner |
| 225 | Should Not Be Equal ${owner} xyz |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 226 | |
| 227 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 228 | *** Keywords *** |
| 229 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 230 | Get BMC Time Using IPMI |
| 231 | [Documentation] Returns BMC time of the system via IPMI |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 232 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 233 | ${stdout} ${stderr} ${output}= |
| 234 | ... Execute Command date "+%m/%d/%Y %H:%M:%S" |
| 235 | ... return_stdout=True return_stderr= True return_rc=True |
| 236 | Should Be Equal ${output} ${0} msg=${stderr} |
| 237 | |
| 238 | ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S |
| 239 | ... exclude_millis=yes |
| 240 | Should Not Be Empty ${resp} |
| 241 | [Return] ${resp} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 242 | |
| 243 | Set Time Owner |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 244 | [Arguments] ${args} |
| 245 | [Documentation] Set time owner of the system via REST |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 246 | |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 247 | ${timeowner}= Set Variable ${args} |
| 248 | ${valueDict}= Create Dictionary data=${timeowner} |
| 249 | |
| 250 | ${resp}= OpenBMC Put Request |
| 251 | ... ${SETTING_HOST}/attr/time_owner data=${valueDict} |
| 252 | ${jsondata}= to JSON ${resp.content} |
| 253 | |
Rahul Maheshwari | 2c72504 | 2017-01-29 22:55:28 -0600 | [diff] [blame] | 254 | ${host_state}= Get Host State |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 255 | |
Rahul Maheshwari | 2c72504 | 2017-01-29 22:55:28 -0600 | [diff] [blame] | 256 | Run Keyword If '${host_state}' == 'Off' |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 257 | ... Log System is in off state so owner change will get applied. |
| 258 | ... ELSE Run keyword |
Rahul Maheshwari | 2c72504 | 2017-01-29 22:55:28 -0600 | [diff] [blame] | 259 | ... Initiate Host PowerOff |
Rahul Maheshwari | f878590 | 2016-12-12 01:23:13 -0600 | [diff] [blame] | 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 |