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