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