blob: 555e5c9041084816cf9371dca095230c68e9a201 [file] [log] [blame]
Rahul Maheshwari01413692016-09-05 21:35:24 -05001*** Settings ***
2Documentation This suite will test extended Network Configuration Rest Interfaces
3
4Resource ../lib/rest_client.robot
5Resource ../lib/connection_client.robot
6Resource ../lib/utils.robot
7Resource ../lib/openbmc_ffdc.robot
8Library ../lib/pythonutil.py
9
10Suite Setup Open Connection And Log In
11Suite Teardown Close All Connections
12Test Teardown Log FFDC
13
14*** Test Cases ***
15
16Set IP address on valid Interface
17 [Tags] network_test
18 [Documentation] This test case sets the ip on the interface and validates
19 ... that ip address has been set or not.
20 ... Expectation is the ip address should get added.
21
22 validateEnvVariables
23
24
25 ${networkInfo}= Get networkInfo from the interface eth0
26 ${result}= convert to integer ${networkInfo['data'][1]}
27
28 ${MASK}= calcDottedNetmask ${result}
29 set suite variable ${OLD_MASK} ${MASK}
30 Log ${OLD_MASK}
31 set suite variable ${OLD_IP} ${networkInfo['data'][2]}
32 set suite variable ${OLD_GATEWAY} ${networkInfo['data'][3]}
33
34 Log ${OLD_IP}
35 Log ${OLD_GATEWAY}
36
37
38 ${NEW_IP}= Get Environment Variable NEW_BMC_IP
39 ${NEW_MASK}= Get Environment Variable NEW_SUBNET_MASK
40 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
41
42 ${arglist}= Create List eth0 ${NEW_IP} ${NEW_MASK} ${NEW_GATEWAY}
43 ${args}= Create Dictionary data=@{arglist}
44 run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
45
46 Wait For Host To Ping ${NEW_IP}
47 Set Suite Variable ${AUTH_URI} https://${NEW_IP}
48 Log ${AUTH_URI}
49
50 ${networkInfo}= Get networkInfo from the interface eth0
51 ${ipaddress}= set variable ${networkInfo['data'][2]}
52 ${gateway}= set variable ${networkInfo['data'][3]}
53
54 ${isgatewayfound} = Set Variable If '${gateway}'=='${NEW_GATEWAY}' true false
55 Log ${isgatewayfound}
56 ${isIPfound}= Set Variable if '${ipaddress}' == '${NEW_IP}' true false
57 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
58
59
60Revert the last ip address change
61 [Tags] network_test
62 [Documentation] This test case sets the ip on the interface and validates
63 ... that ip address has been set or not.
64 ... Expectation is the ip address should get added.
65
66
67 ${arglist}= Create List eth0 ${OLD_IP} ${OLD_MASK} ${OLD_GATEWAY}
68 ${args}= Create Dictionary data=@{arglist}
69 run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args}
70
71 Wait For Host To Ping ${OLD_IP}
72 Set Suite Variable ${AUTH_URI} https://${OLD_IP}
73 Log ${AUTH_URI}
74
75
76 ${networkInfo}= Get networkInfo from the interface eth0
77 ${ipaddress}= set variable ${networkInfo['data'][2]}
78 ${gateway}= set variable ${networkInfo['data'][3]}
79
80 ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
81 Log ${isgatewayfound}
82 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
83 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
84
85
86Persistency check for ip address
87 [Tags] reboot_test
88 [Documentation] we reboot the service processor and after reboot
89 ... will request for the ip address to check the persistency
90 ... of the ip address.
91 ... Expectation is the ip address should persist.
92
93 Open Connection And Log In
94 Execute Command reboot
95 Log "System is getting rebooted wait for few seconds"
96 ${networkInfo}= Get networkInfo from the interface eth0
97 ${ipaddress}= set variable ${networkInfo['data'][2]}
98 ${gateway}= set variable ${networkInfo['data'][3]}
99
100 ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
101 Log ${isgatewayfound}
102 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
103 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
104
105
George Keishingf2f5f3b2016-09-28 10:55:11 -0500106Set invalid Mac address eth0 gg:hh:jj:kk:ll:mm error
107 [Tags] network_test Set_invalid_Mac_address
108 [Template] SetMacAddress_bad
109 [Documentation] This test case tries to set the invalid mac address
110 ... on the eth0 interface.
111 ... Expectation is that it should throw error.
112
113
114Set valid Mac address eth0 00:21:cc:73:91:dd ok
115 [Tags] network_test Set_valid_Mac_address
116 [Template] SetMacAddress_good
117 [Documentation] ***GOOD PATH***
118 ... This test case add the ip addresson the interface and validates
119 ... that ip address has been added or not.
120 ... Expectation is the ip address should get added.
121
122Revert old Mac address eth0 ${OLD_MAC_ADDRESS} ok
123 [Tags] network_test Revert_old_Mac_address
124 [Template] SetMacAddress_good
125 [Documentation] ***GOOD PATH***
126 ... This test case add the ip addresson the interface and validates
127 ... that ip address has been added or not.
128 ... Expectation is the ip address should get added.
129
Rahul Maheshwari01413692016-09-05 21:35:24 -0500130***keywords***
131
132Get networkInfo from the interface
133
134 [Documentation] This keyword is used to match the given ip with the configured one.
135 ... returns true if match successfull else false
136 ... eg:- Outout of getAddress4
137 ... NewFormat:-{"data": [ 2,25,"9.3.164.147","9.3.164.129"],"message": "200 OK","status": "ok"}
138 ... OldFormat:-
139 ... {"data": [[[2,25,0,128,"9.3.164.177"],[2,8,254,128,"127.0.0.1"]],"9.3.164.129"],
140 ... "message": "200 OK", "status": "ok"}
141
142 [arguments] ${intf}
143 @{arglist}= Create List ${intf}
144 ${args}= Create Dictionary data=@{arglist}
145 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args}
146 should be equal as strings ${resp.status_code} ${HTTP_OK}
147 ${json} = to json ${resp.content}
148 Log ${json['data'][2]}
149 Log ${json['data'][3]}
150 [return] ${json}
151
152
153validateEnvVariables
154
155 ${NEW_BMC_IP}= Get Environment Variable NEW_BMC_IP
156 ${NEW_SUBNET_MASK}= Get Environment Variable NEW_SUBNET_MASK
157 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
158
159
160 should not be empty ${NEW_BMC_IP}
161 should not be empty ${NEW_GATEWAY}
162 should not be empty ${NEW_SUBNET_MASK}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500163
164SetMacAddress_bad
165 [Arguments] ${intf} ${address} ${result}
166 ${arglist}= Create List ${intf} ${address}
167 ${args}= Create Dictionary data=@{arglist}
168 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetHwAddress data=${args}
169 should not be equal as strings ${resp.status_code} ${HTTP_OK}
170 ${json} = to json ${resp.content}
171 should be equal as strings ${json['status']} ${result}
172
173
174SetMacAddress_good
175 [Arguments] ${intf} ${address} ${result}
176 ${arglist}= Create List ${intf} ${address}
177 ${args}= Create Dictionary data=@{arglist}
178 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetHwAddress data=${args}
179 should be equal as strings ${resp.status_code} ${HTTP_OK}
180 ${json} = to json ${resp.content}
181 should be equal as strings ${json['status']} ${result}
182 Wait For Host To Ping ${OPENBMC_HOST}
183
184 Wait Until Keyword Succeeds 30 sec 5 sec Initialize OpenBMC
185
186 @{arglist}= Create List ${intf}
187 ${args}= Create Dictionary data=@{arglist}
188 ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetHwAddress data=${args}
189 ${json} = to json ${resp.content}
190 should be equal as strings ${json['data']} ${address}