blob: 74e83376388ab3deeadb8bb9015316d6d749d001 [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
Gunnar Millseac1af22016-11-14 15:30:09 -060012Test Teardown FFDC On Test Case Fail
Rahul Maheshwari01413692016-09-05 21:35:24 -050013
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}
George Keishing0fd3b242016-11-24 09:01:41 -060044 run keyword and ignore error
45 ... Call Method
46 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetAddress4 data=${args}
Rahul Maheshwari01413692016-09-05 21:35:24 -050047
48 Wait For Host To Ping ${NEW_IP}
49 Set Suite Variable ${AUTH_URI} https://${NEW_IP}
50 Log ${AUTH_URI}
51
52 ${networkInfo}= Get networkInfo from the interface eth0
53 ${ipaddress}= set variable ${networkInfo['data'][2]}
54 ${gateway}= set variable ${networkInfo['data'][3]}
55
Gunnar Mills597ffa02016-12-06 11:26:53 -060056 ${isgatewayfound}= Set Variable If '${gateway}'=='${NEW_GATEWAY}' true false
Rahul Maheshwari01413692016-09-05 21:35:24 -050057 Log ${isgatewayfound}
58 ${isIPfound}= Set Variable if '${ipaddress}' == '${NEW_IP}' true false
59 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
60
61
62Revert the last ip address change
63 [Tags] network_test
64 [Documentation] This test case sets the ip on the interface and validates
65 ... that ip address has been set or not.
66 ... Expectation is the ip address should get added.
67
68
69 ${arglist}= Create List eth0 ${OLD_IP} ${OLD_MASK} ${OLD_GATEWAY}
70 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -060071 run keyword and ignore error
72 ... Call Method
73 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetAddress4 data=${args}
Rahul Maheshwari01413692016-09-05 21:35:24 -050074
75 Wait For Host To Ping ${OLD_IP}
76 Set Suite Variable ${AUTH_URI} https://${OLD_IP}
77 Log ${AUTH_URI}
78
79
80 ${networkInfo}= Get networkInfo from the interface eth0
81 ${ipaddress}= set variable ${networkInfo['data'][2]}
82 ${gateway}= set variable ${networkInfo['data'][3]}
83
Gunnar Mills597ffa02016-12-06 11:26:53 -060084 ${isgatewayfound}= Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
Rahul Maheshwari01413692016-09-05 21:35:24 -050085 Log ${isgatewayfound}
86 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
87 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
88
89
90Persistency check for ip address
91 [Tags] reboot_test
92 [Documentation] we reboot the service processor and after reboot
93 ... will request for the ip address to check the persistency
94 ... of the ip address.
95 ... Expectation is the ip address should persist.
96
97 Open Connection And Log In
98 Execute Command reboot
99 Log "System is getting rebooted wait for few seconds"
100 ${networkInfo}= Get networkInfo from the interface eth0
101 ${ipaddress}= set variable ${networkInfo['data'][2]}
102 ${gateway}= set variable ${networkInfo['data'][3]}
103
Gunnar Mills597ffa02016-12-06 11:26:53 -0600104 ${isgatewayfound}= Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
Rahul Maheshwari01413692016-09-05 21:35:24 -0500105 Log ${isgatewayfound}
106 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
107 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
108
109
George Keishingf2f5f3b2016-09-28 10:55:11 -0500110Set invalid Mac address eth0 gg:hh:jj:kk:ll:mm error
111 [Tags] network_test Set_invalid_Mac_address
112 [Template] SetMacAddress_bad
113 [Documentation] This test case tries to set the invalid mac address
114 ... on the eth0 interface.
115 ... Expectation is that it should throw error.
116
117
118Set valid Mac address eth0 00:21:cc:73:91:dd ok
119 [Tags] network_test Set_valid_Mac_address
120 [Template] SetMacAddress_good
121 [Documentation] ***GOOD PATH***
122 ... This test case add the ip addresson the interface and validates
123 ... that ip address has been added or not.
124 ... Expectation is the ip address should get added.
125
126Revert old Mac address eth0 ${OLD_MAC_ADDRESS} ok
127 [Tags] network_test Revert_old_Mac_address
128 [Template] SetMacAddress_good
129 [Documentation] ***GOOD PATH***
130 ... This test case add the ip addresson the interface and validates
131 ... that ip address has been added or not.
132 ... Expectation is the ip address should get added.
133
Gunnar Mills7c8923f2016-12-12 21:19:52 -0600134*** Keywords ***
Rahul Maheshwari01413692016-09-05 21:35:24 -0500135
136Get networkInfo from the interface
137
138 [Documentation] This keyword is used to match the given ip with the configured one.
139 ... returns true if match successfull else false
140 ... eg:- Outout of getAddress4
141 ... NewFormat:-{"data": [ 2,25,"9.3.164.147","9.3.164.129"],"message": "200 OK","status": "ok"}
142 ... OldFormat:-
143 ... {"data": [[[2,25,0,128,"9.3.164.177"],[2,8,254,128,"127.0.0.1"]],"9.3.164.129"],
144 ... "message": "200 OK", "status": "ok"}
145
Gunnar Mills38032802016-12-12 13:43:40 -0600146 [Arguments] ${intf}
Rahul Maheshwari01413692016-09-05 21:35:24 -0500147 @{arglist}= Create List ${intf}
148 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -0600149 ${resp}= Call Method
150 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ GetAddress4 data=${args}
Rahul Maheshwari01413692016-09-05 21:35:24 -0500151 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills597ffa02016-12-06 11:26:53 -0600152 ${json}= to json ${resp.content}
Rahul Maheshwari01413692016-09-05 21:35:24 -0500153 Log ${json['data'][2]}
154 Log ${json['data'][3]}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600155 [Return] ${json}
Rahul Maheshwari01413692016-09-05 21:35:24 -0500156
157
158validateEnvVariables
159
160 ${NEW_BMC_IP}= Get Environment Variable NEW_BMC_IP
161 ${NEW_SUBNET_MASK}= Get Environment Variable NEW_SUBNET_MASK
162 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
163
164
165 should not be empty ${NEW_BMC_IP}
166 should not be empty ${NEW_GATEWAY}
167 should not be empty ${NEW_SUBNET_MASK}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500168
169SetMacAddress_bad
170 [Arguments] ${intf} ${address} ${result}
171 ${arglist}= Create List ${intf} ${address}
172 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -0600173 ${resp}= Call Method
174 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetHwAddress data=${args}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500175 should not be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills597ffa02016-12-06 11:26:53 -0600176 ${json}= to json ${resp.content}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500177 should be equal as strings ${json['status']} ${result}
178
179
180SetMacAddress_good
181 [Arguments] ${intf} ${address} ${result}
182 ${arglist}= Create List ${intf} ${address}
183 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -0600184 ${resp}= Call Method
185 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetHwAddress data=${args}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500186 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills597ffa02016-12-06 11:26:53 -0600187 ${json}= to json ${resp.content}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500188 should be equal as strings ${json['status']} ${result}
189 Wait For Host To Ping ${OPENBMC_HOST}
190
191 Wait Until Keyword Succeeds 30 sec 5 sec Initialize OpenBMC
192
193 @{arglist}= Create List ${intf}
194 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -0600195 ${resp}= Call Method
196 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ GetHwAddress data=${args}
Gunnar Mills597ffa02016-12-06 11:26:53 -0600197 ${json}= to json ${resp.content}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500198 should be equal as strings ${json['data']} ${address}