blob: bde94dc905d49160ae008b4d70ed45954109ff16 [file] [log] [blame]
Prashanth Kattie79c5402017-06-08 07:40:49 -05001*** Settings ***
Prashanth Katti4cf87bd2017-06-28 08:56:02 -05002Documentation Network interface and functionalities test module on BMC.
Prashanth Kattie79c5402017-06-08 07:40:49 -05003
4Resource ../lib/rest_client.robot
5Resource ../lib/utils.robot
6Resource ../lib/bmc_network_utils.robot
7
8Force Tags Network_Test
9
10Library String
11Library SSHLibrary
12
13Test Setup Test Init Setup
14
Prashanth Katti4cf87bd2017-06-28 08:56:02 -050015*** Variables ***
16
17${alpha_ip} xx.xx.xx.xx
18
19# 10.x.x.x series is a private IP address range and does not exist in
20# our network, so this is chosen to avoid IP conflict.
21
22${valid_ip} 10.6.6.6
23${valid_gateway} 10.6.6.1
24${valid_prefix_len} 24
25${broadcast_ip} 10.6.6.255
26${loopback_ip} 127.0.0.1
27${multicast_ip} 224.6.6.255
28${out_of_range_ip} 10.6.6.256
29
30# There will be 4 octets in IP address (e.g. xx.xx.xx.xx)
31# but trying to configure xx.xx.xx
32
33${less_octet_ip} 10.3.36
34
35# For the address 10.6.6.6, the 10.6.6.0 portion describes the
36# network ID and the 6 describe the host.
37
38${network_id} 10.6.6.0
39${hex_ip} 0xa.0xb.0xc.0xd
Prashanth Katti40fb8ca2017-07-25 06:47:23 -050040${negative_ip} 10.-6.-6.6
Prashanth Katti4cf87bd2017-06-28 08:56:02 -050041
Prashanth Kattie79c5402017-06-08 07:40:49 -050042*** Test Cases ***
43
44Get BMC IPv4 Address And Verify
45 [Documentation] Get BMC IPv4 address and verify.
46 [Tags] Get_BMC_IPv4_Address_And_Verify
47
48 :FOR ${ipv4_uri} IN @{IPv4_URI_List}
49 \ ${ipv4_addr}= Read Attribute ${ipv4_uri} Address
50 \ Validate IP on BMC ${ipv4_addr}
51
52Verify IPv4 Prefix Length
53 [Documentation] Get prefix length and verify.
54 [Tags] Verify_IPv4_Prefix_Length
55
56 :FOR ${ipv4_uri} IN @{IPv4_URI_List}
57 \ ${prefix_length}= Read Attribute ${ipv4_uri} PrefixLength
58 \ Validate Prefix Length On BMC ${prefix_length}
59
60Verify Gateway Address
61 [Documentation] Get gateway address and verify.
62 [Tags] Verify_Gateway_Address
63
64 :FOR ${ipv4_uri} IN @{IPv4_URI_List}
Prashanth Katti4cf87bd2017-06-28 08:56:02 -050065 \ ${gateway_ip}= Read Attribute ${ipv4_uri} Gateway
66 \ Validate Route On BMC ${gateway_ip}
Prashanth Kattie79c5402017-06-08 07:40:49 -050067
68Verify MAC Address
69 [Documentation] Get MAC address and verify.
70 [Tags] Verify_MAC_Address
71 ${macaddr}= Read Attribute ${XYZ_NETWORK_MANAGER}/eth0 MACAddress
72 Validate MAC On BMC ${macaddr}
73
Prashanth Katti4cf87bd2017-06-28 08:56:02 -050074Add New Valid IP And Verify
75 [Documentation] Add new IP address and verify.
76 [Tags] Add_New_Valid_IP_And_Verify
77
78 Configure Network Settings ${valid_ip} ${valid_prefix_len}
79 ... ${valid_gateway} valid
80
81 # Verify whether new IP address is populated on BMC system.
82 ${ip_info}= Get BMC IP Info
83 Validate IP On BMC ${valid_ip} ${ip_info}
84
85Configure Invalid IP String
86 # IP Address Prefix_length Gateway_IP Expected_Result
87 ${alpha_ip} ${valid_prefix_len} ${valid_gateway} error
88
89 [Documentation] Configure invalid IP address which is a string.
90 [Tags] Configure_Invalid_IP_String
91
Prashanth Katti40fb8ca2017-07-25 06:47:23 -050092 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -050093
94Configure Out Of Range IP
95 # IP Address Prefix_length Gateway_IP Expected_Result
96 ${out_of_range_ip} ${valid_prefix_len} ${valid_gateway} error
97
Prashanth Katti388bdc72017-07-19 08:54:58 -050098 [Documentation] Configure out-of-range IP address.
Prashanth Katti4cf87bd2017-06-28 08:56:02 -050099 [Tags] Configure_Out_Of_Range_IP
100
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500101 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500102
103Configure Broadcast IP
104 # IP Address Prefix_length Gateway_IP Expected_Result
105 ${broadcast_ip} ${valid_prefix_len} ${valid_gateway} error
106
107 [Documentation] Configure broadcast IP address.
108 [Tags] Configure_Broadcast_IP
109
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500110 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500111
112Configure Multicast IP
113 # IP Address Prefix_length Gateway_IP Expected_Result
114 ${multicast_ip} ${valid_prefix_len} ${valid_gateway} error
115
116 [Documentation] Configure multicast IP address.
117 [Tags] Configure_Multicast_IP
118
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500119 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500120
121Configure Loopback IP
122 # IP Address Prefix_length Gateway_IP Expected_Result
123 ${loopback_ip} ${valid_prefix_len} ${valid_gateway} error
124
125 [Documentation] Configure loopback IP address.
126 [Tags] Configure_Loopback_IP
127
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500128 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500129
130Configure Network ID
131 # IP Address Prefix_length Gateway_IP Expected_Result
132 ${network_id} ${valid_prefix_len} ${valid_gateway} error
133
134 [Documentation] Configure network ID IP address.
135 [Tags] Configure_Network_ID
136
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500137 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500138
139Configure Less Octet IP
140 # IP Address Prefix_length Gateway_IP Expected_Result
141 ${less_octet_ip} ${valid_prefix_len} ${valid_gateway} error
142
143 [Documentation] Configure less octet IP address.
144 [Tags] Configure_Less_Octet_IP
145
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500146 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500147
148Configure Empty IP
149 # IP Address Prefix_length Gateway_IP Expected_Result
150 ${EMPTY} ${valid_prefix_len} ${valid_gateway} error
151
152 [Documentation] Configure less octet IP address.
153 [Tags] Configure_Empty_IP
154
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500155 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500156
157Configure Special Char IP
158 # IP Address Prefix_length Gateway_IP Expected_Result
159 @@@.%%.44.11 ${valid_prefix_len} ${valid_gateway} error
160
161 [Documentation] Configure invalid IP address contaning special chars.
162 [Tags] Configure_Special_Char_IP
163
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500164 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500165
166Configure Hexadecimal IP
167 # IP Address Prefix_length Gateway_IP Expected_Result
168 ${hex_ip} ${valid_prefix_len} ${valid_gateway} error
169
170 [Documentation] Configure invalid IP address contaning hex value.
171 [Tags] Configure_Hexadecimal_IP
172
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500173 [Template] Configure Network Settings
174
175Configure Negative Octet IP
176 # IP Address Prefix_length Gateway_IP Expected_Result
177 ${negative_ip} ${valid_prefix_len} ${valid_gateway} error
178
179 [Documentation] Configure invalid IP address containing negative octet.
180 [Tags] Configure_Negative_Octet_IP
181
182 [Template] Configure Network Settings
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500183
Prashanth Katti388bdc72017-07-19 08:54:58 -0500184Add New Valid IP With Blank Gateway
185 [Documentation] Add new IP with blank gateway.
186 [Tags] Add_New_Valid_IP_With_Blank_Gateway
187
188 Configure Network Settings ${valid_ip} ${valid_prefix_len} ${EMPTY}
189 ... valid
190
191 # Verify whether new IP address is populated on BMC system.
192 ${ip_info}= Get BMC IP Info
193 Validate IP On BMC ${valid_ip} ${ip_info}
194
195Configure Invalid Gateway String
196 # IP Address Prefix_length Gateway_IP Expected_Result
197 ${valid_ip} ${valid_prefix_len} ${alpha_ip} error
198
199 [Documentation] Configure invalid IP address to a gateway which is
200 ... an alpha string and expect an error.
201 [Tags] Configure_Invalid_Gateway_String
202
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500203 [Template] Configure Network Settings
Prashanth Katti388bdc72017-07-19 08:54:58 -0500204
205Configure Out Of Range IP For Gateway
206 # IP Address Prefix_length Gateway_IP Expected_Result
207 ${valid_ip} ${valid_prefix_len} ${out_of_range_ip} error
208
209 [Documentation] Configure out-of-range IP for gateway and expect an error.
210 [Tags] Configure_Out_Of_Range_IP_For_Gateway
211
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500212 [Template] Configure Network Settings
Prashanth Katti388bdc72017-07-19 08:54:58 -0500213
214Configure Broadcast IP For Gateway
215 # IP Address Prefix_length Gateway_IP Expected_Result
216 ${valid_ip} ${valid_prefix_len} ${broadcast_ip} error
217
218 [Documentation] Configure broadcast IP for gateway and expect an error.
219 [Tags] Configure_Broadcast_IP_For_Gateway
220
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500221 [Template] Configure Network Settings
Prashanth Katti388bdc72017-07-19 08:54:58 -0500222
223Configure Loopback IP For Gateway
224 # IP Address Prefix_length Gateway_IP Expected_Result
225 ${valid_ip} ${valid_prefix_len} ${loopback_ip} error
226
227 [Documentation] Configure loopback IP for gateway and expect an error.
228 [Tags] Configure_Loopback_IP_For_Gateway
229
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500230 [Template] Configure Network Settings
Prashanth Katti388bdc72017-07-19 08:54:58 -0500231
232Configure Multicast IP For Gateway
233 # IP Address Prefix_length Gateway_IP Expected_Result
234 ${valid_ip} ${valid_prefix_len} ${multicast_ip} error
235
236 [Documentation] Configure multicast IP for gateway and expect an error.
237 [Tags] Configure_Multicast_IP_For_Gateway
238
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500239 [Template] Configure Network Settings
Prashanth Katti388bdc72017-07-19 08:54:58 -0500240
241Configure Network ID For Gateway
242 # IP Address Prefix_length Gateway_IP Expected_Result
243 ${valid_ip} ${valid_prefix_len} ${network_id} error
244
245 [Documentation] Configure network ID for gateway and expect an error.
246 [Tags] Configure_Network_ID_For_Gateway
247
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500248 [Template] Configure Network Settings
Prashanth Katti388bdc72017-07-19 08:54:58 -0500249
250Configure Less Octet IP For Gateway
251 # IP Address Prefix_length Gateway_IP Expected_Result
252 ${valid_ip} ${valid_prefix_len} ${less_octet_ip} error
253
254 [Documentation] Configure less octet IP for gateway and expect an error.
255 [Tags] Configure_Less_Octet_IP_For_Gateway
256
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500257 [Template] Configure Network Settings
Prashanth Katti388bdc72017-07-19 08:54:58 -0500258
259Configure Special Char IP For Gateway
260 # IP Address Prefix_length Gateway_IP Expected_Result
261 ${valid_ip} ${valid_prefix_len} @@@.%%.44.11 error
262
263 [Documentation] Configure special char IP for gateway and expect an error.
264 [Tags] Configure_Special_Char_IP_For_Gateway
265
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500266 [Template] Configure Network Settings
Prashanth Katti388bdc72017-07-19 08:54:58 -0500267
268Configure Hexadecimal IP For Gateway
269 # IP Address Prefix_length Gateway_IP Expected_Result
270 ${valid_ip} ${valid_prefix_len} ${hex_ip} error
271
272 [Documentation] Configure hexadecimal IP for gateway and expect an error.
273 [Tags] Configure_Hexadecimal_IP_For_Gateway
274
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500275 [Template] Configure Network Settings
276
277Configure Out Of Range Prefix Length
278 # IP Address Prefix_length Gateway_IP Expected_Result
279 ${valid_ip} 33 ${hex_ip} error
280
281 [Documentation] Configure out-of-range prefix length and expect an error.
282 [Tags] Configure_Out_Of_Range_Prefix_Length
283
284 [Template] Configure Network Settings
285
286Configure Negative Value For Prefix Length
287 # IP Address Prefix_length Gateway_IP Expected_Result
288 ${valid_ip} -10 ${hex_ip} error
289
290 [Documentation] Configure negative prefix length and expect an error.
291 [Tags] Configure_Negative_Value_For_Prefix_Length
292
293 [Template] Configure Network Settings
294
295Configure Non Numeric Value For Prefix Length
296 # IP Address Prefix_length Gateway_IP Expected_Result
297 ${valid_ip} xx ${hex_ip} error
298
299 [Documentation] Configure non numeric value prefix length and expect
300 ... an error.
301 [Tags] Configure_String_Value_For_Prefix_Length
302
303 [Template] Configure Network Settings
304
305Add Fourth Octet Threshold IP And Verify
306 [Documentation] Add fourth octet threshold IP and verify.
307 [Tags] Add_Fourth_Octet_Threshold_IP_And_Verify
308
309 Configure Network Settings 10.6.6.254 ${valid_prefix_len}
310 ... ${valid_gateway} valid
311
312 # Verify whether new IP address is populated on BMC system.
313 ${ip_info}= Get BMC IP Info
314 Validate IP On BMC 10.6.6.254 ${ip_info}
315
316Add Third Octet Threshold IP And Verify
317 [Documentation] Add third octet threshold IP and verify.
318 [Tags] Add_Third_Octet_Threshold_IP_And_Verify
319
320 Configure Network Settings 10.6.255.6 ${valid_prefix_len}
321 ... ${valid_gateway} valid
322
323 # Verify whether new IP address is populated on BMC system.
324 ${ip_info}= Get BMC IP Info
325 Validate IP On BMC 10.6.255.6 ${ip_info}
326
327Add Second Octet Threshold IP And Verify
328 [Documentation] Add second octet threshold IP and verify.
329 [Tags] Add_Second_Octet_Threshold_IP_And_Verify
330
331 Configure Network Settings 10.255.6.6 ${valid_prefix_len}
332 ... ${valid_gateway} valid
333
334 # Verify whether new IP address is populated on BMC system.
335 ${ip_info}= Get BMC IP Info
336 Validate IP On BMC 10.255.6.6 ${ip_info}
337
338Add First Octet Threshold IP And Verify
339 [Documentation] Add first octet threshold IP and verify.
340 [Tags] Add_First_Octet_Threshold_IP_And_Verify
341
342 Configure Network Settings 223.6.6.6 ${valid_prefix_len}
343 ... ${valid_gateway} valid
344
345 # Verify whether new IP address is populated on BMC system.
346 ${ip_info}= Get BMC IP Info
347 Validate IP On BMC 223.6.6.6 ${ip_info}
348
349Verify Default Gateway
350 [Documentation] Verify default gateway.
351 [Tags] Verify that the default gateway has a valid route.
352
353 ${default_gw}= Read Attribute ${XYZ_NETWORK_MANAGER}/config
354 ... DefaultGateway
355 Validate Route On BMC ${default_gw}
356
357Verify Hostname
358 [Documentation] Verify that the hostname read via REST is the same as the
359 ... hostname configured on system.
360 [Tags] Verify_Hostname
361
362 ${hostname}= Read Attribute ${XYZ_NETWORK_MANAGER}/config HostName
363 Validate Hostname On BMC ${hostname}
Prashanth Katti388bdc72017-07-19 08:54:58 -0500364
Prashanth Kattie79c5402017-06-08 07:40:49 -0500365*** Keywords ***
366
367Test Init Setup
368 [Documentation] Network setup.
369 Open Connection And Login
370
371 @{IPv4_URI_List}= Get IPv4 URI List
372 Set Test Variable @{IPv4_URI_List}
373
374 # Get BMC IP address and prefix length.
375 ${ip_data}= Get BMC IP Info
376 Set Test Variable ${ip_data}
377
378Get IPv4 URI List
379 [Documentation] Get all IPv4 URIs.
380
381 # Sample output:
382 # "data": [
383 # "/xyz/openbmc_project/network/eth0/ipv4/e9767624",
384 # "/xyz/openbmc_project/network/eth0/ipv4/31f4ce8b"
385 # ],
386
387 @{ipv4_uri_list}= Read Properties ${XYZ_NETWORK_MANAGER}/eth0/ipv4/
388 Should Not Be Empty ${ipv4_uri_list} msg=IPv4 URI list is empty.
389
390 [Return] @{ipv4_uri_list}
391
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500392Validate IP On BMC
Prashanth Kattie79c5402017-06-08 07:40:49 -0500393 [Documentation] Validate IP on BMC.
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500394 [Arguments] ${ip_address} ${ip_info}=${ip_data}
Prashanth Kattie79c5402017-06-08 07:40:49 -0500395
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500396 # Description of argument(s):
Prashanth Kattie79c5402017-06-08 07:40:49 -0500397 # ip_address IP address of the system.
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500398 # ip_info List of IP address and prefix length values.
Prashanth Kattie79c5402017-06-08 07:40:49 -0500399
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500400 Should Contain Match ${ip_info} ${ip_address}*
Prashanth Kattie79c5402017-06-08 07:40:49 -0500401 ... msg=IP address does not exist.
402
403Validate Prefix Length On BMC
404 [Documentation] Validate prefix length on BMC.
405 [Arguments] ${prefix_length}
406
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500407 # Description of argument(s):
Prashanth Kattie79c5402017-06-08 07:40:49 -0500408 # prefix_length It indicates netmask, netmask value 255.255.255.0
409 # is equal to prefix length 24.
410 # ip_data Suite variable which has list of IP address and
411 # prefix length values.
412
413 Should Contain Match ${ip_data} */${prefix_length}
414 ... msg=Prefix length does not exist.
415
416Validate Route On BMC
417 [Documentation] Validate route.
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500418 [Arguments] ${gateway_ip}
Prashanth Kattie79c5402017-06-08 07:40:49 -0500419
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500420 # Description of argument(s):
421 # gateway_ip Gateway IP address.
Prashanth Kattie79c5402017-06-08 07:40:49 -0500422
423 ${route_info}= Get BMC Route Info
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500424 Should Contain ${route_info} ${gateway_ip}
Prashanth Kattie79c5402017-06-08 07:40:49 -0500425 ... msg=Gateway IP address not matching.
426
427Validate MAC on BMC
428 [Documentation] Validate MAC on BMC.
429 [Arguments] ${macaddr}
430
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500431 # Description of argument(s):
Prashanth Kattie79c5402017-06-08 07:40:49 -0500432 # macaddr MAC address of the BMC.
433
434 ${system_mac}= Get BMC MAC Address
435
436 Should Contain ${system_mac} ${macaddr}
437 ... ignore_case=True msg=MAC address does not exist.
Prashanth Katti4cf87bd2017-06-28 08:56:02 -0500438
439Configure Network Settings
440 [Documentation] Configure network settings.
441 [Arguments] ${ip_addr} ${prefix_len} ${gateway_ip} ${expected_result}
442
443 # Description of argument(s):
444 # ip_addr IP address of BMC.
445 # prefix_len Prefix length.
446 # gateway_ip Gateway IP address.
447 # expected_result Expected status of network setting configuration.
448
449 ${len}= Convert To Bytes ${prefix_len}
450
451 @{ip_parm_list}= Create List xyz.openbmc_project.Network.IP.Protocol.IPv4
452 ... ${ip_addr} ${len} ${gateway_ip}
453
454 ${data}= Create Dictionary data=@{ip_parm_list}
455 ${resp}= OpenBMC Post Request
456 ... ${XYZ_NETWORK_MANAGER}/eth0/action/IP data=${data}
457 ${json}= To JSON ${resp.content}
458
459 Run Keyword If '${expected_result}' == 'error' Run Keywords
460 ... Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK}
461 ... AND Should Be Equal As Strings ${json['status']} ${expected_result}
462 ... ELSE
463 ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Prashanth Katti40fb8ca2017-07-25 06:47:23 -0500464
465Validate Hostname On BMC
466 [Documentation] Verify that the hostname read via REST is the same as the
467 ... hostname configured on system.
468 [Arguments] ${hostname}
469
470 # Description of argument(s):
471 # hostname A hostname value which is to be compared to the hostname
472 # configured on system.
473
474 ${sys_hostname}= Get BMC Hostname
475
476 Should Contain ${sys_hostname} ${hostname}
477 ... ignore_case=True msg=Hostname does not exist.