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