blob: 5731c645265a32dedd3d31d0ec4f97e90ff18f22 [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
Chris Austenb29d2e82016-06-07 12:25:35 -05007
George Keishing4d6c1da2016-07-15 05:51:22 -05008Library OperatingSystem
9Library DateTime
Chris Austenb29d2e82016-06-07 12:25:35 -050010
George Keishing4d6c1da2016-07-15 05:51:22 -050011Suite Setup Open Connection And Log In
12Suite Teardown Close All Connections
Rahul Maheshwari93f68092016-10-24 02:42:12 -050013Test Teardown Post Test Execution
Chris Austenb29d2e82016-06-07 12:25:35 -050014
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
22Get 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 Keishing845fb822016-11-01 13:23:19 -050027 [Tags] Get_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050028
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
35Set 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 Keishing845fb822016-11-01 13:23:19 -050040 [Tags] Set_Valid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050041
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
48Set 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 Keishing845fb822016-11-01 13:23:19 -050052 [Tags] Set_Invalid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050053
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
57Set System Time with no time
George Keishing845fb822016-11-01 13:23:19 -050058 [Documentation] ***BAD PATH***
Chris Austenb29d2e82016-06-07 12:25:35 -050059 ... This test case tries to set system time with no time using IPMI.
60 ... Expectation is that it should return error.
George Keishing845fb822016-11-01 13:23:19 -050061 [Tags] Set_System_Time_with_no_time
Chris Austenb29d2e82016-06-07 12:25:35 -050062
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 Maheshwari93f68092016-10-24 02:42:12 -050066Set 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
Gunnar Mills1cd544d2016-12-06 11:19:22 -060074 ${boot}= Read Attribute /org/openbmc/settings/host0 time_mode
Rahul Maheshwari93f68092016-10-24 02:42:12 -050075 Should Be Equal ${boot} NTP
76
77Set 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
Gunnar Mills1cd544d2016-12-06 11:19:22 -060085 ${boot}= Read Attribute /org/openbmc/settings/host0 time_mode
Rahul Maheshwari93f68092016-10-24 02:42:12 -050086 Should Be Equal ${boot} Manual
87
88Set 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
Gunnar Mills1cd544d2016-12-06 11:19:22 -060096 ${boot}= Read Attribute /org/openbmc/settings/host0 time_owner
Rahul Maheshwari93f68092016-10-24 02:42:12 -050097 Should Be Equal ${boot} BMC
98
99Set 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
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600107 ${boot}= Read Attribute /org/openbmc/settings/host0 time_owner
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500108 Should Be Equal ${boot} Host
109
110Set 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
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600117 ${resp}= Set Time Mode abc
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500118 Should Be Equal ${resp} error
119
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600120 ${boot}= Read Attribute /org/openbmc/settings/host0 time_mode
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500121 Should Not Be Equal ${boot} abc
122
123Set 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
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600130 ${resp}= Set Time Owner xyz
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500131 Should Be Equal ${resp} error
132
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600133 ${boot}= Read Attribute /org/openbmc/settings/host0 time_owner
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500134 Should Not Be Equal ${boot} xyz
135
136
Chris Austenb29d2e82016-06-07 12:25:35 -0500137*** Keywords ***
138
139Get BMC Time And Date
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500140 ${stdout} ${stderr} ${output}=
141 ... Execute Command date "+%m/%d/%Y %H:%M:%S"
142 ... return_stdout=True return_stderr= True return_rc=True
Chris Austenb29d2e82016-06-07 12:25:35 -0500143 Should Be Equal ${output} ${0} msg=${stderr}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500144
145 ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S
146 ... exclude_millis=yes
Chris Austenb29d2e82016-06-07 12:25:35 -0500147 Should Not Be Empty ${resp}
148 [return] ${resp}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500149
150Set Time Owner
151 [Arguments] ${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600152 ${timeowner}= Set Variable ${args}
153 ${valueDict}= create dictionary data=${timeowner}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500154
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600155 ${resp}= OpenBMC Put Request
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500156 ... /org/openbmc/settings/host0/attr/time_owner data=${valueDict}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600157 ${jsondata}= to json ${resp.content}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500158 [return] ${jsondata['status']}
159
160Set Time Mode
161 [Arguments] ${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600162 ${timemode}= Set Variable ${args}
163 ${valueDict}= create dictionary data=${timemode}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500164
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600165 ${resp}= OpenBMC Put Request
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500166 ... /org/openbmc/settings/host0/attr/time_mode data=${valueDict}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600167 ${jsondata}= to json ${resp.content}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500168 [return] ${jsondata['status']}
169
170
171Post 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