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