blob: b228aa4f2ab462a7ecfcb15ec2bd1acb101b7d15 [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
Sweta Potthurib2c50f12017-06-28 03:53:30 -050014Force Tags Networkd_Ext
15
Rahul Maheshwari01413692016-09-05 21:35:24 -050016*** Test Cases ***
17
18Set IP address on valid Interface
19 [Tags] network_test
20 [Documentation] This test case sets the ip on the interface and validates
21 ... that ip address has been set or not.
22 ... Expectation is the ip address should get added.
23
24 validateEnvVariables
25
26
27 ${networkInfo}= Get networkInfo from the interface eth0
28 ${result}= convert to integer ${networkInfo['data'][1]}
29
30 ${MASK}= calcDottedNetmask ${result}
31 set suite variable ${OLD_MASK} ${MASK}
32 Log ${OLD_MASK}
33 set suite variable ${OLD_IP} ${networkInfo['data'][2]}
34 set suite variable ${OLD_GATEWAY} ${networkInfo['data'][3]}
35
36 Log ${OLD_IP}
37 Log ${OLD_GATEWAY}
38
39
40 ${NEW_IP}= Get Environment Variable NEW_BMC_IP
41 ${NEW_MASK}= Get Environment Variable NEW_SUBNET_MASK
42 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
43
44 ${arglist}= Create List eth0 ${NEW_IP} ${NEW_MASK} ${NEW_GATEWAY}
45 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -060046 run keyword and ignore error
47 ... Call Method
48 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetAddress4 data=${args}
Rahul Maheshwari01413692016-09-05 21:35:24 -050049
50 Wait For Host To Ping ${NEW_IP}
51 Set Suite Variable ${AUTH_URI} https://${NEW_IP}
52 Log ${AUTH_URI}
53
54 ${networkInfo}= Get networkInfo from the interface eth0
55 ${ipaddress}= set variable ${networkInfo['data'][2]}
56 ${gateway}= set variable ${networkInfo['data'][3]}
57
Gunnar Mills597ffa02016-12-06 11:26:53 -060058 ${isgatewayfound}= Set Variable If '${gateway}'=='${NEW_GATEWAY}' true false
Rahul Maheshwari01413692016-09-05 21:35:24 -050059 Log ${isgatewayfound}
60 ${isIPfound}= Set Variable if '${ipaddress}' == '${NEW_IP}' true false
61 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
62
63
64Revert the last ip address change
65 [Tags] network_test
66 [Documentation] This test case sets the ip on the interface and validates
67 ... that ip address has been set or not.
68 ... Expectation is the ip address should get added.
69
70
71 ${arglist}= Create List eth0 ${OLD_IP} ${OLD_MASK} ${OLD_GATEWAY}
72 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -060073 run keyword and ignore error
74 ... Call Method
75 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetAddress4 data=${args}
Rahul Maheshwari01413692016-09-05 21:35:24 -050076
77 Wait For Host To Ping ${OLD_IP}
78 Set Suite Variable ${AUTH_URI} https://${OLD_IP}
79 Log ${AUTH_URI}
80
81
82 ${networkInfo}= Get networkInfo from the interface eth0
83 ${ipaddress}= set variable ${networkInfo['data'][2]}
84 ${gateway}= set variable ${networkInfo['data'][3]}
85
Gunnar Mills597ffa02016-12-06 11:26:53 -060086 ${isgatewayfound}= Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
Rahul Maheshwari01413692016-09-05 21:35:24 -050087 Log ${isgatewayfound}
88 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
89 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
90
91
92Persistency check for ip address
93 [Tags] reboot_test
94 [Documentation] we reboot the service processor and after reboot
95 ... will request for the ip address to check the persistency
96 ... of the ip address.
97 ... Expectation is the ip address should persist.
98
99 Open Connection And Log In
100 Execute Command reboot
101 Log "System is getting rebooted wait for few seconds"
102 ${networkInfo}= Get networkInfo from the interface eth0
103 ${ipaddress}= set variable ${networkInfo['data'][2]}
104 ${gateway}= set variable ${networkInfo['data'][3]}
105
Gunnar Mills597ffa02016-12-06 11:26:53 -0600106 ${isgatewayfound}= Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false
Rahul Maheshwari01413692016-09-05 21:35:24 -0500107 Log ${isgatewayfound}
108 ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false
109 should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true'
110
111
George Keishingf2f5f3b2016-09-28 10:55:11 -0500112Set invalid Mac address eth0 gg:hh:jj:kk:ll:mm error
113 [Tags] network_test Set_invalid_Mac_address
114 [Template] SetMacAddress_bad
115 [Documentation] This test case tries to set the invalid mac address
116 ... on the eth0 interface.
117 ... Expectation is that it should throw error.
118
119
120Set valid Mac address eth0 00:21:cc:73:91:dd ok
121 [Tags] network_test Set_valid_Mac_address
122 [Template] SetMacAddress_good
123 [Documentation] ***GOOD PATH***
124 ... This test case add the ip addresson the interface and validates
125 ... that ip address has been added or not.
126 ... Expectation is the ip address should get added.
127
128Revert old Mac address eth0 ${OLD_MAC_ADDRESS} ok
129 [Tags] network_test Revert_old_Mac_address
130 [Template] SetMacAddress_good
131 [Documentation] ***GOOD PATH***
132 ... This test case add the ip addresson the interface and validates
133 ... that ip address has been added or not.
134 ... Expectation is the ip address should get added.
135
Gunnar Mills7c8923f2016-12-12 21:19:52 -0600136*** Keywords ***
Rahul Maheshwari01413692016-09-05 21:35:24 -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}
Rahul Maheshwari01413692016-09-05 21:35:24 -0500149 @{arglist}= Create List ${intf}
150 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -0600151 ${resp}= Call Method
152 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ GetAddress4 data=${args}
Rahul Maheshwari01413692016-09-05 21:35:24 -0500153 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills597ffa02016-12-06 11:26:53 -0600154 ${json}= to json ${resp.content}
Rahul Maheshwari01413692016-09-05 21:35:24 -0500155 Log ${json['data'][2]}
156 Log ${json['data'][3]}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600157 [Return] ${json}
Rahul Maheshwari01413692016-09-05 21:35:24 -0500158
159
160validateEnvVariables
161
162 ${NEW_BMC_IP}= Get Environment Variable NEW_BMC_IP
163 ${NEW_SUBNET_MASK}= Get Environment Variable NEW_SUBNET_MASK
164 ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY
165
166
167 should not be empty ${NEW_BMC_IP}
168 should not be empty ${NEW_GATEWAY}
169 should not be empty ${NEW_SUBNET_MASK}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500170
171SetMacAddress_bad
172 [Arguments] ${intf} ${address} ${result}
173 ${arglist}= Create List ${intf} ${address}
174 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -0600175 ${resp}= Call Method
176 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetHwAddress data=${args}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500177 should not be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills597ffa02016-12-06 11:26:53 -0600178 ${json}= to json ${resp.content}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500179 should be equal as strings ${json['status']} ${result}
180
181
182SetMacAddress_good
183 [Arguments] ${intf} ${address} ${result}
184 ${arglist}= Create List ${intf} ${address}
185 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -0600186 ${resp}= Call Method
187 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ SetHwAddress data=${args}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500188 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills597ffa02016-12-06 11:26:53 -0600189 ${json}= to json ${resp.content}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500190 should be equal as strings ${json['status']} ${result}
191 Wait For Host To Ping ${OPENBMC_HOST}
192
193 Wait Until Keyword Succeeds 30 sec 5 sec Initialize OpenBMC
194
195 @{arglist}= Create List ${intf}
196 ${args}= Create Dictionary data=@{arglist}
George Keishing0fd3b242016-11-24 09:01:41 -0600197 ${resp}= Call Method
198 ... ${OPENBMC_BASE_URI}NetworkManager/Interface/ GetHwAddress data=${args}
Gunnar Mills597ffa02016-12-06 11:26:53 -0600199 ${json}= to json ${resp.content}
George Keishingf2f5f3b2016-09-28 10:55:11 -0500200 should be equal as strings ${json['data']} ${address}