Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 1 | *** Settings *** |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 2 | Documentation Network interface and functionalities test module on BMC. |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 3 | |
| 4 | Resource ../lib/rest_client.robot |
| 5 | Resource ../lib/utils.robot |
| 6 | Resource ../lib/bmc_network_utils.robot |
| 7 | |
| 8 | Force Tags Network_Test |
| 9 | |
| 10 | Library String |
| 11 | Library SSHLibrary |
| 12 | |
| 13 | Test Setup Test Init Setup |
| 14 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 15 | *** Variables *** |
| 16 | |
| 17 | ${alpha_ip} xx.xx.xx.xx |
| 18 | |
| 19 | # 10.x.x.x series is a private IP address range and does not exist in |
| 20 | # our network, so this is chosen to avoid IP conflict. |
| 21 | |
| 22 | ${valid_ip} 10.6.6.6 |
| 23 | ${valid_gateway} 10.6.6.1 |
| 24 | ${valid_prefix_len} 24 |
| 25 | ${broadcast_ip} 10.6.6.255 |
| 26 | ${loopback_ip} 127.0.0.1 |
| 27 | ${multicast_ip} 224.6.6.255 |
| 28 | ${out_of_range_ip} 10.6.6.256 |
| 29 | |
| 30 | # There will be 4 octets in IP address (e.g. xx.xx.xx.xx) |
| 31 | # but trying to configure xx.xx.xx |
| 32 | |
| 33 | ${less_octet_ip} 10.3.36 |
| 34 | |
| 35 | # For the address 10.6.6.6, the 10.6.6.0 portion describes the |
| 36 | # network ID and the 6 describe the host. |
| 37 | |
| 38 | ${network_id} 10.6.6.0 |
| 39 | ${hex_ip} 0xa.0xb.0xc.0xd |
| 40 | |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 41 | *** Test Cases *** |
| 42 | |
| 43 | Get BMC IPv4 Address And Verify |
| 44 | [Documentation] Get BMC IPv4 address and verify. |
| 45 | [Tags] Get_BMC_IPv4_Address_And_Verify |
| 46 | |
| 47 | :FOR ${ipv4_uri} IN @{IPv4_URI_List} |
| 48 | \ ${ipv4_addr}= Read Attribute ${ipv4_uri} Address |
| 49 | \ Validate IP on BMC ${ipv4_addr} |
| 50 | |
| 51 | Verify IPv4 Prefix Length |
| 52 | [Documentation] Get prefix length and verify. |
| 53 | [Tags] Verify_IPv4_Prefix_Length |
| 54 | |
| 55 | :FOR ${ipv4_uri} IN @{IPv4_URI_List} |
| 56 | \ ${prefix_length}= Read Attribute ${ipv4_uri} PrefixLength |
| 57 | \ Validate Prefix Length On BMC ${prefix_length} |
| 58 | |
| 59 | Verify Gateway Address |
| 60 | [Documentation] Get gateway address and verify. |
| 61 | [Tags] Verify_Gateway_Address |
| 62 | |
| 63 | :FOR ${ipv4_uri} IN @{IPv4_URI_List} |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 64 | \ ${gateway_ip}= Read Attribute ${ipv4_uri} Gateway |
| 65 | \ Validate Route On BMC ${gateway_ip} |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 66 | |
| 67 | Verify MAC Address |
| 68 | [Documentation] Get MAC address and verify. |
| 69 | [Tags] Verify_MAC_Address |
| 70 | ${macaddr}= Read Attribute ${XYZ_NETWORK_MANAGER}/eth0 MACAddress |
| 71 | Validate MAC On BMC ${macaddr} |
| 72 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 73 | Add New Valid IP And Verify |
| 74 | [Documentation] Add new IP address and verify. |
| 75 | [Tags] Add_New_Valid_IP_And_Verify |
| 76 | |
| 77 | Configure Network Settings ${valid_ip} ${valid_prefix_len} |
| 78 | ... ${valid_gateway} valid |
| 79 | |
| 80 | # Verify whether new IP address is populated on BMC system. |
| 81 | ${ip_info}= Get BMC IP Info |
| 82 | Validate IP On BMC ${valid_ip} ${ip_info} |
| 83 | |
| 84 | Configure Invalid IP String |
| 85 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 86 | ${alpha_ip} ${valid_prefix_len} ${valid_gateway} error |
| 87 | |
| 88 | [Documentation] Configure invalid IP address which is a string. |
| 89 | [Tags] Configure_Invalid_IP_String |
| 90 | |
| 91 | [Template] Configure_Network_Settings |
| 92 | |
| 93 | Configure Out Of Range IP |
| 94 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 95 | ${out_of_range_ip} ${valid_prefix_len} ${valid_gateway} error |
| 96 | |
Prashanth Katti | 388bdc7 | 2017-07-19 08:54:58 -0500 | [diff] [blame] | 97 | [Documentation] Configure out-of-range IP address. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 98 | [Tags] Configure_Out_Of_Range_IP |
| 99 | |
| 100 | [Template] Configure_Network_Settings |
| 101 | |
| 102 | Configure Broadcast IP |
| 103 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 104 | ${broadcast_ip} ${valid_prefix_len} ${valid_gateway} error |
| 105 | |
| 106 | [Documentation] Configure broadcast IP address. |
| 107 | [Tags] Configure_Broadcast_IP |
| 108 | |
| 109 | [Template] Configure_Network_Settings |
| 110 | |
| 111 | Configure Multicast IP |
| 112 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 113 | ${multicast_ip} ${valid_prefix_len} ${valid_gateway} error |
| 114 | |
| 115 | [Documentation] Configure multicast IP address. |
| 116 | [Tags] Configure_Multicast_IP |
| 117 | |
| 118 | [Template] Configure_Network_Settings |
| 119 | |
| 120 | Configure Loopback IP |
| 121 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 122 | ${loopback_ip} ${valid_prefix_len} ${valid_gateway} error |
| 123 | |
| 124 | [Documentation] Configure loopback IP address. |
| 125 | [Tags] Configure_Loopback_IP |
| 126 | |
| 127 | [Template] Configure_Network_Settings |
| 128 | |
| 129 | Configure Network ID |
| 130 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 131 | ${network_id} ${valid_prefix_len} ${valid_gateway} error |
| 132 | |
| 133 | [Documentation] Configure network ID IP address. |
| 134 | [Tags] Configure_Network_ID |
| 135 | |
| 136 | [Template] Configure_Network_Settings |
| 137 | |
| 138 | Configure Less Octet IP |
| 139 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 140 | ${less_octet_ip} ${valid_prefix_len} ${valid_gateway} error |
| 141 | |
| 142 | [Documentation] Configure less octet IP address. |
| 143 | [Tags] Configure_Less_Octet_IP |
| 144 | |
| 145 | [Template] Configure_Network_Settings |
| 146 | |
| 147 | Configure Empty IP |
| 148 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 149 | ${EMPTY} ${valid_prefix_len} ${valid_gateway} error |
| 150 | |
| 151 | [Documentation] Configure less octet IP address. |
| 152 | [Tags] Configure_Empty_IP |
| 153 | |
| 154 | [Template] Configure_Network_Settings |
| 155 | |
| 156 | Configure Special Char IP |
| 157 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 158 | @@@.%%.44.11 ${valid_prefix_len} ${valid_gateway} error |
| 159 | |
| 160 | [Documentation] Configure invalid IP address contaning special chars. |
| 161 | [Tags] Configure_Special_Char_IP |
| 162 | |
| 163 | [Template] Configure_Network_Settings |
| 164 | |
| 165 | Configure Hexadecimal IP |
| 166 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 167 | ${hex_ip} ${valid_prefix_len} ${valid_gateway} error |
| 168 | |
| 169 | [Documentation] Configure invalid IP address contaning hex value. |
| 170 | [Tags] Configure_Hexadecimal_IP |
| 171 | |
| 172 | [Template] Configure_Network_Settings |
| 173 | |
Prashanth Katti | 388bdc7 | 2017-07-19 08:54:58 -0500 | [diff] [blame] | 174 | Add New Valid IP With Blank Gateway |
| 175 | [Documentation] Add new IP with blank gateway. |
| 176 | [Tags] Add_New_Valid_IP_With_Blank_Gateway |
| 177 | |
| 178 | Configure Network Settings ${valid_ip} ${valid_prefix_len} ${EMPTY} |
| 179 | ... valid |
| 180 | |
| 181 | # Verify whether new IP address is populated on BMC system. |
| 182 | ${ip_info}= Get BMC IP Info |
| 183 | Validate IP On BMC ${valid_ip} ${ip_info} |
| 184 | |
| 185 | Configure Invalid Gateway String |
| 186 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 187 | ${valid_ip} ${valid_prefix_len} ${alpha_ip} error |
| 188 | |
| 189 | [Documentation] Configure invalid IP address to a gateway which is |
| 190 | ... an alpha string and expect an error. |
| 191 | [Tags] Configure_Invalid_Gateway_String |
| 192 | |
| 193 | [Template] Configure_Network_Settings |
| 194 | |
| 195 | Configure Out Of Range IP For Gateway |
| 196 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 197 | ${valid_ip} ${valid_prefix_len} ${out_of_range_ip} error |
| 198 | |
| 199 | [Documentation] Configure out-of-range IP for gateway and expect an error. |
| 200 | [Tags] Configure_Out_Of_Range_IP_For_Gateway |
| 201 | |
| 202 | [Template] Configure_Network_Settings |
| 203 | |
| 204 | Configure Broadcast IP For Gateway |
| 205 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 206 | ${valid_ip} ${valid_prefix_len} ${broadcast_ip} error |
| 207 | |
| 208 | [Documentation] Configure broadcast IP for gateway and expect an error. |
| 209 | [Tags] Configure_Broadcast_IP_For_Gateway |
| 210 | |
| 211 | [Template] Configure_Network_Settings |
| 212 | |
| 213 | Configure Loopback IP For Gateway |
| 214 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 215 | ${valid_ip} ${valid_prefix_len} ${loopback_ip} error |
| 216 | |
| 217 | [Documentation] Configure loopback IP for gateway and expect an error. |
| 218 | [Tags] Configure_Loopback_IP_For_Gateway |
| 219 | |
| 220 | [Template] Configure_Network_Settings |
| 221 | |
| 222 | Configure Multicast IP For Gateway |
| 223 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 224 | ${valid_ip} ${valid_prefix_len} ${multicast_ip} error |
| 225 | |
| 226 | [Documentation] Configure multicast IP for gateway and expect an error. |
| 227 | [Tags] Configure_Multicast_IP_For_Gateway |
| 228 | |
| 229 | [Template] Configure_Network_Settings |
| 230 | |
| 231 | Configure Network ID For Gateway |
| 232 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 233 | ${valid_ip} ${valid_prefix_len} ${network_id} error |
| 234 | |
| 235 | [Documentation] Configure network ID for gateway and expect an error. |
| 236 | [Tags] Configure_Network_ID_For_Gateway |
| 237 | |
| 238 | [Template] Configure_Network_Settings |
| 239 | |
| 240 | Configure Less Octet IP For Gateway |
| 241 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 242 | ${valid_ip} ${valid_prefix_len} ${less_octet_ip} error |
| 243 | |
| 244 | [Documentation] Configure less octet IP for gateway and expect an error. |
| 245 | [Tags] Configure_Less_Octet_IP_For_Gateway |
| 246 | |
| 247 | [Template] Configure_Network_Settings |
| 248 | |
| 249 | Configure Special Char IP For Gateway |
| 250 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 251 | ${valid_ip} ${valid_prefix_len} @@@.%%.44.11 error |
| 252 | |
| 253 | [Documentation] Configure special char IP for gateway and expect an error. |
| 254 | [Tags] Configure_Special_Char_IP_For_Gateway |
| 255 | |
| 256 | [Template] Configure_Network_Settings |
| 257 | |
| 258 | Configure Hexadecimal IP For Gateway |
| 259 | # IP Address Prefix_length Gateway_IP Expected_Result |
| 260 | ${valid_ip} ${valid_prefix_len} ${hex_ip} error |
| 261 | |
| 262 | [Documentation] Configure hexadecimal IP for gateway and expect an error. |
| 263 | [Tags] Configure_Hexadecimal_IP_For_Gateway |
| 264 | |
| 265 | [Template] Configure_Network_Settings |
| 266 | |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 267 | *** Keywords *** |
| 268 | |
| 269 | Test Init Setup |
| 270 | [Documentation] Network setup. |
| 271 | Open Connection And Login |
| 272 | |
| 273 | @{IPv4_URI_List}= Get IPv4 URI List |
| 274 | Set Test Variable @{IPv4_URI_List} |
| 275 | |
| 276 | # Get BMC IP address and prefix length. |
| 277 | ${ip_data}= Get BMC IP Info |
| 278 | Set Test Variable ${ip_data} |
| 279 | |
| 280 | Get IPv4 URI List |
| 281 | [Documentation] Get all IPv4 URIs. |
| 282 | |
| 283 | # Sample output: |
| 284 | # "data": [ |
| 285 | # "/xyz/openbmc_project/network/eth0/ipv4/e9767624", |
| 286 | # "/xyz/openbmc_project/network/eth0/ipv4/31f4ce8b" |
| 287 | # ], |
| 288 | |
| 289 | @{ipv4_uri_list}= Read Properties ${XYZ_NETWORK_MANAGER}/eth0/ipv4/ |
| 290 | Should Not Be Empty ${ipv4_uri_list} msg=IPv4 URI list is empty. |
| 291 | |
| 292 | [Return] @{ipv4_uri_list} |
| 293 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 294 | Validate IP On BMC |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 295 | [Documentation] Validate IP on BMC. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 296 | [Arguments] ${ip_address} ${ip_info}=${ip_data} |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 297 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 298 | # Description of argument(s): |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 299 | # ip_address IP address of the system. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 300 | # ip_info List of IP address and prefix length values. |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 301 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 302 | Should Contain Match ${ip_info} ${ip_address}* |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 303 | ... msg=IP address does not exist. |
| 304 | |
| 305 | Validate Prefix Length On BMC |
| 306 | [Documentation] Validate prefix length on BMC. |
| 307 | [Arguments] ${prefix_length} |
| 308 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 309 | # Description of argument(s): |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 310 | # prefix_length It indicates netmask, netmask value 255.255.255.0 |
| 311 | # is equal to prefix length 24. |
| 312 | # ip_data Suite variable which has list of IP address and |
| 313 | # prefix length values. |
| 314 | |
| 315 | Should Contain Match ${ip_data} */${prefix_length} |
| 316 | ... msg=Prefix length does not exist. |
| 317 | |
| 318 | Validate Route On BMC |
| 319 | [Documentation] Validate route. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 320 | [Arguments] ${gateway_ip} |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 321 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 322 | # Description of argument(s): |
| 323 | # gateway_ip Gateway IP address. |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 324 | |
| 325 | ${route_info}= Get BMC Route Info |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 326 | Should Contain ${route_info} ${gateway_ip} |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 327 | ... msg=Gateway IP address not matching. |
| 328 | |
| 329 | Validate MAC on BMC |
| 330 | [Documentation] Validate MAC on BMC. |
| 331 | [Arguments] ${macaddr} |
| 332 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 333 | # Description of argument(s): |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 334 | # macaddr MAC address of the BMC. |
| 335 | |
| 336 | ${system_mac}= Get BMC MAC Address |
| 337 | |
| 338 | Should Contain ${system_mac} ${macaddr} |
| 339 | ... ignore_case=True msg=MAC address does not exist. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame] | 340 | |
| 341 | Configure Network Settings |
| 342 | [Documentation] Configure network settings. |
| 343 | [Arguments] ${ip_addr} ${prefix_len} ${gateway_ip} ${expected_result} |
| 344 | |
| 345 | # Description of argument(s): |
| 346 | # ip_addr IP address of BMC. |
| 347 | # prefix_len Prefix length. |
| 348 | # gateway_ip Gateway IP address. |
| 349 | # expected_result Expected status of network setting configuration. |
| 350 | |
| 351 | ${len}= Convert To Bytes ${prefix_len} |
| 352 | |
| 353 | @{ip_parm_list}= Create List xyz.openbmc_project.Network.IP.Protocol.IPv4 |
| 354 | ... ${ip_addr} ${len} ${gateway_ip} |
| 355 | |
| 356 | ${data}= Create Dictionary data=@{ip_parm_list} |
| 357 | ${resp}= OpenBMC Post Request |
| 358 | ... ${XYZ_NETWORK_MANAGER}/eth0/action/IP data=${data} |
| 359 | ${json}= To JSON ${resp.content} |
| 360 | |
| 361 | Run Keyword If '${expected_result}' == 'error' Run Keywords |
| 362 | ... Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 363 | ... AND Should Be Equal As Strings ${json['status']} ${expected_result} |
| 364 | ... ELSE |
| 365 | ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |