From 7c3e0cc41f55327d6eeb04fe757c6e80064ab28a Mon Sep 17 00:00:00 2001 From: Zdeno Olsovsky Date: Mon, 13 Jun 2016 15:46:07 +0200 Subject: [PATCH] CSIT-158: Tap interface tests Change-Id: I30a4562ea5fca9b839d854118243daa70378b0ae Signed-off-by: Zdeno Olsovsky --- resources/libraries/python/IPv4Util.py | 65 +++++- resources/libraries/python/InterfaceUtil.py | 20 ++ resources/libraries/python/L2Util.py | 2 + resources/libraries/python/Namespaces.py | 96 +++++++++ resources/libraries/python/Routing.py | 25 ++- resources/libraries/python/Tap.py | 107 ++++++++++ resources/libraries/robot/traffic.robot | 8 +- resources/templates/vat/tap.vat | 1 + tests/suites/tap/tap_interface.robot | 305 ++++++++++++++++++++++++++++ 9 files changed, 620 insertions(+), 9 deletions(-) create mode 100644 resources/libraries/python/Namespaces.py create mode 100644 resources/libraries/python/Tap.py create mode 100644 resources/templates/vat/tap.vat create mode 100644 tests/suites/tap/tap_interface.robot diff --git a/resources/libraries/python/IPv4Util.py b/resources/libraries/python/IPv4Util.py index 4fe711fbff..3043f230c2 100644 --- a/resources/libraries/python/IPv4Util.py +++ b/resources/libraries/python/IPv4Util.py @@ -164,26 +164,83 @@ class IPv4Util(object): @staticmethod def send_ping_from_node_to_dst(node, destination, namespace=None, - ping_count=3): + ping_count=3, interface=None): """Send a ping from node to destination. Optionally, you can define a - namespace from where to send a ping. + namespace and interface from where to send a ping. :param node: Node to start ping on. :param destination: IPv4 address where to send ping. - :param namespace: Namespace to send ping from. - :param ping_count: Number of pings to send. + :param namespace: Namespace to send ping from. Optional + :param ping_count: Number of pings to send. Default 3 + :param interface: Interface from where to send ping. Optional :type node: dict :type destination: str :type namespace: str :type ping_count: int + :type interface: str :raises RuntimeError: If no response for ping, raise error """ cmd = '' if namespace is not None: cmd = 'ip netns exec {0} ping -c{1} {2}'.format( namespace, ping_count, destination) + elif interface is not None: + cmd = 'ping -I {0} -c{1} {2}'.format( + interface, ping_count, destination) else: cmd = 'ping -c{0} {1}'.format(ping_count, destination) rc, stdout, stderr = exec_cmd(node, cmd, sudo=True) if rc != 0: raise RuntimeError("Ping Not Successful") + + @staticmethod + def set_linux_interface_arp(node, interface, ip, mac, namespace=None): + """Set arp on interface in linux. + + :param node: Node where to execute command. + :param interface: Interface in namespace. + :param ip: IP for arp. + :param mac: MAC address. + :param namespace: Execute command in namespace. Optional + :type node: dict + :type interface: str + :type ip: str + :type mac: str + :type namespace: str + :raises RuntimeError: Could not set ARP properly. + """ + if namespace is not None: + cmd = 'ip netns exec {} arp -i {} -s {} {}'.format( + namespace, interface, ip, mac) + else: + cmd = 'arp -i {} -s {} {}'.format(interface, ip, mac) + rc, _, stderr = exec_cmd(node, cmd, sudo=True) + if rc != 0: + raise RuntimeError("Arp set not successful, reason:{}". + format(stderr)) + + @staticmethod + def set_linux_interface_ip(node, interface, ip, prefix, namespace=None): + """Set IP address to interface in linux. + + :param node: Node where to execute command. + :param interface: Interface in namespace. + :param ip: IP to be set on interface. + :param prefix: IP prefix. + :param namespace: Execute command in namespace. Optional + :type node: dict + :type interface: str + :type ip: str + :type prefix: int + :type namespace: str + :raises RuntimeError: IP could not be set. + """ + if namespace is not None: + cmd = 'ip netns exec {} ip addr add {}/{} dev {}'.format( + namespace, ip, prefix, interface) + else: + cmd = 'ip addr add {}/{} dev {}'.format(ip, prefix, interface) + (rc, _, stderr) = exec_cmd(node, cmd, timeout=5, sudo=True) + if rc != 0: + raise RuntimeError( + 'Could not set IP for interface, reason:{}'.format(stderr)) diff --git a/resources/libraries/python/InterfaceUtil.py b/resources/libraries/python/InterfaceUtil.py index 69d0a59680..2b985bf434 100644 --- a/resources/libraries/python/InterfaceUtil.py +++ b/resources/libraries/python/InterfaceUtil.py @@ -837,3 +837,23 @@ class InterfaceUtil(object): vat.vat_terminal_exec_cmd_from_template("set_fib_to_interface.vat", sw_index=sw_if_index, vrf=table_id) + + @staticmethod + def set_linux_interface_mac(node, interface, mac, namespace=None): + """Set MAC address for interface in linux. + + :param node: Node where to execute command. + :param interface: Interface in namespace. + :param mac: MAC to be assigned to interface. + :param namespace: Execute command in namespace. Optional + :type node: dict + :type interface: str + :type mac: str + :type namespace: str + """ + if namespace is not None: + cmd = 'ip netns exec {} ip link set {} address {}'.format( + namespace, interface, mac) + else: + cmd = 'ip link set {} address {}'.format(interface, mac) + exec_cmd_no_error(node, cmd, sudo=True) diff --git a/resources/libraries/python/L2Util.py b/resources/libraries/python/L2Util.py index af4735fdf8..4832ffac1c 100644 --- a/resources/libraries/python/L2Util.py +++ b/resources/libraries/python/L2Util.py @@ -211,6 +211,8 @@ class L2Util(object): exec_cmd_no_error(node, cmd, sudo=True) cmd = 'brctl addif {0} {1}'.format(br_name, if_2) exec_cmd_no_error(node, cmd, sudo=True) + cmd = 'ip link set dev {0} up'.format(br_name) + exec_cmd_no_error(node, cmd, sudo=True) @staticmethod def setup_network_namespace(node, namespace_name, interface_name, diff --git a/resources/libraries/python/Namespaces.py b/resources/libraries/python/Namespaces.py new file mode 100644 index 0000000000..d92dfd7e26 --- /dev/null +++ b/resources/libraries/python/Namespaces.py @@ -0,0 +1,96 @@ +# 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. + +"""Linux namespace utilities library.""" + +from resources.libraries.python.ssh import exec_cmd_no_error, exec_cmd, SSH + + +class Namespaces(object): + """Linux namespace utilities.""" + def __init__(self): + self._namespaces = [] + + def create_namespace(self, node, namespace_name): + """Create namespace and add the name to the list for later clean-up. + + :param node: Where to create namespace. + :param namespace_name: Name for namespace. + :type node: dict + :type namespace_name: str + """ + cmd = ('ip netns add {0}'.format(namespace_name)) + exec_cmd_no_error(node, cmd, sudo=True) + self._namespaces.append(namespace_name) + + @staticmethod + def attach_interface_to_namespace(node, namespace, interface): + """Attach specific interface to namespace. + + :param node: Node where to execute command. + :param namespace: Namespace to execute command on. + :param interface: Interface in namespace. + :type node: dict + :type namespace: str + :type interface: str + :raises RuntimeError: Interface could not be attached. + """ + cmd = 'ip link set {0} netns {1}'.format(interface, namespace) + (rc, _, stderr) = exec_cmd(node, cmd, timeout=5, sudo=True) + if rc != 0: + raise RuntimeError( + 'Could not attach interface, reason:{}'.format(stderr)) + cmd = 'ip netns exec {} ip link set {} up'.format( + namespace, interface) + (rc, _, stderr) = exec_cmd(node, cmd, timeout=5, sudo=True) + if rc != 0: + raise RuntimeError( + 'Could not set interface state, reason:{}'.format(stderr)) + + @staticmethod + def create_bridge_for_int_in_namespace( + node, namespace, bridge_name, *interfaces): + """Setup bridge domain and add interfaces to it. + + :param node: Node where to execute command. + :param namespace: Namespace to execute command on. + :param bridge_name: Name of the bridge to be created. + :param interfaces: List of interfaces to add to the namespace. + :type node: dict + :type namespace: str + :type bridge_name: str + :type interfaces: list + """ + cmd = 'ip netns exec {} brctl addbr {}'.format(namespace, bridge_name) + exec_cmd_no_error(node, cmd, sudo=True) + for interface in interfaces: + cmd = 'ip netns exec {} brctl addif {} {}'.format( + namespace, bridge_name, interface) + exec_cmd_no_error(node, cmd, sudo=True) + cmd = 'ip netns exec {} ip link set dev {} up'.format( + namespace, bridge_name) + exec_cmd_no_error(node, cmd, sudo=True) + + def clean_up_namespaces(self, node): + """Remove all old namespaces. + + :param node: Node where to execute command. + :type node: dict + :raises RuntimeError: Namespaces could not be cleaned properly. + """ + for namespace in self._namespaces: + print "Cleaning namespace {}".format(namespace) + cmd = 'ip netns delete {}'.format(namespace) + (rc, stdout, stderr) = exec_cmd(node, cmd, timeout=5, sudo=True) + if rc != 0: + raise RuntimeError('Could not delete namespace') diff --git a/resources/libraries/python/Routing.py b/resources/libraries/python/Routing.py index 199b6de8d5..767fb3aff0 100644 --- a/resources/libraries/python/Routing.py +++ b/resources/libraries/python/Routing.py @@ -15,9 +15,10 @@ from resources.libraries.python.VatExecutor import VatTerminal from resources.libraries.python.topology import Topology - +from resources.libraries.python.ssh import exec_cmd_no_error class Routing(object): + """Routing utilities.""" @staticmethod @@ -93,3 +94,25 @@ class Routing(object): prefix_length=prefix_len, fib_number=fib_id, where=place) + + @staticmethod + def add_route(node, ip, prefix, gw, namespace=None): + """Add route in namespace. + + :param node: Node where to execute command. + :param ip: Route destination IP. + :param prefix: IP prefix. + :param namespace: Execute command in namespace. Optional + :param gw: Gateway. + :type node: dict + :type ip: str + :type prefix: int + :type gw: str + :type namespace: str + """ + if namespace is not None: + cmd = 'ip netns exec {} ip route add {}/{} via {}'.format( + namespace, ip, prefix, gw) + else: + cmd = 'ip route add {}/{} via {}'.format(ip, prefix, gw) + exec_cmd_no_error(node, cmd, sudo=True) diff --git a/resources/libraries/python/Tap.py b/resources/libraries/python/Tap.py new file mode 100644 index 0000000000..6c346860de --- /dev/null +++ b/resources/libraries/python/Tap.py @@ -0,0 +1,107 @@ +# 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. + +"""Tap utilities library.""" + +from resources.libraries.python.VatExecutor import VatTerminal +from resources.libraries.python.InterfaceUtil import InterfaceUtil + + +class Tap(object): + """Tap utilities.""" + + @staticmethod + def add_tap_interface(node, tap_name, mac=None): + """Add tap interface with name and optionally with MAC. + + :param node: Node to add tap on. + :param tap_name: Tap interface name for linux tap. + :param mac: Optional MAC address for VPP tap. + :type node: dict + :type tap_name: str + :type mac: str + :return: Returns a interface index. + :rtype: int + """ + command = 'connect' + if mac is not None: + args = 'tapname {} mac {}'.format(tap_name, mac) + else: + args = 'tapname {}'.format(tap_name) + with VatTerminal(node) as vat: + resp = vat.vat_terminal_exec_cmd_from_template('tap.vat', + tap_command=command, + tap_arguments=args) + return resp[0]['sw_if_index'] + + @staticmethod + def modify_tap_interface(node, if_index, tap_name, mac=None): + """Modify tap interface like linux interface name or VPP MAC. + + :param node: Node to modify tap on. + :param if_index: Index of tap interface to be modified. + :param tap_name: Tap interface name for linux tap. + :param mac: Optional MAC address for VPP tap. + :type node: dict + :type if_index: int + :type tap_name: str + :type mac: str + :return: Returns a interface index. + :rtype: int + """ + command = 'modify' + if mac is not None: + args = 'sw_if_index {} tapname {} mac {}'.format( + if_index, tap_name, mac) + else: + args = 'sw_if_index {} tapname {}'.format(if_index, tap_name) + with VatTerminal(node) as vat: + resp = vat.vat_terminal_exec_cmd_from_template('tap.vat', + tap_command=command, + tap_arguments=args) + return resp[0]['sw_if_index'] + + @staticmethod + def delete_tap_interface(node, if_index): + """Delete tap interface. + + :param node: Node to delete tap on. + :param if_index: Index of tap interface to be deleted. + :type node: dict + :type if_index: int + :raises RuntimeError: Deletion was not successful. + """ + command = 'delete' + args = 'sw_if_index {}'.format(if_index) + with VatTerminal(node) as vat: + resp = vat.vat_terminal_exec_cmd_from_template('tap.vat', + tap_command=command, + tap_arguments=args) + if int(resp[0]['retval']) != 0: + raise RuntimeError( + 'Could not remove tap interface: {}'.format(resp)) + + @staticmethod + def check_tap_present(node, tap_name): + """Check whether specific tap interface exists. + + :param node: Node to check tap on. + :param tap_name: Tap interface name for linux tap. + :type node: dict + :type tap_name: str + :raises RuntimeError: Specified interface was not found. + """ + tap_if = InterfaceUtil.tap_dump(node, tap_name) + if len(tap_if) == 0: + raise RuntimeError( + 'Tap interface :{} does not exist'.format(tap_name)) diff --git a/resources/libraries/robot/traffic.robot b/resources/libraries/robot/traffic.robot index e468700fc8..383eccc0f8 100644 --- a/resources/libraries/robot/traffic.robot +++ b/resources/libraries/robot/traffic.robot @@ -38,8 +38,8 @@ | | ... | TG(if1)->(if1)DUT(if2)->TG(if2) | | ... | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary -| | ... | - src_ip - IP of source interface (TG-if1). Type: int -| | ... | - dst_ip - IP of destination interface (TG-if2). Type: int +| | ... | - src_ip - IP of source interface (TG-if1). Type: string +| | ... | - dst_ip - IP of destination interface (TG-if2). Type: string | | ... | - tx_src_port - Interface of TG-if1. Type: string | | ... | - tx_src_mac - MAC address of TG-if1. Type: string | | ... | - tx_dst_mac - MAC address of DUT-if1. Type: string @@ -79,8 +79,8 @@ | | ... | TG(if1)->(if1)DUT(if2)->TG(if2) | | ... | | ... | - tg_node - Node to execute scripts on (TG). Type: dictionary -| | ... | - src_ip - IP of source interface (TG-if1). Type: int -| | ... | - dst_ip - IP of destination interface (TG-if2). Type: int +| | ... | - src_ip - IP of source interface (TG-if1). Type: string +| | ... | - dst_ip - IP of destination interface (TG-if2). Type: string | | ... | - tx_src_port - Interface of TG-if1. Type: string | | ... | - tx_src_mac - MAC address of TG-if1. Type: string | | ... | - tx_dst_mac - MAC address of DUT-if1. Type: string diff --git a/resources/templates/vat/tap.vat b/resources/templates/vat/tap.vat new file mode 100644 index 0000000000..30cde83d9e --- /dev/null +++ b/resources/templates/vat/tap.vat @@ -0,0 +1 @@ +tap_{tap_command} {tap_arguments} \ No newline at end of file diff --git a/tests/suites/tap/tap_interface.robot b/tests/suites/tap/tap_interface.robot new file mode 100644 index 0000000000..d32a970aca --- /dev/null +++ b/tests/suites/tap/tap_interface.robot @@ -0,0 +1,305 @@ +# 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/ipv4.robot +| Resource | resources/libraries/robot/ipv6.robot +| Resource | resources/libraries/robot/interfaces.robot +| Resource | resources/libraries/robot/bridge_domain.robot +| Resource | resources/libraries/robot/testing_path.robot +| Resource | resources/libraries/robot/traffic.robot +| Library | resources.libraries.python.Trace +| Library | resources.libraries.python.Tap +| Library | resources.libraries.python.Namespaces +| Library | resources.libraries.python.IPUtil +| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO +| Test Setup | Run Keywords | Setup all DUTs before test +| ... | AND | Setup all TGs before traffic script +| ... | AND | Clean Up Namespaces | ${nodes['DUT1']} +| Test Teardown | Run Keywords | Show Packet Trace on All DUTs | ${nodes} +| ... | AND | Clean Up Namespaces | ${nodes['DUT1']} +| Documentation | *Tap Interface Traffic Tests* +| ... | *[Top] Network Topologies:* TG=DUT1 2-node topology with two links +| ... | between nodes. +| ... | *[Enc] Packet Encapsulations:* Eth-IPv4-ICMPv4 for L2 switching of +| ... | IPv4. +| ... | *[Cfg] DUT configuration:* DUT1 and DUT2 are configured with L2 +| ... | bridge-domain (L2BD) MAC learning enabled; Split Horizon Groups (SHG) +| ... | are set depending on test case; Namespaces (NM) +| ... | are set on DUT1 with attached linux-TAP. +| ... | *[Ver] TG verification:* Test ICMPv4 Echo Request packets +| ... | are sent by TG on link to DUT1; On receipt TG verifies packets +| ... | for correctness and their IPv4 src-addr, dst-addr, and MAC addresses. +| ... | *[Ref] Applicable standard specifications:* + +*** Variables *** +| ${tap1_VPP_ip}= | 16.0.10.1 +| ${tap2_VPP_ip}= | 16.0.20.1 + +| ${tap1_NM_ip}= | 16.0.10.2 +| ${tap2_NM_ip}= | 16.0.20.2 +| ${tap2_NM_SHG}= | 16.0.10.3 + +| ${bid_from_TG}= | 19 +| ${bid_to_TG}= | 20 +| ${bid_NM}= | container1_br +| ${bid_TAP}= | tapBr +| ${bd_id1}= | 21 +| ${bd_id2}= | 22 +| ${shg1}= | 2 +| ${shg2}= | 3 + +| ${tap1_NM_mac}= | 02:00:00:00:00:02 +| ${tap2_NM_mac}= | 02:00:00:00:00:04 + +| ${tap_int1}= | tap_int1 +| ${tap_int2}= | tap_int2 +| ${mod_tap_name}= | tap_int1MOD + +| ${namespace1}= | nmspace1 +| ${namespace2}= | nmspace2 + +| ${tg_ip_address}= | 192.168.0.2 +| ${tg_ip_address_SHG}= | 16.0.10.20 +| ${tg_ip_address_GW}= | 192.168.0.0 + +| ${prefix}= | 24 + +*** Test Cases *** +| TC01: Tap Interface Simple BD +| | [Documentation] +| | ... | [Top] TG-DUT1-TG. +| | ... | [Enc] Eth-IPv4-ICMPv4. +| | ... | [Cfg] On DUT1 configure two +| | ... | L2BD with two if's for each L2BD with MAC learning and one L2BD +| | ... | joining two linux-TAP interfaces created by VPP located in namespace. +| | ... | [Ver] Packet sent from TG is passed through all L2BD and received +| | ... | back on TG. Then src_ip, dst_ip and MAC are checked. +| | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']} +| | ... | ${nodes['TG']} +| | And Interfaces in 2-node path are up +| | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} +| | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2} +| | And Set Interface State | ${dut_node} | ${int1} | up +| | And Set Interface State | ${dut_node} | ${int2} | up +| | And Bridge domain on DUT node is created | ${dut_node} +| | ... | ${bid_from_TG} | learn=${TRUE} +| | And Bridge domain on DUT node is created | ${dut_node} +| | ... | ${bid_to_TG} | learn=${TRUE} +| | And Linux Add Bridge | ${dut_node} +| | ... | ${bid_TAP} | ${tap_int1} | ${tap_int2} +| | And Interface is added to bridge domain | ${dut_node} +| | ... | ${int1} | ${bid_to_TG} | 0 +| | And Interface is added to bridge domain | ${dut_node} +| | ... | ${dut_to_tg_if1} | ${bid_to_TG} | 0 +| | And Interface is added to bridge domain | ${dut_node} +| | ... | ${int2} | ${bid_from_TG} | 0 +| | And Interface is added to bridge domain | ${dut_node} +| | ... | ${dut_to_tg_if2} | ${bid_from_TG} | 0 +| | Then Send and receive ICMP Packet | ${tg_node} +| | ... | ${tg_to_dut_if1} | ${tg_to_dut_if2} + +| TC02: Tap Interface IP Ping Without Namespace +| | [Documentation] +| | ... | [Top] TG-DUT1-TG. +| | ... | [Enc] Eth-IPv4-ICMPv4. +| | ... | [Cfg] On DUT1 configure two interface addresses with IPv4 of which +| | ... | one is TAP interface ( dut_to_tg_if and TAP ). +| | ... | and one is linux-TAP. +| | ... | [Ver] Packet sent from TG gets to the destination and ICMP-reply is +| | ... | received on TG. +| | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']} +| | ... | ${nodes['TG']} +| | And Interfaces in 2-node path are up +| | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} | +| | And Set Interface Address +| | ... | ${dut_node} | ${int1} | ${tap1_VPP_ip} | ${prefix} +| | And Set Interface State | ${dut_node} | ${int1} | up +| | And Set Linux Interface MAC | ${dut_node} | ${tap_int1} | ${tap1_NM_mac} +| | And Set Linux Interface IP | ${dut_node} +| | ... | ${tap_int1} | ${tap1_NM_ip} | ${prefix} +| | And Add Route | ${dut_node} +| | ... | ${tg_ip_address_GW} | ${prefix} | ${tap1_VPP_ip} +| | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1} +| | ... | ${tg_ip_address} | ${tg_to_dut_if1_mac} +| | And Add Arp On Dut | ${dut_node} | ${int1} +| | ... | ${tap1_NM_ip} | ${tap1_NM_mac} +| | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1} +| | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if1_mac} +| | ... | ${tap1_NM_ip} | ${tg_ip_address} + +| TC03: Tap Interface IP Ping With Namespace +| | [Documentation] +| | ... | [Top] TG-DUT1-TG. +| | ... | [Enc] Eth-IPv4-ICMPv4. +| | ... | [Cfg] On DUT1 configure two interface addresses with IPv4 of which +| | ... | one is TAP interface ( dut_to_tg_if and TAP ). +| | ... | and one is linux-TAP in namespace. +| | ... | [Ver] Packet sent from TG gets to the destination and ICMP-reply is +| | ... | received on TG. +| | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']} +| | ... | ${nodes['TG']} +| | And Interfaces in 2-node path are up +| | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} | +| | And Set Interface Address +| | ... | ${dut_node} | ${int1} | ${tap1_VPP_ip} | ${prefix} +| | And Set Interface State | ${dut_node} | ${int1} | up +| | When Create Namespace | ${dut_node} | ${namespace1} +| | And Attach Interface To Namespace | ${dut_node} +| | ... | ${namespace1} | ${tap_int1} +| | And Set Linux Interface MAC | ${dut_node} +| | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1} +| | And Set Linux Interface IP | ${dut_node} +| | ... | ${tap_int1} | ${tap1_NM_ip} | ${prefix} | ${namespace1} +| | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1} +| | ... | ${tg_ip_address} | ${tg_to_dut_if1_mac} +| | And Add Arp On Dut | ${dut_node} | ${int1} +| | ... | ${tap1_NM_ip} | ${tap1_NM_mac} +| | And Add Route | ${dut_node} +| | ... | ${tg_ip_address_GW} | ${prefix} | ${tap1_VPP_ip} | ${namespace1} +| | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1} +| | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if1_mac} +| | ... | ${tap1_NM_ip} | ${tg_ip_address} + +| TC04: Tap Interface BD - Different Split Horizon +| | [Documentation] +| | ... | [Top] TG-DUT1-TG. +| | ... | [Enc] Eth-IPv4-ICMPv4. +| | ... | [Cfg] On DUT1 +| | ... | configure one if into L2BD with MAC learning. Add two TAP interfaces +| | ... | into this L2BD and assign them different SHG. Setup two namespaces +| | ... | and assign two linux-TAP interfaces to it respectively. +| | ... | [Ver] Packet is sent from TG to both linux-TAP interfaces and reply +| | ... | is checked. Ping from First linux-TAP to another should pass. +| | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']} +| | ... | ${nodes['TG']} +| | And Interfaces in 2-node path are up +| | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} +| | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2} +| | And Set Interface State | ${dut_node} | ${int1} | up +| | And Set Interface State | ${dut_node} | ${int2} | up +| | When Create Namespace | ${dut_node} | ${namespace1} +| | And Attach Interface To Namespace | ${dut_node} +| | ... | ${namespace1} | ${tap_int1} +| | And Create Namespace | ${dut_node} | ${namespace2} +| | And Attach Interface To Namespace | ${dut_node} +| | ... | ${namespace2} | ${tap_int2} +| | And Set Linux Interface IP | ${dut_node} | ${tap_int1} +| | ... | ${tap1_NM_ip} | ${prefix} | ${namespace1} +| | And Set Linux Interface IP | ${dut_node} | ${tap_int2} +| | ... | ${tap2_NM_SHG} | ${prefix} | ${namespace2} +| | And Set Linux Interface MAC | ${dut_node} +| | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1} +| | And Set Linux Interface MAC | ${dut_node} +| | ... | ${tap_int2} | ${tap2_NM_mac} | ${namespace2} +| | And Set Linux Interface ARP | ${dut_node} | ${tap_int1} +| | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace1} +| | And Set Linux Interface ARP | ${dut_node} | ${tap_int2} +| | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace2} +| | And Bridge domain on DUT node is created | ${dut_node} +| | ... | ${bd_id1} | learn=${TRUE} +| | And Interface is added to bridge domain | ${dut_node} | ${dut_to_tg_if1} +| | ... | ${bd_id1} +| | And Interface is added to bridge domain | ${dut_node} | ${int1} +| | ... | ${bd_id1} | ${shg1} +| | And Interface is added to bridge domain | ${dut_node} | ${int2} +| | ... | ${bd_id1} | ${shg2} +| | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1} +| | ... | ${tap1_NM_mac} | ${tg_to_dut_if1_mac} +| | ... | ${tap1_NM_ip} | ${tg_ip_address_SHG} +| | And Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1} +| | ... | ${tap2_NM_mac} | ${tg_to_dut_if1_mac} +| | ... | ${tap2_NM_SHG} | ${tg_ip_address_SHG} +| | And Send Ping From Node To Dst | ${dut_node} | ${tap1_NM_ip} | namespace=${namespace2} +| | And Send Ping From Node To Dst | ${dut_node} | ${tap2_NM_SHG} | namespace=${namespace1} + +| TC05: Tap Interface BD - Same Split Horizon +| | [Documentation] +| | ... | [Top] TG-DUT1-TG. +| | ... | [Enc] Eth-IPv4-ICMPv4. +| | ... | [Cfg] On DUT1 +| | ... | configure one if into L2BD with MAC learning. Add two TAP interfaces +| | ... | into this L2BD and assign them same SHG. Setup two namespaces +| | ... | and assign two linux-TAP interfaces to it respectively. +| | ... | [Ver] Packet is sent from TG to both linux-TAP interfaces and reply +| | ... | is checked. Ping from First linux-TAP to another should fail. +| | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']} +| | ... | ${nodes['TG']} +| | And Interfaces in 2-node path are up +| | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} +| | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2} +| | And Set Interface State | ${dut_node} | ${int1} | up +| | And Set Interface State | ${dut_node} | ${int2} | up +| | When Create Namespace | ${dut_node} | ${namespace1} +| | And Attach Interface To Namespace | ${dut_node} +| | ... | ${namespace1} | ${tap_int1} +| | And Create Namespace | ${dut_node} | ${namespace2} +| | And Attach Interface To Namespace | ${dut_node} +| | ... | ${namespace2} | ${tap_int2} +| | And Set Linux Interface IP | ${dut_node} | ${tap_int1} +| | ... | ${tap1_NM_ip} | ${prefix} | ${namespace1} +| | And Set Linux Interface IP | ${dut_node} | ${tap_int2} +| | ... | ${tap2_NM_SHG} | ${prefix} | ${namespace2} +| | And Set Linux Interface MAC | ${dut_node} +| | ... | ${tap_int1} | ${tap1_NM_mac} | ${namespace1} +| | And Set Linux Interface MAC | ${dut_node} +| | ... | ${tap_int2} | ${tap2_NM_mac} | ${namespace2} +| | And Set Linux Interface ARP | ${dut_node} | ${tap_int1} +| | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace1} +| | And Set Linux Interface ARP | ${dut_node} | ${tap_int2} +| | ... | ${tg_ip_address_SHG} | ${tg_to_dut_if1_mac} | ${namespace2} +| | And Bridge domain on DUT node is created | ${dut_node} +| | ... | ${bd_id1} | learn=${TRUE} +| | And Interface is added to bridge domain | ${dut_node} | ${dut_to_tg_if1} +| | ... | ${bd_id1} +| | And Interface is added to bridge domain | ${dut_node} | ${int1} +| | ... | ${bd_id1} | ${shg1} +| | And Interface is added to bridge domain | ${dut_node} | ${int2} +| | ... | ${bd_id1} | ${shg1} +| | Then Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1} +| | ... | ${tap1_NM_mac} | ${tg_to_dut_if1_mac} +| | ... | ${tap1_NM_ip} | ${tg_ip_address_SHG} +| | And Node replies to ICMP echo request | ${tg_node} | ${tg_to_dut_if1} +| | ... | ${tap2_NM_mac} | ${tg_to_dut_if1_mac} +| | ... | ${tap2_NM_SHG} | ${tg_ip_address_SHG} +| | And Run Keyword And Expect Error | Ping Not Successful | Send Ping From Node To Dst +| | ... | ${dut_node} | ${tap2_NM_SHG} | namespace=${namespace1} +| | And Run Keyword And Expect Error | Ping Not Successful | Send Ping From Node To Dst +| | ... | ${dut_node} | ${tap1_NM_ip} | namespace=${namespace2} + +| TC06: Tap Interface Modify And Delete +| | [Documentation] +| | ... | [Top] TG-DUT1-TG. +| | ... | [Enc] Eth-IPv4-ICMPv4. +| | ... | [Cfg] Set two TAP interfaces. +| | ... | [Ver] Verify that TAP interface can be modified, deleted, and no other +| | ... | TAP interface is affected. +| | Given Path for 2-node testing is set | ${nodes['TG']} | ${nodes['DUT1']} +| | ... | ${nodes['TG']} +| | And Interfaces in 2-node path are up +| | ${int1}= | And Add Tap Interface | ${dut_node} | ${tap_int1} +| | ${int2}= | And Add Tap Interface | ${dut_node} | ${tap_int2} +| | And Set Interface State | ${dut_node} | ${int1} | up +| | And Set Interface State | ${dut_node} | ${int2} | up +| | When Modify Tap Interface | ${dut_node} | ${int1} | ${mod_tap_name} +| | Then Check Tap Present | ${dut_node} | ${mod_tap_name} +| | When Delete Tap Interface | ${dut_node} | ${int1} +| | Then Run Keyword And Expect Error +| | ... | Tap interface :${mod_tap_name} does not exist +| | ... | Check Tap Present | ${dut_node} | ${mod_tap_name} +| | And Check Tap Present | ${dut_node} | ${tap_int2} +| | When Delete Tap Interface | ${dut_node} | ${int2} +| | Then Run Keyword And Expect Error +| | ... | ValueError: No JSON object could be decoded +| | ... | Check Tap Present | ${dut_node} | ${tap_int2} -- 2.16.6