Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite is for testing System time in Open BMC. |
| 3 | |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 4 | Resource ../lib/rest_client.robot |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 5 | Resource ../lib/ipmi_client.robot |
George Keishing | d55a4be | 2016-08-26 03:28:17 -0500 | [diff] [blame] | 6 | Resource ../lib/openbmc_ffdc.robot |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 7 | Resource ../lib/resource.txt |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 8 | |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 9 | Library OperatingSystem |
| 10 | Library DateTime |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 11 | |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 12 | Suite Setup Open Connection And Log In |
| 13 | Suite Teardown Close All Connections |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 14 | Test Teardown Post Test Execution |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 15 | |
| 16 | *** Variables *** |
| 17 | ${SYSTEM_TIME_INVALID} 01/01/1969 00:00:00 |
| 18 | ${SYSTEM_TIME_VALID} 02/29/2016 09:10:00 |
| 19 | ${ALLOWED_TIME_DIFF} 2 |
| 20 | |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 21 | ${SETTING_HOST} ${SETTINGS_URI}host0 |
| 22 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 23 | *** Test Cases *** |
| 24 | |
| 25 | Get System Time |
| 26 | [Documentation] ***GOOD PATH*** |
| 27 | ... This test case tries to get system time using IPMI and |
| 28 | ... then tries to cross check with BMC date time. |
| 29 | ... Expectation is that BMC time and ipmi sel time should match. |
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 | |
| 32 | ${resp}= Run IPMI Standard Command sel time get |
| 33 | ${ipmidate}= Convert Date ${resp} date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes |
| 34 | ${bmcdate}= Get BMC Time And Date |
| 35 | ${diff}= Subtract Date From Date ${bmcdate} ${ipmidate} |
| 36 | Should Be True ${diff} < ${ALLOWED_TIME_DIFF} Open BMC time does not match with IPMI sel time |
| 37 | |
| 38 | Set Valid System Time |
| 39 | [Documentation] ***GOOD PATH*** |
| 40 | ... This test case tries to set system time using IPMI and |
| 41 | ... then tries to cross check if it is correctly set in BMC. |
| 42 | ... Expectation is that BMC time should match with new time. |
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 | |
| 45 | ${resp}= Run IPMI Standard Command sel time set "${SYSTEM_TIME_VALID}" |
| 46 | ${setdate}= Convert Date ${SYSTEM_TIME_VALID} date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes |
| 47 | ${bmcdate}= Get BMC Time And Date |
| 48 | ${diff}= Subtract Date From Date ${bmcdate} ${setdate} |
| 49 | Should Be True ${diff} < ${ALLOWED_TIME_DIFF} Open BMC time does not match with set time |
| 50 | |
| 51 | Set Invalid System Time |
| 52 | [Documentation] ***BAD PATH*** |
| 53 | ... This test case tries to set system time with invalid time using IPMI. |
| 54 | ... Expectation is that it should return 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 | |
| 57 | ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command sel time set "${SYSTEM_TIME_INVALID}" |
| 58 | Should Start With ${msg} Specified time could not be parsed |
| 59 | |
| 60 | Set System Time with no time |
George Keishing | 845fb82 | 2016-11-01 13:23:19 -0500 | [diff] [blame] | 61 | [Documentation] ***BAD PATH*** |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 62 | ... This test case tries to set system time with no time using IPMI. |
| 63 | ... Expectation is that it should return 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 | |
| 66 | ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command sel time set "" |
| 67 | Should Start With ${msg} Specified time could not be parsed |
| 68 | |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 69 | Set NTP Time Mode |
| 70 | [Documentation] ***GOOD PATH*** |
| 71 | ... This testcase is to set time mode as NTP using REST |
| 72 | ... URI and then verify using REST API.\n |
| 73 | [Tags] Set_NTP_Time_Mode |
| 74 | |
| 75 | Set Time Mode NTP |
| 76 | |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 77 | ${boot}= Read Attribute ${SETTING_HOST} time_mode |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 78 | Should Be Equal ${boot} NTP |
| 79 | |
| 80 | Set Manual Time Mode |
| 81 | [Documentation] ***GOOD PATH*** |
| 82 | ... This testcase is to set time mode as manual using REST |
| 83 | ... URI and then verify using REST API.\n |
| 84 | [Tags] Set_Manual_Time_Mode |
| 85 | |
| 86 | Set Time Mode Manual |
| 87 | |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 88 | ${boot}= Read Attribute ${SETTING_HOST} time_mode |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 89 | Should Be Equal ${boot} Manual |
| 90 | |
| 91 | Set Time Owner as BMC |
| 92 | [Documentation] ***GOOD PATH*** |
| 93 | ... This testcase is to set time owner as BMC using REST |
| 94 | ... URI and then verify using REST API.\n |
| 95 | [Tags] Set_Time_Owner_as_BMC |
| 96 | |
| 97 | Set Time Owner BMC |
| 98 | |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 99 | ${boot}= Read Attribute ${SETTING_HOST} time_owner |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 100 | Should Be Equal ${boot} BMC |
| 101 | |
| 102 | Set Time Owner as Host |
| 103 | [Documentation] ***GOOD PATH*** |
| 104 | ... This testcase is to set time owner as Host using REST |
| 105 | ... URI and then verify using REST API.\n |
| 106 | [Tags] Set_Time_Owner_as_Host |
| 107 | |
| 108 | Set Time Owner Host |
| 109 | |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 110 | ${boot}= Read Attribute ${SETTING_HOST} time_owner |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 111 | Should Be Equal ${boot} Host |
| 112 | |
| 113 | Set Invalid Time Mode |
| 114 | [Documentation] ***BAD PATH*** |
| 115 | ... This testcase is to verify that invalid value for time |
| 116 | ... mode can not be set and proper error is thrown by |
| 117 | ... REST API for the same. |
| 118 | [Tags] Set_Invalid_Time_Mode |
| 119 | |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 120 | ${resp}= Set Time Mode abc |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 121 | Should Be Equal ${resp} error |
| 122 | |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 123 | ${boot}= Read Attribute ${SETTING_HOST} time_mode |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 124 | Should Not Be Equal ${boot} abc |
| 125 | |
| 126 | Set Invalid Time Owner |
| 127 | [Documentation] ***BAD PATH*** |
| 128 | ... This testcase is to verify that invalid value for time |
| 129 | ... owner can not be set and proper error is thrown by |
| 130 | ... REST API for the same. |
| 131 | [Tags] Set_Invalid_Time_Owner |
| 132 | |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 133 | ${resp}= Set Time Owner xyz |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 134 | Should Be Equal ${resp} error |
| 135 | |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 136 | ${boot}= Read Attribute ${SETTING_HOST} time_owner |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 137 | Should Not Be Equal ${boot} xyz |
| 138 | |
| 139 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 140 | *** Keywords *** |
| 141 | |
| 142 | Get BMC Time And Date |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 143 | ${stdout} ${stderr} ${output}= |
| 144 | ... Execute Command date "+%m/%d/%Y %H:%M:%S" |
| 145 | ... return_stdout=True return_stderr= True return_rc=True |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 146 | Should Be Equal ${output} ${0} msg=${stderr} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 147 | |
| 148 | ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S |
| 149 | ... exclude_millis=yes |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 150 | Should Not Be Empty ${resp} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 151 | [Return] ${resp} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 152 | |
| 153 | Set Time Owner |
| 154 | [Arguments] ${args} |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 155 | ${timeowner}= Set Variable ${args} |
| 156 | ${valueDict}= create dictionary data=${timeowner} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 157 | |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 158 | ${resp}= OpenBMC Put Request |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 159 | ... ${SETTING_HOST}/attr/time_owner data=${valueDict} |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 160 | ${jsondata}= to json ${resp.content} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 161 | [Return] ${jsondata['status']} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 162 | |
| 163 | Set Time Mode |
| 164 | [Arguments] ${args} |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 165 | ${timemode}= Set Variable ${args} |
| 166 | ${valueDict}= create dictionary data=${timemode} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 167 | |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 168 | ${resp}= OpenBMC Put Request |
George Keishing | ab1bd92 | 2016-12-05 05:29:59 -0600 | [diff] [blame] | 169 | ... ${SETTING_HOST}/attr/time_mode data=${valueDict} |
Gunnar Mills | 1cd544d | 2016-12-06 11:19:22 -0600 | [diff] [blame] | 170 | ${jsondata}= to json ${resp.content} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 171 | [Return] ${jsondata['status']} |
Rahul Maheshwari | 93f6809 | 2016-10-24 02:42:12 -0500 | [diff] [blame] | 172 | |
| 173 | |
| 174 | Post Test Execution |
| 175 | [Documentation] Perform operations after test execution. It first try to |
| 176 | ... capture FFDC in case of test case failure. Later it sets |
| 177 | ... default values for time mode and owner. |
| 178 | |
| 179 | Run Keyword If Test Failed FFDC On Test Case Fail |
| 180 | |
| 181 | Set Time Mode NTP |
| 182 | |
| 183 | Set Time Owner BMC |