blob: 3ad5a95846935360a162d26851d025d8383df8dd [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
Gunnar Mills56b32892016-11-14 13:56:17 -06002Documentation 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
Chris Austenb29d2e82016-06-07 12:25:35 -05005
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
Gunnar Millseac1af22016-11-14 15:30:09 -060014Test Teardown FFDC On Test Case Fail
Chris Austenb29d2e82016-06-07 12:25:35 -050015
George Keishing8f7c1fa2017-03-06 06:17:47 -060016Force Tags NetworkManager
17
George Keishingab1bd922016-12-05 05:29:59 -060018*** Variables ***
19
20${NW_MANAGER} ${NETWORK_MANAGER_URI}Interface
21
George Keishing4d6c1da2016-07-15 05:51:22 -050022*** Test Cases ***
Chris Austenb29d2e82016-06-07 12:25:35 -050023
24Get the Mac address
25
26 [Documentation] This test case is to get the mac address
27 [Tags] network_test
28 @{arglist}= Create List eth0
29 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -060030 ${resp}= Call Method ${NW_MANAGER} GetHwAddress data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050031 should not be empty ${resp.content}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060032 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -050033 should be equal as strings ${json['status']} ok
George Keishing06ae4aa2016-08-30 01:41:28 -050034 set suite variable ${OLD_MAC_ADDRESS} ${json['data']}
Chris Austenb29d2e82016-06-07 12:25:35 -050035
36
37Get IP Address with invalid interface
38
39 [Documentation] This test case tries to get the ip addrees with the invalid
40 ... interface,Expectation is it should get error.
41 [Tags] network_test
42
43 @{arglist}= Create List lo01
44 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -060045 ${resp}= Call Method ${NW_MANAGER} GetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050046 should not be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060047 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -050048 should be equal as strings ${json['status']} error
49
50Get IP Address with valid interface
51
52 [Documentation] This test case tries to get the ip addrees with the invalid
53 ... interface,Expectation is it should get error.
54 [Tags] network_test
55
56 @{arglist}= Create List eth0
57 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -060058 ${resp}= Call Method ${NW_MANAGER} GetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050059 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060060 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -050061 should be equal as strings ${json['status']} ok
62
63
64Set the IP address on invalid Interface lo01 1.1.1.1 255.255.255.0 1.1.1.1 error
65
66 [Tags] network_test
67 [Template] AddNetworkInfo
68 [Documentation] This test case tries to set the ip addrees with the invalid
69 ... interface,Expectation is it should get error
70
71Set invalid IP address on the valid interface eth0 ab.cd.ef.gh 255.255.255.0 1.1.1.1 error
72
73 [Tags] network_test
74 [Template] AddNetworkInfo
75 [Documentation] This test case tries to set the invalid ip addrees on the interface
76 ... Expectation is it should get error.
77
78
79Set IP address with invalid subnet mask eth0 2.2.2.2 av.ih.jk.lm 1.1.1.1 error
80
81 [Tags] network_test
82 [Template] AddNetworkInfo
83 [Documentation] This test case tries to set the ip addrees on the interface
84 ... with invalid subnet mask,Expectation is it should get error.
85
86Set empty IP address eth0 ${EMPTY} 255.255.255.0 1.1.1.1 error
87
88 [Tags] network_test
89 [Template] AddNetworkInfo
90 [Documentation] This test case tries to set the NULL ip addrees on the interface
91 ... Expectation is it should get error.
92
93Set empty subnet mask eth0 2.2.2.2 ${EMPTY} 1.1.1.1 error
94
95 [Tags] network_test
96 [Template] AddNetworkInfo
97 [Documentation] This test case tries to set the ip addrees on the interface
98 ... with empty subnet mask,Expectation is it should get error.
99
100Set empty gateway eth0 2.2.2.2 255.255.255.0 ${EMPTY} error
101
102 [Tags] network_test
103 [Template] AddNetworkInfo
104 [Documentation] This test case tries to set the ip addrees on the interface
105 ... with empty gateway,Expectation is it should get error.
106
107
Chris Austenb29d2e82016-06-07 12:25:35 -0500108Get IP Address type
109 [Tags] GOOD-PATH
George Keishing06ae4aa2016-08-30 01:41:28 -0500110 [Documentation] This test case tries to set existing ipaddress address and
111 ... later tries to verify that ip address type is set to static
Chris Austenb29d2e82016-06-07 12:25:35 -0500112 ... due to the operation.
113
114 ${networkInfo}= Get networkInfo from the interface eth0
115 ${result}= convert to integer ${networkInfo['data'][1]}
116
117 ${CURRENT_MASK}= calcDottedNetmask ${result}
118 ${CURRENT_IP}= set variable ${networkInfo['data'][2]}
119 ${CURRENT_GATEWAY}= set variable ${networkInfo['data'][3]}
120
121 ${arglist}= Create List eth0 ${CURRENT_IP} ${CURRENT_MASK} ${CURRENT_GATEWAY}
122 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -0600123 run keyword and ignore error Call Method ${NW_MANAGER} SetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500124
125 Wait For Host To Ping ${CURRENT_IP}
George Keishing06ae4aa2016-08-30 01:41:28 -0500126
Rahul Maheshwari4f467f32016-09-03 15:02:57 -0500127 Wait Until Keyword Succeeds 30 sec 5 sec Initialize OpenBMC
128
Chris Austenb29d2e82016-06-07 12:25:35 -0500129 @{arglist}= Create List eth0
130 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -0600131 ${resp}= Call Method ${NW_MANAGER} GetAddressType data=${args}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600132 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500133 Should Be Equal ${json['data']} STATIC
134 should be equal as strings ${json['status']} ok
135
Gunnar Mills7c8923f2016-12-12 21:19:52 -0600136*** Keywords ***
Chris Austenb29d2e82016-06-07 12:25:35 -0500137
138Get networkInfo from the interface
139
140 [Documentation] This keyword is used to match the given ip with the configured one.
141 ... returns true if match successfull else false
142 ... eg:- Outout of getAddress4
143 ... NewFormat:-{"data": [ 2,25,"9.3.164.147","9.3.164.129"],"message": "200 OK","status": "ok"}
144 ... OldFormat:-
145 ... {"data": [[[2,25,0,128,"9.3.164.177"],[2,8,254,128,"127.0.0.1"]],"9.3.164.129"],
146 ... "message": "200 OK", "status": "ok"}
147
Gunnar Mills38032802016-12-12 13:43:40 -0600148 [Arguments] ${intf}
Chris Austenb29d2e82016-06-07 12:25:35 -0500149 @{arglist}= Create List ${intf}
150 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -0600151 ${resp}= Call Method ${NW_MANAGER} GetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500152 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600153 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500154 log to console ${json['data'][2]}
155 log to console ${json['data'][3]}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600156 [Return] ${json}
Chris Austenb29d2e82016-06-07 12:25:35 -0500157
158AddNetworkInfo
159 [Arguments] ${intf} ${address} ${mask} ${gateway} ${result}
160
161 ${arglist}= Create List ${intf} ${address} ${mask} ${gateway}
162 ${args}= Create Dictionary data=@{arglist}
George Keishingab1bd922016-12-05 05:29:59 -0600163 ${resp}= Call Method ${NW_MANAGER} SetAddress4 data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500164 should not be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600165 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500166 should be equal as strings ${json['status']} ${result}