blob: 974e89d4564fd591df728eabe319b1c90bad4352 [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
George Keishing06ae4aa2016-08-30 01:41:28 -050028 set suite variable ${OLD_MAC_ADDRESS} ${json['data']}
Chris Austenb29d2e82016-06-07 12:25:35 -050029
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}
George Keishing06ae4aa2016-08-30 01:41:28 -0500131
Chris Austenb29d2e82016-06-07 12:25:35 -0500132 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
George Keishing06ae4aa2016-08-30 01:41:28 -0500174 [Documentation] This test case tries to set existing ipaddress address and
175 ... later tries to verify that ip address type is set to static
Chris Austenb29d2e82016-06-07 12:25:35 -0500176 ... 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}
George Keishing06ae4aa2016-08-30 01:41:28 -0500190
Rahul Maheshwari4f467f32016-09-03 15:02:57 -0500191 Wait Until Keyword Succeeds 30 sec 5 sec Initialize OpenBMC
192
Chris Austenb29d2e82016-06-07 12:25:35 -0500193 @{arglist}= Create List eth0
194 ${args}= Create Dictionary data=@{arglist}
195 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddressType data=${args}
196 ${json} = to json ${resp.content}
197 Should Be Equal ${json['data']} STATIC
198 should be equal as strings ${json['status']} ok
199
200
201Persistency check for ip address
202 [Tags] reboot_test
203 [Documentation] we reboot the service processor and after reboot
204 ... will request for the ip address to check the persistency
205 ... of the ip address.
206 ... Expectation is the ip address should persist.
George Keishing06ae4aa2016-08-30 01:41:28 -0500207
Chris Austenb29d2e82016-06-07 12:25:35 -0500208 Open Connection And Log In
209 Execute Command reboot
210# sleep 100sec
211 log to console "System is getting rebooted wait for few seconds"
212 ${networkInfo}= Get networkInfo from the interface eth0
213 ${ipaddress}= set variable ${networkInfo['data'][2]}
214 ${gateway}= set variable ${networkInfo['data'][3]}
215
216 ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
217 log to console ${isgatewayfound}
218 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
219 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
220
221
222
223
224
225Set invalid Mac address eth0 gg:hh:jj:kk:ll:mm error
226 [Tags] network_test
227 [Template] SetMacAddress_bad
George Keishing06ae4aa2016-08-30 01:41:28 -0500228 [Documentation] This test case tries to set the invalid mac address
Chris Austenb29d2e82016-06-07 12:25:35 -0500229 ... on the eth0 interface.
230 ... Expectation is that it should throw error.
231
232
233Set valid Mac address eth0 00:21:cc:73:91:dd ok
234 [Tags] network_test
235 [Template] SetMacAddress_good
236 [Documentation] ***GOOD PATH***
237 ... This test case add the ip addresson the interface and validates
238 ... that ip address has been added or not.
239 ... Expectation is the ip address should get added.
George Keishing06ae4aa2016-08-30 01:41:28 -0500240
Chris Austenb29d2e82016-06-07 12:25:35 -0500241Revert old Mac address eth0 ${OLD_MAC_ADDRESS} ok
242 [Tags] network_test
243 [Template] SetMacAddress_good
244 [Documentation] ***GOOD PATH***
245 ... This test case add the ip addresson the interface and validates
246 ... that ip address has been added or not.
247 ... Expectation is the ip address should get added.
248
249
250***keywords***
251
252Get networkInfo from the interface
253
254 [Documentation] This keyword is used to match the given ip with the configured one.
255 ... returns true if match successfull else false
256 ... eg:- Outout of getAddress4
257 ... NewFormat:-{"data": [ 2,25,"9.3.164.147","9.3.164.129"],"message": "200 OK","status": "ok"}
258 ... OldFormat:-
259 ... {"data": [[[2,25,0,128,"9.3.164.177"],[2,8,254,128,"127.0.0.1"]],"9.3.164.129"],
260 ... "message": "200 OK", "status": "ok"}
261
262 [arguments] ${intf}
263 @{arglist}= Create List ${intf}
264 ${args}= Create Dictionary data=@{arglist}
265 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args}
266 should be equal as strings ${resp.status_code} ${HTTP_OK}
267 ${json} = to json ${resp.content}
268 log to console ${json['data'][2]}
269 log to console ${json['data'][3]}
270 [return] ${json}
271
272AddNetworkInfo
273 [Arguments] ${intf} ${address} ${mask} ${gateway} ${result}
274
275 ${arglist}= Create List ${intf} ${address} ${mask} ${gateway}
276 ${args}= Create Dictionary data=@{arglist}
277 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
278 should not be equal as strings ${resp.status_code} ${HTTP_OK}
279 ${json} = to json ${resp.content}
280 should be equal as strings ${json['status']} ${result}
281
282
283SetMacAddress_bad
284 [Arguments] ${intf} ${address} ${result}
285 ${arglist}= Create List ${intf} ${address}
286 ${args}= Create Dictionary data=@{arglist}
287 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetHwAddress data=${args}
288 should not be equal as strings ${resp.status_code} ${HTTP_OK}
289 ${json} = to json ${resp.content}
290 should be equal as strings ${json['status']} ${result}
291
292
293SetMacAddress_good
294 [Arguments] ${intf} ${address} ${result}
George Keishing06ae4aa2016-08-30 01:41:28 -0500295 ${arglist}= Create List ${intf} ${address}
Chris Austenb29d2e82016-06-07 12:25:35 -0500296 ${args}= Create Dictionary data=@{arglist}
297 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetHwAddress data=${args}
298 should be equal as strings ${resp.status_code} ${HTTP_OK}
299 ${json} = to json ${resp.content}
300 should be equal as strings ${json['status']} ${result}
301 Wait For Host To Ping ${OPENBMC_HOST}
302
Rahul Maheshwari4f467f32016-09-03 15:02:57 -0500303 Wait Until Keyword Succeeds 30 sec 5 sec Initialize OpenBMC
304
Chris Austenb29d2e82016-06-07 12:25:35 -0500305 @{arglist}= Create List ${intf}
306 ${args}= Create Dictionary data=@{arglist}
307 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetHwAddress data=${args}
308 ${json} = to json ${resp.content}
309 should be equal as strings ${json['data']} ${address}
George Keishing06ae4aa2016-08-30 01:41:28 -0500310
Chris Austenb29d2e82016-06-07 12:25:35 -0500311
312validateEnvVariables
313
314 ${NEW_BMC_IP}= Get Environment Variable NEW_BMC_IP
315 ${NEW_SUBNET_MASK}= Get Environment Variable NEW_SUBNET_MASK
316 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
317
George Keishing06ae4aa2016-08-30 01:41:28 -0500318
319 should not be empty ${NEW_BMC_IP}
320 should not be empty ${NEW_GATEWAY}
321 should not be empty ${NEW_SUBNET_MASK}