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