Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation 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 |
| 5 | |
| 6 | Resource ../lib/rest_client.robot |
| 7 | Resource ../lib/ipmi_client.robot |
| 8 | Resource ../lib/utils.robot |
| 9 | Library ../lib/pythonutil.py |
| 10 | |
| 11 | |
| 12 | |
| 13 | *** Test Cases *** |
| 14 | |
| 15 | Get the Mac address |
| 16 | |
| 17 | [Documentation] This test case is to get the mac address |
| 18 | [Tags] network_test |
| 19 | @{arglist}= Create List eth0 |
| 20 | ${args}= Create Dictionary data=@{arglist} |
| 21 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetHwAddress data=${args} |
| 22 | should not be empty ${resp.content} |
| 23 | ${json} = to json ${resp.content} |
| 24 | should be equal as strings ${json['status']} ok |
| 25 | set suite variable ${OLD_MAC_ADDRESS} ${json['data']} |
| 26 | |
| 27 | |
| 28 | Get IP Address with invalid interface |
| 29 | |
| 30 | [Documentation] This test case tries to get the ip addrees with the invalid |
| 31 | ... interface,Expectation is it should get error. |
| 32 | [Tags] network_test |
| 33 | |
| 34 | @{arglist}= Create List lo01 |
| 35 | ${args}= Create Dictionary data=@{arglist} |
| 36 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args} |
| 37 | should not be equal as strings ${resp.status_code} ${HTTP_OK} |
| 38 | ${json} = to json ${resp.content} |
| 39 | should be equal as strings ${json['status']} error |
| 40 | |
| 41 | Get IP Address with valid interface |
| 42 | |
| 43 | [Documentation] This test case tries to get the ip addrees with the invalid |
| 44 | ... interface,Expectation is it should get error. |
| 45 | [Tags] network_test |
| 46 | |
| 47 | @{arglist}= Create List eth0 |
| 48 | ${args}= Create Dictionary data=@{arglist} |
| 49 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args} |
| 50 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 51 | ${json} = to json ${resp.content} |
| 52 | should be equal as strings ${json['status']} ok |
| 53 | |
| 54 | |
| 55 | Set the IP address on invalid Interface lo01 1.1.1.1 255.255.255.0 1.1.1.1 error |
| 56 | |
| 57 | [Tags] network_test |
| 58 | [Template] AddNetworkInfo |
| 59 | [Documentation] This test case tries to set the ip addrees with the invalid |
| 60 | ... interface,Expectation is it should get error |
| 61 | |
| 62 | Set invalid IP address on the valid interface eth0 ab.cd.ef.gh 255.255.255.0 1.1.1.1 error |
| 63 | |
| 64 | [Tags] network_test |
| 65 | [Template] AddNetworkInfo |
| 66 | [Documentation] This test case tries to set the invalid ip addrees on the interface |
| 67 | ... Expectation is it should get error. |
| 68 | |
| 69 | |
| 70 | Set IP address with invalid subnet mask eth0 2.2.2.2 av.ih.jk.lm 1.1.1.1 error |
| 71 | |
| 72 | [Tags] network_test |
| 73 | [Template] AddNetworkInfo |
| 74 | [Documentation] This test case tries to set the ip addrees on the interface |
| 75 | ... with invalid subnet mask,Expectation is it should get error. |
| 76 | |
| 77 | Set empty IP address eth0 ${EMPTY} 255.255.255.0 1.1.1.1 error |
| 78 | |
| 79 | [Tags] network_test |
| 80 | [Template] AddNetworkInfo |
| 81 | [Documentation] This test case tries to set the NULL ip addrees on the interface |
| 82 | ... Expectation is it should get error. |
| 83 | |
| 84 | Set empty subnet mask eth0 2.2.2.2 ${EMPTY} 1.1.1.1 error |
| 85 | |
| 86 | [Tags] network_test |
| 87 | [Template] AddNetworkInfo |
| 88 | [Documentation] This test case tries to set the ip addrees on the interface |
| 89 | ... with empty subnet mask,Expectation is it should get error. |
| 90 | |
| 91 | Set empty gateway eth0 2.2.2.2 255.255.255.0 ${EMPTY} error |
| 92 | |
| 93 | [Tags] network_test |
| 94 | [Template] AddNetworkInfo |
| 95 | [Documentation] This test case tries to set the ip addrees on the interface |
| 96 | ... with empty gateway,Expectation is it should get error. |
| 97 | |
| 98 | |
| 99 | Set IP address on valid Interface |
| 100 | [Tags] network_test |
| 101 | [Documentation] This test case sets the ip on the interface and validates |
| 102 | ... that ip address has been set or not. |
| 103 | ... Expectation is the ip address should get added. |
| 104 | |
| 105 | validateEnvVariables |
| 106 | |
| 107 | |
| 108 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 109 | ${result}= convert to integer ${networkInfo['data'][1]} |
| 110 | |
| 111 | ${MASK}= calcDottedNetmask ${result} |
| 112 | set suite variable ${OLD_MASK} ${MASK} |
| 113 | log to console ${OLD_MASK} |
| 114 | set suite variable ${OLD_IP} ${networkInfo['data'][2]} |
| 115 | set suite variable ${OLD_GATEWAY} ${networkInfo['data'][3]} |
| 116 | |
| 117 | log to console ${OLD_IP} |
| 118 | log to console ${OLD_GATEWAY} |
| 119 | |
| 120 | |
| 121 | ${NEW_IP}= Get Environment Variable NEW_BMC_IP |
| 122 | ${NEW_MASK}= Get Environment Variable NEW_SUBNET_MASK |
| 123 | ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY |
| 124 | |
| 125 | ${arglist}= Create List eth0 ${NEW_IP} ${NEW_MASK} ${NEW_GATEWAY} |
| 126 | ${args}= Create Dictionary data=@{arglist} |
| 127 | run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args} |
| 128 | |
| 129 | Wait For Host To Ping ${NEW_IP} |
| 130 | Set Suite Variable ${AUTH_URI} https://${NEW_IP} |
| 131 | log to console ${AUTH_URI} |
| 132 | |
| 133 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 134 | ${ipaddress}= set variable ${networkInfo['data'][2]} |
| 135 | ${gateway}= set variable ${networkInfo['data'][3]} |
| 136 | |
| 137 | ${isgatewayfound} = Set Variable If '${gateway}'=='${NEW_GATEWAY}' true false |
| 138 | log to console ${isgatewayfound} |
| 139 | ${isIPfound}= Set Variable if '${ipaddress}' == '${NEW_IP}' true false |
| 140 | should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true' |
| 141 | |
| 142 | |
| 143 | Revert the last ip address change |
| 144 | [Tags] network_test |
| 145 | [Documentation] This test case sets the ip on the interface and validates |
| 146 | ... that ip address has been set or not. |
| 147 | ... Expectation is the ip address should get added. |
| 148 | |
| 149 | |
| 150 | ${arglist}= Create List eth0 ${OLD_IP} ${OLD_MASK} ${OLD_GATEWAY} |
| 151 | ${args}= Create Dictionary data=@{arglist} |
| 152 | run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args} |
| 153 | |
| 154 | Wait For Host To Ping ${OLD_IP} |
| 155 | Set Suite Variable ${AUTH_URI} https://${OLD_IP} |
| 156 | log to console ${AUTH_URI} |
| 157 | |
| 158 | |
| 159 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 160 | ${ipaddress}= set variable ${networkInfo['data'][2]} |
| 161 | ${gateway}= set variable ${networkInfo['data'][3]} |
| 162 | |
| 163 | ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false |
| 164 | log to console ${isgatewayfound} |
| 165 | ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false |
| 166 | should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true' |
| 167 | |
| 168 | |
| 169 | Get IP Address type |
| 170 | [Tags] GOOD-PATH |
| 171 | [Documentation] This test case tries to set existing ipaddress address and |
| 172 | ... later tries to verify that ip address type is set to static |
| 173 | ... due to the operation. |
| 174 | |
| 175 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 176 | ${result}= convert to integer ${networkInfo['data'][1]} |
| 177 | |
| 178 | ${CURRENT_MASK}= calcDottedNetmask ${result} |
| 179 | ${CURRENT_IP}= set variable ${networkInfo['data'][2]} |
| 180 | ${CURRENT_GATEWAY}= set variable ${networkInfo['data'][3]} |
| 181 | |
| 182 | ${arglist}= Create List eth0 ${CURRENT_IP} ${CURRENT_MASK} ${CURRENT_GATEWAY} |
| 183 | ${args}= Create Dictionary data=@{arglist} |
| 184 | run keyword and ignore error Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args} |
| 185 | |
| 186 | Wait For Host To Ping ${CURRENT_IP} |
| 187 | |
| 188 | @{arglist}= Create List eth0 |
| 189 | ${args}= Create Dictionary data=@{arglist} |
| 190 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddressType data=${args} |
| 191 | ${json} = to json ${resp.content} |
| 192 | Should Be Equal ${json['data']} STATIC |
| 193 | should be equal as strings ${json['status']} ok |
| 194 | |
| 195 | |
| 196 | Persistency check for ip address |
| 197 | [Tags] reboot_test |
| 198 | [Documentation] we reboot the service processor and after reboot |
| 199 | ... will request for the ip address to check the persistency |
| 200 | ... of the ip address. |
| 201 | ... Expectation is the ip address should persist. |
| 202 | |
| 203 | Open Connection And Log In |
| 204 | Execute Command reboot |
| 205 | # sleep 100sec |
| 206 | log to console "System is getting rebooted wait for few seconds" |
| 207 | ${networkInfo}= Get networkInfo from the interface eth0 |
| 208 | ${ipaddress}= set variable ${networkInfo['data'][2]} |
| 209 | ${gateway}= set variable ${networkInfo['data'][3]} |
| 210 | |
| 211 | ${isgatewayfound} = Set Variable If '${gateway}'=='${OLD_GATEWAY}' true false |
| 212 | log to console ${isgatewayfound} |
| 213 | ${isIPfound}= Set Variable if '${ipaddress}' == '${OLD_IP}' true false |
| 214 | should be true '${isIPfound}' == 'true' and '${isgatewayfound}' == 'true' |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | Set invalid Mac address eth0 gg:hh:jj:kk:ll:mm error |
| 221 | [Tags] network_test |
| 222 | [Template] SetMacAddress_bad |
| 223 | [Documentation] This test case tries to set the invalid mac address |
| 224 | ... on the eth0 interface. |
| 225 | ... Expectation is that it should throw error. |
| 226 | |
| 227 | |
| 228 | Set valid Mac address eth0 00:21:cc:73:91:dd ok |
| 229 | [Tags] network_test |
| 230 | [Template] SetMacAddress_good |
| 231 | [Documentation] ***GOOD PATH*** |
| 232 | ... This test case add the ip addresson the interface and validates |
| 233 | ... that ip address has been added or not. |
| 234 | ... Expectation is the ip address should get added. |
| 235 | |
| 236 | Revert old Mac address eth0 ${OLD_MAC_ADDRESS} ok |
| 237 | [Tags] network_test |
| 238 | [Template] SetMacAddress_good |
| 239 | [Documentation] ***GOOD PATH*** |
| 240 | ... This test case add the ip addresson the interface and validates |
| 241 | ... that ip address has been added or not. |
| 242 | ... Expectation is the ip address should get added. |
| 243 | |
| 244 | |
| 245 | ***keywords*** |
| 246 | |
| 247 | Get networkInfo from the interface |
| 248 | |
| 249 | [Documentation] This keyword is used to match the given ip with the configured one. |
| 250 | ... returns true if match successfull else false |
| 251 | ... eg:- Outout of getAddress4 |
| 252 | ... NewFormat:-{"data": [ 2,25,"9.3.164.147","9.3.164.129"],"message": "200 OK","status": "ok"} |
| 253 | ... OldFormat:- |
| 254 | ... {"data": [[[2,25,0,128,"9.3.164.177"],[2,8,254,128,"127.0.0.1"]],"9.3.164.129"], |
| 255 | ... "message": "200 OK", "status": "ok"} |
| 256 | |
| 257 | [arguments] ${intf} |
| 258 | @{arglist}= Create List ${intf} |
| 259 | ${args}= Create Dictionary data=@{arglist} |
| 260 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetAddress4 data=${args} |
| 261 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 262 | ${json} = to json ${resp.content} |
| 263 | log to console ${json['data'][2]} |
| 264 | log to console ${json['data'][3]} |
| 265 | [return] ${json} |
| 266 | |
| 267 | AddNetworkInfo |
| 268 | [Arguments] ${intf} ${address} ${mask} ${gateway} ${result} |
| 269 | |
| 270 | ${arglist}= Create List ${intf} ${address} ${mask} ${gateway} |
| 271 | ${args}= Create Dictionary data=@{arglist} |
| 272 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetAddress4 data=${args} |
| 273 | should not be equal as strings ${resp.status_code} ${HTTP_OK} |
| 274 | ${json} = to json ${resp.content} |
| 275 | should be equal as strings ${json['status']} ${result} |
| 276 | |
| 277 | |
| 278 | SetMacAddress_bad |
| 279 | [Arguments] ${intf} ${address} ${result} |
| 280 | ${arglist}= Create List ${intf} ${address} |
| 281 | ${args}= Create Dictionary data=@{arglist} |
| 282 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetHwAddress data=${args} |
| 283 | should not be equal as strings ${resp.status_code} ${HTTP_OK} |
| 284 | ${json} = to json ${resp.content} |
| 285 | should be equal as strings ${json['status']} ${result} |
| 286 | |
| 287 | |
| 288 | SetMacAddress_good |
| 289 | [Arguments] ${intf} ${address} ${result} |
| 290 | ${arglist}= Create List ${intf} ${address} |
| 291 | ${args}= Create Dictionary data=@{arglist} |
| 292 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ SetHwAddress data=${args} |
| 293 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 294 | ${json} = to json ${resp.content} |
| 295 | should be equal as strings ${json['status']} ${result} |
| 296 | Wait For Host To Ping ${OPENBMC_HOST} |
| 297 | |
| 298 | @{arglist}= Create List ${intf} |
| 299 | ${args}= Create Dictionary data=@{arglist} |
| 300 | ${resp}= Call Method /org/openbmc/NetworkManager/Interface/ GetHwAddress data=${args} |
| 301 | ${json} = to json ${resp.content} |
| 302 | should be equal as strings ${json['data']} ${address} |
| 303 | |
| 304 | |
| 305 | validateEnvVariables |
| 306 | |
| 307 | ${NEW_BMC_IP}= Get Environment Variable NEW_BMC_IP |
| 308 | ${NEW_SUBNET_MASK}= Get Environment Variable NEW_SUBNET_MASK |
| 309 | ${NEW_GATEWAY}= Get Environment Variable NEW_GATEWAY |
| 310 | |
| 311 | |
| 312 | should not be empty ${NEW_BMC_IP} |
| 313 | should not be empty ${NEW_GATEWAY} |
| 314 | should not be empty ${NEW_SUBNET_MASK} |