blob: 973e590bfa70ac5fd9c020e14971ca8bfe714bfc [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Documentation This suite will verifiy the Network Configuration Rest Interfaces
3... Details of valid interfaces can be found here...
4... https://github.com/openbmc/docs/blob/master/rest-api.md
5
George Keishing4d6c1da2016-07-15 05:51:22 -05006Resource ../lib/rest_client.robot
7Resource ../lib/connection_client.robot
8Resource ../lib/utils.robot
George Keishingd55a4be2016-08-26 03:28:17 -05009Resource ../lib/openbmc_ffdc.robot
George Keishing4d6c1da2016-07-15 05:51:22 -050010Library ../lib/pythonutil.py
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
George Keishingd55a4be2016-08-26 03:28:17 -050014Test Teardown Log FFDC
Chris Austenb29d2e82016-06-07 12:25:35 -050015
George Keishing4d6c1da2016-07-15 05:51:22 -050016*** Test Cases ***
Chris Austenb29d2e82016-06-07 12:25:35 -050017
18Get the Mac address
19
20 [Documentation] This test case is to get the mac address
21 [Tags] network_test
22 @{arglist}= Create List eth0
23 ${args}= Create Dictionary data=@{arglist}
24 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetHwAddress data=${args}
25 should not be empty ${resp.content}
26 ${json} = to json ${resp.content}
27 should be equal as strings ${json['status']} ok
28 set suite variable ${OLD_MAC_ADDRESS} ${json['data']}
29
30
31Get IP Address with invalid interface
32
33 [Documentation] This test case tries to get the ip addrees with the invalid
34 ... interface,Expectation is it should get error.
35 [Tags] network_test
36
37 @{arglist}= Create List lo01
38 ${args}= Create Dictionary data=@{arglist}
39 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args}
40 should not be equal as strings ${resp.status_code} ${HTTP_OK}
41 ${json} = to json ${resp.content}
42 should be equal as strings ${json['status']} error
43
44Get IP Address with valid interface
45
46 [Documentation] This test case tries to get the ip addrees with the invalid
47 ... interface,Expectation is it should get error.
48 [Tags] network_test
49
50 @{arglist}= Create List eth0
51 ${args}= Create Dictionary data=@{arglist}
52 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args}
53 should be equal as strings ${resp.status_code} ${HTTP_OK}
54 ${json} = to json ${resp.content}
55 should be equal as strings ${json['status']} ok
56
57
58Set the IP address on invalid Interface lo01 1.1.1.1 255.255.255.0 1.1.1.1 error
59
60 [Tags] network_test
61 [Template] AddNetworkInfo
62 [Documentation] This test case tries to set the ip addrees with the invalid
63 ... interface,Expectation is it should get error
64
65Set invalid IP address on the valid interface eth0 ab.cd.ef.gh 255.255.255.0 1.1.1.1 error
66
67 [Tags] network_test
68 [Template] AddNetworkInfo
69 [Documentation] This test case tries to set the invalid ip addrees on the interface
70 ... Expectation is it should get error.
71
72
73Set IP address with invalid subnet mask eth0 2.2.2.2 av.ih.jk.lm 1.1.1.1 error
74
75 [Tags] network_test
76 [Template] AddNetworkInfo
77 [Documentation] This test case tries to set the ip addrees on the interface
78 ... with invalid subnet mask,Expectation is it should get error.
79
80Set empty IP address eth0 ${EMPTY} 255.255.255.0 1.1.1.1 error
81
82 [Tags] network_test
83 [Template] AddNetworkInfo
84 [Documentation] This test case tries to set the NULL ip addrees on the interface
85 ... Expectation is it should get error.
86
87Set empty subnet mask eth0 2.2.2.2 ${EMPTY} 1.1.1.1 error
88
89 [Tags] network_test
90 [Template] AddNetworkInfo
91 [Documentation] This test case tries to set the ip addrees on the interface
92 ... with empty subnet mask,Expectation is it should get error.
93
94Set empty gateway eth0 2.2.2.2 255.255.255.0 ${EMPTY} error
95
96 [Tags] network_test
97 [Template] AddNetworkInfo
98 [Documentation] This test case tries to set the ip addrees on the interface
99 ... with empty gateway,Expectation is it should get error.
100
101
102Set IP address on valid Interface
103 [Tags] network_test
104 [Documentation] This test case sets the ip on the interface and validates
105 ... that ip address has been set or not.
106 ... Expectation is the ip address should get added.
107
108 validateEnvVariables
109
110
111 ${networkInfo}= Get networkInfo from the interface eth0
112 ${result}= convert to integer ${networkInfo['data'][1]}
113
114 ${MASK}= calcDottedNetmask ${result}
115 set suite variable ${OLD_MASK} ${MASK}
116 log to console ${OLD_MASK}
117 set suite variable ${OLD_IP} ${networkInfo['data'][2]}
118 set suite variable ${OLD_GATEWAY} ${networkInfo['data'][3]}
119
120 log to console ${OLD_IP}
121 log to console ${OLD_GATEWAY}
122
123
124 ${NEW_IP}= Get Environment Variable NEW_BMC_IP
125 ${NEW_MASK}= Get Environment Variable NEW_SUBNET_MASK
126 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
127
128 ${arglist}= Create List eth0 ${NEW_IP} ${NEW_MASK} ${NEW_GATEWAY}
129 ${args}= Create Dictionary data=@{arglist}
130 run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
131
132 Wait For Host To Ping ${NEW_IP}
133 Set Suite Variable ${AUTH_URI} https://${NEW_IP}
134 log to console ${AUTH_URI}
135
136 ${networkInfo}= Get networkInfo from the interface eth0
137 ${ipaddress}= set variable ${networkInfo['data'][2]}
138 ${gateway}= set variable ${networkInfo['data'][3]}
139
140 ${isgatewayfound} = Set Variable If '${gateway}'=='${NEW_GATEWAY}' true false
141 log to console ${isgatewayfound}
142 ${isIPfound}= Set Variable if '${ipaddress}' == '${NEW_IP}' true false
143 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
144
145
146Revert the last ip address change
147 [Tags] network_test
148 [Documentation] This test case sets the ip on the interface and validates
149 ... that ip address has been set or not.
150 ... Expectation is the ip address should get added.
151
152
153 ${arglist}= Create List eth0 ${OLD_IP} ${OLD_MASK} ${OLD_GATEWAY}
154 ${args}= Create Dictionary data=@{arglist}
155 run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
156
157 Wait For Host To Ping ${OLD_IP}
158 Set Suite Variable ${AUTH_URI} https://${OLD_IP}
159 log to console ${AUTH_URI}
160
161
162 ${networkInfo}= Get networkInfo from the interface eth0
163 ${ipaddress}= set variable ${networkInfo['data'][2]}
164 ${gateway}= set variable ${networkInfo['data'][3]}
165
166 ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
167 log to console ${isgatewayfound}
168 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
169 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
170
171
172Get IP Address type
173 [Tags] GOOD-PATH
174 [Documentation] This test case tries to set existing ipaddress address and
175 ... later tries to verify that ip address type is set to static
176 ... due to the operation.
177
178 ${networkInfo}= Get networkInfo from the interface eth0
179 ${result}= convert to integer ${networkInfo['data'][1]}
180
181 ${CURRENT_MASK}= calcDottedNetmask ${result}
182 ${CURRENT_IP}= set variable ${networkInfo['data'][2]}
183 ${CURRENT_GATEWAY}= set variable ${networkInfo['data'][3]}
184
185 ${arglist}= Create List eth0 ${CURRENT_IP} ${CURRENT_MASK} ${CURRENT_GATEWAY}
186 ${args}= Create Dictionary data=@{arglist}
187 run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
188
189 Wait For Host To Ping ${CURRENT_IP}
190
191 @{arglist}= Create List eth0
192 ${args}= Create Dictionary data=@{arglist}
193 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddressType data=${args}
194 ${json} = to json ${resp.content}
195 Should Be Equal ${json['data']} STATIC
196 should be equal as strings ${json['status']} ok
197
198
199Persistency check for ip address
200 [Tags] reboot_test
201 [Documentation] we reboot the service processor and after reboot
202 ... will request for the ip address to check the persistency
203 ... of the ip address.
204 ... Expectation is the ip address should persist.
205
206 Open Connection And Log In
207 Execute Command reboot
208# sleep 100sec
209 log to console "System is getting rebooted wait for few seconds"
210 ${networkInfo}= Get networkInfo from the interface eth0
211 ${ipaddress}= set variable ${networkInfo['data'][2]}
212 ${gateway}= set variable ${networkInfo['data'][3]}
213
214 ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
215 log to console ${isgatewayfound}
216 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
217 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
218
219
220
221
222
223Set invalid Mac address eth0 gg:hh:jj:kk:ll:mm error
224 [Tags] network_test
225 [Template] SetMacAddress_bad
226 [Documentation] This test case tries to set the invalid mac address
227 ... on the eth0 interface.
228 ... Expectation is that it should throw error.
229
230
231Set valid Mac address eth0 00:21:cc:73:91:dd ok
232 [Tags] network_test
233 [Template] SetMacAddress_good
234 [Documentation] ***GOOD PATH***
235 ... This test case add the ip addresson the interface and validates
236 ... that ip address has been added or not.
237 ... Expectation is the ip address should get added.
238
239Revert old Mac address eth0 ${OLD_MAC_ADDRESS} ok
240 [Tags] network_test
241 [Template] SetMacAddress_good
242 [Documentation] ***GOOD PATH***
243 ... This test case add the ip addresson the interface and validates
244 ... that ip address has been added or not.
245 ... Expectation is the ip address should get added.
246
247
248***keywords***
249
250Get networkInfo from the interface
251
252 [Documentation] This keyword is used to match the given ip with the configured one.
253 ... returns true if match successfull else false
254 ... eg:- Outout of getAddress4
255 ... NewFormat:-{"data": [ 2,25,"9.3.164.147","9.3.164.129"],"message": "200 OK","status": "ok"}
256 ... OldFormat:-
257 ... {"data": [[[2,25,0,128,"9.3.164.177"],[2,8,254,128,"127.0.0.1"]],"9.3.164.129"],
258 ... "message": "200 OK", "status": "ok"}
259
260 [arguments] ${intf}
261 @{arglist}= Create List ${intf}
262 ${args}= Create Dictionary data=@{arglist}
263 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args}
264 should be equal as strings ${resp.status_code} ${HTTP_OK}
265 ${json} = to json ${resp.content}
266 log to console ${json['data'][2]}
267 log to console ${json['data'][3]}
268 [return] ${json}
269
270AddNetworkInfo
271 [Arguments] ${intf} ${address} ${mask} ${gateway} ${result}
272
273 ${arglist}= Create List ${intf} ${address} ${mask} ${gateway}
274 ${args}= Create Dictionary data=@{arglist}
275 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
276 should not be equal as strings ${resp.status_code} ${HTTP_OK}
277 ${json} = to json ${resp.content}
278 should be equal as strings ${json['status']} ${result}
279
280
281SetMacAddress_bad
282 [Arguments] ${intf} ${address} ${result}
283 ${arglist}= Create List ${intf} ${address}
284 ${args}= Create Dictionary data=@{arglist}
285 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetHwAddress data=${args}
286 should not be equal as strings ${resp.status_code} ${HTTP_OK}
287 ${json} = to json ${resp.content}
288 should be equal as strings ${json['status']} ${result}
289
290
291SetMacAddress_good
292 [Arguments] ${intf} ${address} ${result}
293 ${arglist}= Create List ${intf} ${address}
294 ${args}= Create Dictionary data=@{arglist}
295 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetHwAddress data=${args}
296 should be equal as strings ${resp.status_code} ${HTTP_OK}
297 ${json} = to json ${resp.content}
298 should be equal as strings ${json['status']} ${result}
299 Wait For Host To Ping ${OPENBMC_HOST}
300
301 @{arglist}= Create List ${intf}
302 ${args}= Create Dictionary data=@{arglist}
303 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetHwAddress data=${args}
304 ${json} = to json ${resp.content}
305 should be equal as strings ${json['data']} ${address}
306
307
308validateEnvVariables
309
310 ${NEW_BMC_IP}= Get Environment Variable NEW_BMC_IP
311 ${NEW_SUBNET_MASK}= Get Environment Variable NEW_SUBNET_MASK
312 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
313
314
315 should not be empty ${NEW_BMC_IP}
316 should not be empty ${NEW_GATEWAY}
317 should not be empty ${NEW_SUBNET_MASK}