aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Hrnciar <phrnciar@cisco.com>2016-09-28 09:36:15 +0200
committerPeter Mikus <pmikus@cisco.com>2016-10-04 12:01:37 +0000
commit149c67b82f9af5144431f4d5b781ed345ca09fb8 (patch)
tree7cb03bd4efa656a56667bbf0b0396b3c655a1053
parenta1316b18443ca5360f1304fc74dee33872dd95eb (diff)
CSIT-227, CSIT-240 IPv4/IPv6 Multipath routing tests
- add IPv4 Equal-cost multipath routing test - add IPv6 Equal-cost multipath routing test Change-Id: I62eaf9983b7767e124f80af7d8c8652ffc460cf8 Signed-off-by: Patrik Hrnciar <phrnciar@cisco.com>
-rw-r--r--resources/libraries/python/Routing.py16
-rw-r--r--resources/libraries/robot/traffic.robot43
-rw-r--r--resources/templates/vat/add_route.vat2
-rwxr-xr-xresources/traffic_scripts/send_icmp_check_multipath.py131
-rw-r--r--tests/func/ipv4/ipv4_multipath_routing.robot79
-rw-r--r--tests/func/ipv6/ipv6_multipath_routing.robot78
6 files changed, 345 insertions, 4 deletions
diff --git a/resources/libraries/python/Routing.py b/resources/libraries/python/Routing.py
index ff675f39a9..73c58e2053 100644
--- a/resources/libraries/python/Routing.py
+++ b/resources/libraries/python/Routing.py
@@ -19,14 +19,14 @@ from resources.libraries.python.ssh import exec_cmd_no_error
class Routing(object):
-
"""Routing utilities."""
# pylint: disable=too-many-arguments
@staticmethod
def vpp_route_add(node, network, prefix_len, gateway=None,
interface=None, use_sw_index=True, resolve_attempts=10,
- count=1, vrf=None, lookup_vrf=None):
+ count=1, vrf=None, lookup_vrf=None, multipath=False,
+ weight=None):
"""Add route to the VPP node.
:param node: Node to add route on.
@@ -40,6 +40,8 @@ class Routing(object):
:param count: number of IP addresses to add starting from network IP
with same prefix (increment is 1). If None, then is not used.
:param lookup_vrf: VRF table ID for lookup.
+ :param multipath: Enable multipath routing.
+ :param weight: Weight value for unequal cost multipath routing.
:type node: dict
:type network: str
:type prefix_len: int
@@ -50,6 +52,8 @@ class Routing(object):
:type count: int
:type vrf: int
:type lookup_vrf: int
+ :type multipath: bool
+ :type weight: int
"""
if use_sw_index:
int_cmd = ('sw_if_index {}'.
@@ -69,6 +73,10 @@ class Routing(object):
lookup_vrf = 'lookup-in-vrf {}'.format(lookup_vrf) if lookup_vrf else ''
+ multipath = 'multipath' if multipath else ''
+
+ weight = 'weight {}'.format(weight) if weight else ''
+
with VatTerminal(node, json_param=False) as vat:
vat.vat_terminal_exec_cmd_from_template('add_route.vat',
network=network,
@@ -78,7 +86,9 @@ class Routing(object):
interface=int_cmd,
resolve_attempts=rap,
count=cnt,
- lookup_vrf=lookup_vrf)
+ lookup_vrf=lookup_vrf,
+ multipath=multipath,
+ weight=weight)
@staticmethod
def add_fib_table(node, network, prefix_len, fib_id, place):
diff --git a/resources/libraries/robot/traffic.robot b/resources/libraries/robot/traffic.robot
index 2522444e35..f21831fe5a 100644
--- a/resources/libraries/robot/traffic.robot
+++ b/resources/libraries/robot/traffic.robot
@@ -388,3 +388,46 @@
| | ... | --src_ip | ${src_ip} | --dst_ip | ${tgt_ip}
| | Run Keyword And Expect Error | ARP reply timeout
| | ... | Run Traffic Script On Node | arp_request.py | ${tg_node} | ${args}
+
+| Send Packets And Check Multipath Routing
+| | [Documentation] | Send 100 IP ICMP packets traffic and check if it is\
+| | ... | divided into two paths.
+| | ...
+| | ... | *Arguments:*
+| | ...
+| | ... | _NOTE:_ Arguments are based on topology:
+| | ... | TG(if1)->(if1)DUT(if2)->TG(if2)
+| | ...
+| | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary
+| | ... | - src_port - Interface of TG-if1. Type: string
+| | ... | - dst_port - Interface of TG-if2. Type: string
+| | ... | - src_ip - IP of source interface (TG-if1). Type: string
+| | ... | - dst_ip - IP of destination interface (TG-if2). Type: string
+| | ... | - tx_src_mac - MAC address of TG-if1. Type: string
+| | ... | - tx_dst_mac - MAC address of DUT-if1. Type: string
+| | ... | - rx_src_mac - MAC address of DUT-if2. Type: string
+| | ... | - rx_dst_mac_1 - MAC address of interface for path 1. Type: string
+| | ... | - rx_dst_mac_2 - MAC address of interface for path 2. Type: string
+| | ...
+| | ... | *Return:*
+| | ... | - No value returned
+| | ...
+| | ... | *Example:*
+| | ...
+| | ... | \| Send Packet And Check Multipath Routing \| ${nodes['TG']} \
+| | ... | \| eth2 \| eth3 \| 16.0.0.1 \| 32.0.0.1 \
+| | ... | \| 08:00:27:cc:4f:54 \| 08:00:27:c9:6a:d5 \| 08:00:27:54:59:f9 \
+| | ... | \| 02:00:00:00:00:02 \| 02:00:00:00:00:03 \|
+| | ...
+| | [Arguments] | ${tg_node} | ${src_port} | ${dst_port} | ${src_ip} | ${dst_ip}
+| | ... | ${tx_src_mac} | ${tx_dst_mac} | ${rx_src_mac}
+| | ... | ${rx_dst_mac_1} | ${rx_dst_mac_2}
+| | ${src_port_name}= | Get interface name | ${tg_node} | ${src_port}
+| | ${dst_port_name}= | Get interface name | ${tg_node} | ${dst_port}
+| | ${args}= | Catenate | --tx_if | ${src_port_name}
+| | ... | --rx_if | ${dst_port_name} | --src_ip | ${src_ip}
+| | ... | --dst_ip | ${dst_ip} | --tg_if1_mac | ${tx_src_mac}
+| | ... | --dut_if1_mac | ${tx_dst_mac} | --dut_if2_mac | ${rx_src_mac}
+| | ... | --path_1_mac | ${rx_dst_mac_1} | --path_2_mac | ${rx_dst_mac_2}
+| | Run Traffic Script On Node | send_icmp_check_multipath.py | ${tg_node}
+| | ... | ${args}
diff --git a/resources/templates/vat/add_route.vat b/resources/templates/vat/add_route.vat
index 9fe89526e6..8411bfbdfb 100644
--- a/resources/templates/vat/add_route.vat
+++ b/resources/templates/vat/add_route.vat
@@ -1 +1 @@
-ip_add_del_route {network}/{prefix_length} {via} {vrf} {interface} {resolve_attempts} {count} {lookup_vrf}
+ip_add_del_route {network}/{prefix_length} {via} {vrf} {interface} {resolve_attempts} {count} {lookup_vrf} {multipath} {weight} \ No newline at end of file
diff --git a/resources/traffic_scripts/send_icmp_check_multipath.py b/resources/traffic_scripts/send_icmp_check_multipath.py
new file mode 100755
index 0000000000..4e39efdfcd
--- /dev/null
+++ b/resources/traffic_scripts/send_icmp_check_multipath.py
@@ -0,0 +1,131 @@
+#!/usr/bin/env python
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Traffic script that sends an IP ICMPv4/ICMPv6 packets traffic
+and check if it is divided into two paths."""
+
+import sys
+import ipaddress
+
+from scapy.layers.inet import ICMP, IP
+from scapy.layers.inet6 import IPv6
+from scapy.all import Ether
+from scapy.layers.inet6 import ICMPv6EchoRequest
+
+from resources.libraries.python.PacketVerifier import RxQueue, TxQueue
+from resources.libraries.python.TrafficScriptArg import TrafficScriptArg
+
+
+def valid_ipv4(ip):
+ try:
+ ipaddress.IPv4Address(unicode(ip))
+ return True
+ except (AttributeError, ipaddress.AddressValueError):
+ return False
+
+
+def valid_ipv6(ip):
+ try:
+ ipaddress.IPv6Address(unicode(ip))
+ return True
+ except (AttributeError, ipaddress.AddressValueError):
+ return False
+
+
+def main():
+ """Send 100 IP ICMP packets traffic and check if it is divided into
+ two paths."""
+ args = TrafficScriptArg(
+ ['src_ip', 'dst_ip', 'tg_if1_mac', 'dut_if1_mac', 'dut_if2_mac',
+ 'path_1_mac', 'path_2_mac'])
+
+ src_ip = args.get_arg('src_ip')
+ dst_ip = args.get_arg('dst_ip')
+ tg_if1_mac = args.get_arg('tg_if1_mac')
+ dut_if1_mac = args.get_arg('dut_if1_mac')
+ dut_if2_mac = args.get_arg('dut_if2_mac')
+ path_1_mac = args.get_arg('path_1_mac')
+ path_2_mac = args.get_arg('path_2_mac')
+ tx_if = args.get_arg('tx_if')
+ rx_if = args.get_arg('rx_if')
+ path_1_counter = 0
+ path_2_counter = 0
+
+ rxq = RxQueue(rx_if)
+ txq = TxQueue(tx_if)
+ sent_packets = []
+ ip_format = ''
+ pkt_raw = ''
+ separator = ''
+
+ if valid_ipv4(src_ip):
+ separator = '.'
+ elif valid_ipv6(src_ip):
+ separator = ':'
+ else:
+ raise ValueError("Source address not in correct format")
+
+ src_ip_base = (src_ip.rsplit(separator, 1))[0] + separator
+
+ for i in range(1, 101):
+ if valid_ipv4(src_ip) and valid_ipv4(dst_ip):
+ pkt_raw = (Ether(src=tg_if1_mac, dst=dut_if1_mac) /
+ IP(src=src_ip_base+str(i), dst=dst_ip) /
+ ICMP())
+ ip_format = 'IP'
+ elif valid_ipv6(src_ip) and valid_ipv6(dst_ip):
+ pkt_raw = (Ether(src=tg_if1_mac, dst=dut_if1_mac) /
+ IPv6(src=src_ip_base+str(i), dst=dst_ip) /
+ ICMPv6EchoRequest())
+ ip_format = 'IPv6'
+ else:
+ raise ValueError("IP not in correct format")
+
+ sent_packets.append(pkt_raw)
+ txq.send(pkt_raw)
+ ether = rxq.recv(2)
+
+ if ether is None:
+ raise RuntimeError("ICMP echo Rx timeout")
+ if not ether.haslayer(ip_format):
+ raise RuntimeError("Not an IP packet received {0}"
+ .format(ether.__repr__()))
+
+ if ether['Ethernet'].src != dut_if2_mac:
+ raise RuntimeError("Source MAC address error")
+
+ if ether['Ethernet'].dst == path_1_mac:
+ path_1_counter += 1
+ elif ether['Ethernet'].dst == path_2_mac:
+ path_2_counter += 1
+ else:
+ raise RuntimeError("Destination MAC address error")
+
+ if (path_1_counter + path_2_counter) != 100:
+ raise RuntimeError("Packet loss: recevied only {} packets of 100 "
+ .format(path_1_counter + path_2_counter))
+
+ if path_1_counter == 0:
+ raise RuntimeError("Path 1 error!")
+
+ if path_2_counter == 0:
+ raise RuntimeError("Path 2 error!")
+
+ print "Path_1 counter: {}".format(path_1_counter)
+ print "Path_2 counter: {}".format(path_2_counter)
+
+ sys.exit(0)
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/func/ipv4/ipv4_multipath_routing.robot b/tests/func/ipv4/ipv4_multipath_routing.robot
new file mode 100644
index 0000000000..9d31bf0d61
--- /dev/null
+++ b/tests/func/ipv4/ipv4_multipath_routing.robot
@@ -0,0 +1,79 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+*** Settings ***
+| Resource | resources/libraries/robot/default.robot
+| Resource | resources/libraries/robot/counters.robot
+| Resource | resources/libraries/robot/interfaces.robot
+| Resource | resources/libraries/robot/testing_path.robot
+| Resource | resources/libraries/robot/ipv4.robot
+| Resource | resources/libraries/robot/traffic.robot
+| Library | resources.libraries.python.Trace
+
+| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO
+| Suite Setup | Run Keywords | Setup all TGs before traffic script
+| ... | AND | Update All Interface Data On All Nodes | ${nodes}
+| Test Setup | Setup all DUTs before test
+| Test Teardown | Run Keywords | Show packet trace on all DUTs | ${nodes}
+| ... | AND | Vpp Show Errors | ${nodes['DUT1']}
+| ... | AND | Show vpp trace dump on all DUTs
+| Documentation | *Ipv4 Multipath routing test cases*
+| ...
+| ... | *[Top] Network topologies:* TG=DUT 2-node topology with two links\
+| ... | between nodes.
+| ... | *[Cfg] DUT configuration:* On DUT configure interfaces IPv4 adresses,\
+| ... | and multipath routing.
+| ... | *[Ver] TG verification:* Test packets are sent from TG on the first\
+| ... | link to DUT. Packet is received on TG on the second link from DUT1.
+
+
+*** Variables ***
+| ${ip_1}= | 192.168.1.1
+| ${ip_2}= | 192.168.2.1
+| ${test_dst_ip}= | 32.0.0.1
+| ${test_src_ip}= | 16.0.0.1
+| ${prefix_length}= | 24
+| ${neighbor_1_ip}= | 192.168.2.10
+| ${neighbor_1_mac}= | 02:00:00:00:00:02
+| ${neighbor_2_ip}= | 192.168.2.20
+| ${neighbor_2_mac}= | 02:00:00:00:00:03
+
+*** Test Cases ***
+| TC01: IPv4 Equal-cost multipath routing
+| | [Documentation]
+| | ... | [Top] TG=DUT
+| | ... | [Cfg] On DUT configure multipath routing wiht two equal-cost paths.
+| | ... | [Ver] TG sends 100 IPv4 ICMP packets traffic on the first link to\
+| | ... | DUT. On second link to TG verify if traffic is divided into two paths.
+| | Given Path for 2-node testing is set
+| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
+| | And Interfaces in 2-node path are UP
+| | And Set Interface Address | ${dut_node}
+| | ... | ${dut_to_tg_if2} | ${ip_1} | ${prefix_length}
+| | And Set Interface Address | ${dut_node}
+| | ... | ${dut_to_tg_if1} | ${ip_2} | ${prefix_length}
+| | And Add Arp On Dut
+| | ... | ${dut_node} | ${dut_to_tg_if1} | ${neighbor_1_ip} | ${neighbor_1_mac}
+| | And Add Arp On Dut
+| | ... | ${dut_node} | ${dut_to_tg_if1} | ${neighbor_2_ip} | ${neighbor_2_mac}
+| | When Vpp Route Add
+| | ... | ${dut_node} | ${test_dst_ip} | ${prefix_length} | ${neighbor_1_ip}
+| | ... | ${dut_to_tg_if1} | resolve_attempts=${NONE} | multipath=${TRUE}
+| | And Vpp Route Add
+| | ... | ${dut_node} | ${test_dst_ip} | ${prefix_length} | ${neighbor_2_ip}
+| | ... | ${dut_to_tg_if1} | resolve_attempts=${NONE} | multipath=${TRUE}
+| | Then Send Packets And Check Multipath Routing | ${tg_node}
+| | ... | ${tg_to_dut_if2} | ${tg_to_dut_if1} | ${test_src_ip} | ${test_dst_ip}
+| | ... | ${tg_to_dut_if2_mac} | ${dut_to_tg_if2_mac} | ${dut_to_tg_if1_mac}
+| | ... | ${neighbor_1_mac} | ${neighbor_2_mac}
diff --git a/tests/func/ipv6/ipv6_multipath_routing.robot b/tests/func/ipv6/ipv6_multipath_routing.robot
new file mode 100644
index 0000000000..02d48a0a72
--- /dev/null
+++ b/tests/func/ipv6/ipv6_multipath_routing.robot
@@ -0,0 +1,78 @@
+# Copyright (c) 2016 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+*** Settings ***
+| Resource | resources/libraries/robot/default.robot
+| Resource | resources/libraries/robot/counters.robot
+| Resource | resources/libraries/robot/interfaces.robot
+| Resource | resources/libraries/robot/testing_path.robot
+| Resource | resources/libraries/robot/ipv6.robot
+| Resource | resources/libraries/robot/traffic.robot
+| Library | resources.libraries.python.Trace
+
+| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO
+| Suite Setup | Run Keywords | Setup all TGs before traffic script
+| ... | AND | Update All Interface Data On All Nodes | ${nodes}
+| Test Setup | Setup all DUTs before test
+| Test Teardown | Run Keywords | Show packet trace on all DUTs | ${nodes}
+| ... | AND | Vpp Show Errors | ${nodes['DUT1']}
+| ... | AND | Show vpp trace dump on all DUTs
+| Documentation | *Ipv6 Multipath routing test cases*
+| ...
+| ... | *[Top] Network topologies:* TG=DUT 2-node topology with two links\
+| ... | between nodes.
+| ... | *[Cfg] DUT configuration:* On DUT configure interfaces IPv4 adresses,\
+| ... | and multipath routing.
+| ... | *[Ver] TG verification:* Test packets are sent from TG on the first\
+| ... | link to DUT. Packet is received on TG on the second link from DUT1.
+
+*** Variables ***
+| ${ip_1}= | 3ffe:61::1
+| ${ip_2}= | 3ffe:62::1
+| ${test_dst_ip}= | 3ffe:71::1
+| ${test_src_ip}= | 3ffe:51::1
+| ${prefix_length}= | 64
+| ${neighbor_1_ip}= | 3ffe:62::2
+| ${neighbor_1_mac}= | 02:00:00:00:00:02
+| ${neighbor_2_ip}= | 3ffe:62::3
+| ${neighbor_2_mac}= | 02:00:00:00:00:03
+
+*** Test Cases ***
+| TC01: IPv6 Equal-cost multipath routing
+| | [Documentation]
+| | ... | [Top] TG=DUT
+| | ... | [Cfg] On DUT configure multipath routing wiht two equal-cost paths.
+| | ... | [Ver] TG sends 100 IPv6 ICMP packets traffic on the first link to\
+| | ... | DUT. On second link to TG verify if traffic is divided into two paths.
+| | Given Path for 2-node testing is set
+| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
+| | And Interfaces in 2-node path are UP
+| | And Vpp Set If Ipv6 Addr | ${dut_node}
+| | ... | ${dut_to_tg_if2} | ${ip_1} | ${prefix_length}
+| | And Vpp Set If Ipv6 Addr | ${dut_node}
+| | ... | ${dut_to_tg_if1} | ${ip_2} | ${prefix_length}
+| | And Add Ip Neighbor
+| | ... | ${dut_node} | ${dut_to_tg_if1} | ${neighbor_1_ip} | ${neighbor_1_mac}
+| | And Add Ip Neighbor
+| | ... | ${dut_node} | ${dut_to_tg_if1} | ${neighbor_2_ip} | ${neighbor_2_mac}
+| | When Vpp Route Add
+| | ... | ${dut_node} | ${test_dst_ip} | ${prefix_length} | ${neighbor_1_ip}
+| | ... | ${dut_to_tg_if1} | resolve_attempts=${NONE} | multipath=${TRUE}
+| | And Vpp Route Add
+| | ... | ${dut_node} | ${test_dst_ip} | ${prefix_length} | ${neighbor_2_ip}
+| | ... | ${dut_to_tg_if1} | resolve_attempts=${NONE} | multipath=${TRUE}
+| | Then Send Packets And Check Multipath Routing | ${tg_node}
+| | ... | ${tg_to_dut_if2} | ${tg_to_dut_if1} | ${test_src_ip} | ${test_dst_ip}
+| | ... | ${tg_to_dut_if2_mac} | ${dut_to_tg_if2_mac} | ${dut_to_tg_if1_mac}
+| | ... | ${neighbor_1_mac} | ${neighbor_2_mac}