blob: 3c13f496cce86260b2239dc9c9ed58b6c85befa5 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Documentation This suite is for testing System time in Open BMC.
3
Rahul Maheshwari93f68092016-10-24 02:42:12 -05004Resource ../lib/rest_client.robot
George Keishing4d6c1da2016-07-15 05:51:22 -05005Resource ../lib/ipmi_client.robot
George Keishingd55a4be2016-08-26 03:28:17 -05006Resource ../lib/openbmc_ffdc.robot
George Keishingab1bd922016-12-05 05:29:59 -06007Resource ../lib/resource.txt
Chris Austenb29d2e82016-06-07 12:25:35 -05008
George Keishing4d6c1da2016-07-15 05:51:22 -05009Library OperatingSystem
10Library DateTime
Chris Austenb29d2e82016-06-07 12:25:35 -050011
George Keishing4d6c1da2016-07-15 05:51:22 -050012Suite Setup Open Connection And Log In
13Suite Teardown Close All Connections
Rahul Maheshwari93f68092016-10-24 02:42:12 -050014Test Teardown Post Test Execution
Chris Austenb29d2e82016-06-07 12:25:35 -050015
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 Keishingab1bd922016-12-05 05:29:59 -060021${SETTING_HOST} ${SETTINGS_URI}host0
22
Chris Austenb29d2e82016-06-07 12:25:35 -050023*** Test Cases ***
24
25Get 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 Keishing845fb822016-11-01 13:23:19 -050030 [Tags] Get_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050031
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
38Set 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 Keishing845fb822016-11-01 13:23:19 -050043 [Tags] Set_Valid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050044
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
51Set 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 Keishing845fb822016-11-01 13:23:19 -050055 [Tags] Set_Invalid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050056
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
60Set System Time with no time
George Keishing845fb822016-11-01 13:23:19 -050061 [Documentation] ***BAD PATH***
Chris Austenb29d2e82016-06-07 12:25:35 -050062 ... This test case tries to set system time with no time using IPMI.
63 ... Expectation is that it should return error.
George Keishing845fb822016-11-01 13:23:19 -050064 [Tags] Set_System_Time_with_no_time
Chris Austenb29d2e82016-06-07 12:25:35 -050065
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 Maheshwari93f68092016-10-24 02:42:12 -050069Set 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 Keishingab1bd922016-12-05 05:29:59 -060077 ${boot}= Read Attribute ${SETTING_HOST} time_mode
Rahul Maheshwari93f68092016-10-24 02:42:12 -050078 Should Be Equal ${boot} NTP
79
80Set 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 Keishingab1bd922016-12-05 05:29:59 -060088 ${boot}= Read Attribute ${SETTING_HOST} time_mode
Rahul Maheshwari93f68092016-10-24 02:42:12 -050089 Should Be Equal ${boot} Manual
90
91Set 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 Keishingab1bd922016-12-05 05:29:59 -060099 ${boot}= Read Attribute ${SETTING_HOST} time_owner
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500100 Should Be Equal ${boot} BMC
101
102Set 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 Keishingab1bd922016-12-05 05:29:59 -0600110 ${boot}= Read Attribute ${SETTING_HOST} time_owner
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500111 Should Be Equal ${boot} Host
112
113Set 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 Mills1cd544d2016-12-06 11:19:22 -0600120 ${resp}= Set Time Mode abc
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500121 Should Be Equal ${resp} error
122
George Keishingab1bd922016-12-05 05:29:59 -0600123 ${boot}= Read Attribute ${SETTING_HOST} time_mode
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500124 Should Not Be Equal ${boot} abc
125
126Set 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 Mills1cd544d2016-12-06 11:19:22 -0600133 ${resp}= Set Time Owner xyz
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500134 Should Be Equal ${resp} error
135
George Keishingab1bd922016-12-05 05:29:59 -0600136 ${boot}= Read Attribute ${SETTING_HOST} time_owner
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500137 Should Not Be Equal ${boot} xyz
138
139
Chris Austenb29d2e82016-06-07 12:25:35 -0500140*** Keywords ***
141
142Get BMC Time And Date
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500143 ${stdout} ${stderr} ${output}=
144 ... Execute Command date "+%m/%d/%Y %H:%M:%S"
145 ... return_stdout=True return_stderr= True return_rc=True
Chris Austenb29d2e82016-06-07 12:25:35 -0500146 Should Be Equal ${output} ${0} msg=${stderr}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500147
148 ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S
149 ... exclude_millis=yes
Chris Austenb29d2e82016-06-07 12:25:35 -0500150 Should Not Be Empty ${resp}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600151 [Return] ${resp}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500152
153Set Time Owner
154 [Arguments] ${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600155 ${timeowner}= Set Variable ${args}
156 ${valueDict}= create dictionary data=${timeowner}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500157
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600158 ${resp}= OpenBMC Put Request
George Keishingab1bd922016-12-05 05:29:59 -0600159 ... ${SETTING_HOST}/attr/time_owner data=${valueDict}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600160 ${jsondata}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600161 [Return] ${jsondata['status']}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500162
163Set Time Mode
164 [Arguments] ${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600165 ${timemode}= Set Variable ${args}
166 ${valueDict}= create dictionary data=${timemode}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500167
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600168 ${resp}= OpenBMC Put Request
George Keishingab1bd922016-12-05 05:29:59 -0600169 ... ${SETTING_HOST}/attr/time_mode data=${valueDict}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600170 ${jsondata}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600171 [Return] ${jsondata['status']}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500172
173
174Post 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