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 | |
| 97 | [Documentation] Configure out of range IP address. |
| 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 | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 174 | *** Keywords *** |
| 175 | |
| 176 | Test Init Setup |
| 177 | [Documentation] Network setup. |
| 178 | Open Connection And Login |
| 179 | |
| 180 | @{IPv4_URI_List}= Get IPv4 URI List |
| 181 | Set Test Variable @{IPv4_URI_List} |
| 182 | |
| 183 | # Get BMC IP address and prefix length. |
| 184 | ${ip_data}= Get BMC IP Info |
| 185 | Set Test Variable ${ip_data} |
| 186 | |
| 187 | Get IPv4 URI List |
| 188 | [Documentation] Get all IPv4 URIs. |
| 189 | |
| 190 | # Sample output: |
| 191 | # "data": [ |
| 192 | # "/xyz/openbmc_project/network/eth0/ipv4/e9767624", |
| 193 | # "/xyz/openbmc_project/network/eth0/ipv4/31f4ce8b" |
| 194 | # ], |
| 195 | |
| 196 | @{ipv4_uri_list}= Read Properties ${XYZ_NETWORK_MANAGER}/eth0/ipv4/ |
| 197 | Should Not Be Empty ${ipv4_uri_list} msg=IPv4 URI list is empty. |
| 198 | |
| 199 | [Return] @{ipv4_uri_list} |
| 200 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 201 | Validate IP On BMC |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 202 | [Documentation] Validate IP on BMC. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 203 | [Arguments] ${ip_address} ${ip_info}=${ip_data} |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 204 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 205 | # Description of argument(s): |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 206 | # ip_address IP address of the system. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 207 | # ip_info List of IP address and prefix length values. |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 208 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 209 | Should Contain Match ${ip_info} ${ip_address}* |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 210 | ... msg=IP address does not exist. |
| 211 | |
| 212 | Validate Prefix Length On BMC |
| 213 | [Documentation] Validate prefix length on BMC. |
| 214 | [Arguments] ${prefix_length} |
| 215 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 216 | # Description of argument(s): |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 217 | # prefix_length It indicates netmask, netmask value 255.255.255.0 |
| 218 | # is equal to prefix length 24. |
| 219 | # ip_data Suite variable which has list of IP address and |
| 220 | # prefix length values. |
| 221 | |
| 222 | Should Contain Match ${ip_data} */${prefix_length} |
| 223 | ... msg=Prefix length does not exist. |
| 224 | |
| 225 | Validate Route On BMC |
| 226 | [Documentation] Validate route. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 227 | [Arguments] ${gateway_ip} |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 228 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 229 | # Description of argument(s): |
| 230 | # gateway_ip Gateway IP address. |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 231 | |
| 232 | ${route_info}= Get BMC Route Info |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 233 | Should Contain ${route_info} ${gateway_ip} |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 234 | ... msg=Gateway IP address not matching. |
| 235 | |
| 236 | Validate MAC on BMC |
| 237 | [Documentation] Validate MAC on BMC. |
| 238 | [Arguments] ${macaddr} |
| 239 | |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 240 | # Description of argument(s): |
Prashanth Katti | e79c540 | 2017-06-08 07:40:49 -0500 | [diff] [blame] | 241 | # macaddr MAC address of the BMC. |
| 242 | |
| 243 | ${system_mac}= Get BMC MAC Address |
| 244 | |
| 245 | Should Contain ${system_mac} ${macaddr} |
| 246 | ... ignore_case=True msg=MAC address does not exist. |
Prashanth Katti | 4cf87bd | 2017-06-28 08:56:02 -0500 | [diff] [blame^] | 247 | |
| 248 | Configure Network Settings |
| 249 | [Documentation] Configure network settings. |
| 250 | [Arguments] ${ip_addr} ${prefix_len} ${gateway_ip} ${expected_result} |
| 251 | |
| 252 | # Description of argument(s): |
| 253 | # ip_addr IP address of BMC. |
| 254 | # prefix_len Prefix length. |
| 255 | # gateway_ip Gateway IP address. |
| 256 | # expected_result Expected status of network setting configuration. |
| 257 | |
| 258 | ${len}= Convert To Bytes ${prefix_len} |
| 259 | |
| 260 | @{ip_parm_list}= Create List xyz.openbmc_project.Network.IP.Protocol.IPv4 |
| 261 | ... ${ip_addr} ${len} ${gateway_ip} |
| 262 | |
| 263 | ${data}= Create Dictionary data=@{ip_parm_list} |
| 264 | ${resp}= OpenBMC Post Request |
| 265 | ... ${XYZ_NETWORK_MANAGER}/eth0/action/IP data=${data} |
| 266 | ${json}= To JSON ${resp.content} |
| 267 | |
| 268 | Run Keyword If '${expected_result}' == 'error' Run Keywords |
| 269 | ... Should Not Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 270 | ... AND Should Be Equal As Strings ${json['status']} ${expected_result} |
| 271 | ... ELSE |
| 272 | ... Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |