VIRL test: Dot1Q-L2BD-vhost_user test (CSIT-502) 52/4952/13
authorMatej Klotton <mklotton@cisco.com>
Mon, 30 Jan 2017 18:31:41 +0000 (19:31 +0100)
committerJan Gelety <jgelety@cisco.com>
Fri, 24 Feb 2017 10:45:28 +0000 (10:45 +0000)
- Create test cases to test Dot1Q+L2BD+vhost_user IPv4 and IPv6
  scenarios

Change-Id: I0823e2d22a36fce236c037cfda27d588ebcd1cc5
Signed-off-by: Matej Klotton <mklotton@cisco.com>
resources/libraries/robot/l2_traffic.robot
resources/traffic_scripts/send_ip_icmp.py
tests/func/vlan/eth2p-dot1q-l2bdbasemaclrn-eth-2vhost-1vm-func.robot [new file with mode: 0644]

index 2d149c6..b265316 100644 (file)
 | | ... | - encaps - Encapsulation: Dot1q or Dot1ad (Optional). Type: string
 | | ... | - vlan1 - VLAN (outer) tag (Optional). Type: integer
 | | ... | - vlan2 - VLAN inner tag (Optional). Type: integer
+| | ... | - encaps_rx - Expected encapsulation on RX side: Dot1q or Dot1ad
+| | ... | (Optional). Type: string
+| | ... | - vlan1_rx - VLAN (outer) tag on RX side (Optional). Type: integer
+| | ... | - vlan2_rx - VLAN inner tag on RX side (Optional). Type: integer
 | | ...
 | | ... | *Return:*
 | | ...
 | | ... | \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=100 \|
 | | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
 | | ... | \| ${tg_to_dut2} \| encaps=Dot1ad \| vlan1=110 \| vlan2=220 \|
+| | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
+| | ... | \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=110 \| encaps_rx=Dot1q \|
+| | ... | \| Send and receive ICMP Packet \| ${nodes['TG']} \| ${tg_to_dut1} \
+| | ... | \| ${tg_to_dut2} \| encaps=Dot1q \| vlan1=110 \| encaps_rx=Dot1q \
+| | ... | \| vlan1_rx=120 \|
 | | ...
 | | [Arguments] | ${tg_node} | ${src_int} | ${dst_int}
 | | ... | ${src_ip}=192.168.100.1 | ${dst_ip}=192.168.100.2 | ${encaps}=${EMPTY}
-| | ... | ${vlan1}=${EMPTY} | ${vlan2}=${EMPTY}
+| | ... | ${vlan1}=${EMPTY} | ${vlan2}=${EMPTY} | ${encaps_rx}=${EMPTY}
+| | ... | ${vlan1_rx}=${EMPTY} | ${vlan2_rx}=${EMPTY}
 | | ${src_mac}= | Get Interface Mac | ${tg_node} | ${src_int}
 | | ${dst_mac}= | Get Interface Mac | ${tg_node} | ${dst_int}
 | | ${src_int_name}= | Get interface name | ${tg_node} | ${src_int}
 | | ${dst_int_name}= | Get interface name | ${tg_node} | ${dst_int}
 | | ${args}= | Traffic Script Gen Arg | ${dst_int_name} | ${src_int_name}
 | | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip}
-| | ${args1}= | Run Keyword Unless | '${encaps}' == '${EMPTY}' | Catenate
-| | ... | --encaps ${encaps} | --vlan1 ${vlan1}
-| | ${args2}= | Run Keyword Unless | '${vlan2}' == '${EMPTY}' | Set Variable
-| | ... | --vlan2 ${vlan2}
-| | ${args}= | Run Keyword If | '${args1}' == 'None' | Set Variable | ${args}
-| | ... | ELSE IF | '${args2}' == 'None' | Catenate | ${args} | ${args1}
-| | ... | ELSE | Catenate | ${args} | ${args1} | ${args2}
+| | ${args}= | Run Keyword If | '${encaps}' == '${EMPTY}'
+| | | ...                     | Set Variable | ${args}
+| | ... | ELSE | Catenate | ${args} | --encaps ${encaps} | --vlan1 ${vlan1}
+| | ${args}= | Run Keyword If | '${vlan2}' == '${EMPTY}'
+| | | ...                     | Set Variable | ${args}
+| | ... | ELSE | Catenate | ${args} | --vlan2 ${vlan2}
+| | ${args}= | Run Keyword If | '${encaps_rx}' == '${EMPTY}'
+| | | ...                     | Set Variable | ${args}
+| | ... | ELSE | Catenate | ${args} | --encaps_rx ${encaps_rx}
+| | ${args}= | Run Keyword If | '${vlan1_rx}' == '${EMPTY}'
+| | | ...                     | Set Variable | ${args}
+| | ... | ELSE | Catenate | ${args} | --vlan1_rx ${vlan1_rx}
+| | ${args}= | Run Keyword If | '${vlan2_rx}' == '${EMPTY}'
+| | | ...                     | Set Variable | ${args}
+| | ... | ELSE | Catenate | ${args} | --vlan2_rx ${vlan2_rx}
 | | Run Traffic Script On Node | send_ip_icmp.py | ${tg_node} | ${args}
 
 | Send and receive ICMP Packet should fail
index 140c205..b22b5d3 100755 (executable)
@@ -66,7 +66,8 @@ def main():
     the other one. Dot1q or Dot1ad tagging of the ethernet frame can be set.
     """
     args = TrafficScriptArg(['src_mac', 'dst_mac', 'src_ip', 'dst_ip'],
-                            ['encaps', 'vlan1', 'vlan2'])
+                            ['encaps', 'vlan1', 'vlan2', 'encaps_rx',
+                             'vlan1_rx', 'vlan2_rx'])
 
     src_mac = args.get_arg('src_mac')
     dst_mac = args.get_arg('dst_mac')
@@ -76,6 +77,9 @@ def main():
     encaps = args.get_arg('encaps')
     vlan1 = args.get_arg('vlan1')
     vlan2 = args.get_arg('vlan2')
+    encaps_rx = args.get_arg('encaps_rx')
+    vlan1_rx = args.get_arg('vlan1_rx')
+    vlan2_rx = args.get_arg('vlan2_rx')
 
     tx_if = args.get_arg('tx_if')
     rx_if = args.get_arg('rx_if')
@@ -136,12 +140,35 @@ def main():
     if ether is None:
         raise RuntimeError('ICMP echo Rx timeout')
 
+    if encaps_rx:
+        if encaps_rx == 'Dot1q':
+            if not vlan1_rx:
+                vlan1_rx = vlan1
+            if not ether.haslayer(Dot1Q):
+                raise RuntimeError('Not VLAN tagged Eth frame received:\n{0}'
+                                   .format(ether.__repr__()))
+            elif ether[Dot1Q].vlan != int(vlan1_rx):
+                raise RuntimeError('Ethernet frame with wrong VLAN tag ({}) '
+                                   'received ({} expected):\n{}'.format(
+                    ether[Dot1Q].vlan, vlan1_rx, ether.__repr__()))
+        elif encaps_rx == 'Dot1ad':
+            if not vlan1_rx:
+                vlan1_rx = vlan1
+            if not vlan2_rx:
+                vlan2_rx = vlan2
+            # TODO
+            raise RuntimeError('Encapsulation {0} not implemented yet.'
+                               .format(encaps_rx))
+        else:
+            raise RuntimeError('Unsupported/unknown encapsulation expected: {0}'
+                               .format(encaps_rx))
+
     if not ether.haslayer(ip_format):
-        raise RuntimeError('Not an IP packet received {0}'
+        raise RuntimeError('Not an IP packet received:\n{0}'
                            .format(ether.__repr__()))
 
     if not ether.haslayer(icmp_format):
-        raise RuntimeError('Not an ICMP packet received {0}'
+        raise RuntimeError('Not an ICMP packet received:\n{0}'
                            .format(ether.__repr__()))
 
     sys.exit(0)
diff --git a/tests/func/vlan/eth2p-dot1q-l2bdbasemaclrn-eth-2vhost-1vm-func.robot b/tests/func/vlan/eth2p-dot1q-l2bdbasemaclrn-eth-2vhost-1vm-func.robot
new file mode 100644 (file)
index 0000000..e2f0e3d
--- /dev/null
@@ -0,0 +1,145 @@
+# 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/bridge_domain.robot
+| Resource | resources/libraries/robot/testing_path.robot
+| Resource | resources/libraries/robot/tagging.robot
+| Resource | resources/libraries/robot/l2_traffic.robot
+| Resource | resources/libraries/robot/qemu.robot
+| Resource | resources/libraries/robot/double_qemu_setup.robot
+| Library  | resources.libraries.python.Trace
+| Force Tags | 3_NODE_DOUBLE_LINK_TOPO | HW_ENV | VM_ENV | VPP_VM_ENV
+| Test Setup | Func Test Setup
+| Test Teardown | Run Keywords | Show Packet Trace on All DUTs | ${nodes}
+| ...           | AND | Show vpp trace dump on all DUTs
+| ...           | AND | Stop and Clear QEMU | ${dut_node} | ${vm_node}
+| ...           | AND | Check VPP PID in Teardown
+| Documentation | *L2 bridge domain with VLAN tag over VM test cases*
+| ...
+| ... | *[Top] Network Topologies:* TG=DUT 2-node circular topology
+| ... | with double links between nodes.
+| ... | *[Enc] Packet encapsulations:* Eth-dot1q-IPv4-ICMPv4 or
+| ... | Eth-dot1q-IPv6-ICMPv6 on TG=DUT and on DUT=VM.
+| ... | *[Cfg] DUT configuration:* DUT is configured with two bridge domains
+| ... | (L2BD) with MAC learning enabled; each one with added VLAN
+| ... | sub-interface towards TG and vhost-user interface to local VM. Configure
+| ... | linux bridge on VM to pass traffic between both vhost-user interfaces.
+| ... | *[Ver] TG verification:* Make TG send ICMPv4/ICMPv6 Echo Req between two
+| ... | of its interfaces to be switched by DUT via VM; verify packets are
+| ... | switched between these TG interfaces; on receive TG verifies packets for
+| ... | correctness and their IPv4 src-addr, dst-addr, MAC addresses and
+| ... | VLAN tag.
+| ... | *[Ref] Applicable standard specifications:* IEEE 802.1q.
+
+*** Variables ***
+| ${bd_id1}= | 1
+| ${bd_id2}= | 2
+
+| ${vlan_id1}= | 110
+| ${vlan_wrong}= | 150
+
+| ${sock1}= | /tmp/sock1
+| ${sock2}= | /tmp/sock2
+
+| ${ip4_1}= | 192.168.100.1
+| ${ip4_2}= | 192.168.100.2
+
+| ${ip6_1}= | 3ffe:63::1
+| ${ip6_2}= | 3ffe:63::2
+
+*** Test Cases ***
+| TC01: eth2p-dot1q-l2bdbasemaclrn-eth-2vhost-1vm - ipv4
+| | [Documentation]
+| | ... | [Top] TG=DUT.
+| | ... | [Enc] Eth-dot1q-IPv4-ICMPv4 on TG=DUT and on DUT=VM.
+| | ... | [Cfg] On DUT configure two L2BDs (MAC learning enabled); first L2BD
+| | ... | with Dot1Q tagged interface to TG-if1 and vhost-user interface to
+| | ... | local VM, second one with vhost-user interface to local VM and Dot1Q
+| | ... | tagged interface towards TG-if2. Configure linux bridge on VM to pass
+| | ... | traffic between both vhost-user interfaces.
+| | ... | [Ver] Make TG send ICMPv4 Echo Req tagged with one Dot1q tag
+| | ... | from one of its interfaces to another one via DUT and VM; verify
+| | ... | that packet is received.
+| | ... | [Ref] IEEE 802.1q
+| | ...
+| | Given Path for 2-node testing is set
+| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
+| | And Interfaces in 2-node path are up
+| | ${vlan1_name} | ${vlan1_index}= | When Vlan Subinterface Created
+| | ... | ${dut_node} | ${dut_to_tg_if1} | ${vlan_id1}
+| | ${vlan2_name} | ${vlan2_index}= | And Vlan Subinterface Created
+| | ... | ${dut_node} | ${dut_to_tg_if2} | ${vlan_id1}
+| | And VPP Vhost interfaces for L2BD forwarding are setup
+| | ... | ${dut_node} | ${sock1} | ${sock2}
+| | And VM for Vhost L2BD forwarding is setup
+| | ... | ${dut_node} | ${sock1} | ${sock2}
+| | And Interface is added to bridge domain | ${dut_node} | ${vlan1_index}
+| | ...                                     | ${bd_id1}
+| | And Interface is added to bridge domain | ${dut_node} | ${vhost_if1}
+| | ...                                     | ${bd_id1}
+| | And Interface is added to bridge domain | ${dut_node} | ${vlan2_index}
+| | ...                                     | ${bd_id2}
+| | And Interface is added to bridge domain | ${dut_node} | ${vhost_if2}
+| | ...                                     | ${bd_id2}
+| | Then Send and receive ICMP Packet
+| | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2} | ${ip4_1} | ${ip4_2}
+| | ... | encaps=Dot1q | vlan1=${vlan_id1} | encaps_rx=Dot1q
+| | And Send and receive ICMP Packet
+| | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1} | ${ip4_2} | ${ip4_1}
+| | ... | encaps=Dot1q | vlan1=${vlan_id1} | encaps_rx=Dot1q
+
+| TC01: eth2p-dot1q-l2bdbasemaclrn-eth-2vhost-1vm - ipv6
+| | [Documentation]
+| | ... | [Top] TG=DUT.
+| | ... | [Enc] Eth-dot1q-IPv6-ICMPv6 on TG=DUT and on DUT=VM.
+| | ... | [Cfg] On DUT configure two L2BDs (MAC learning enabled); first L2BD
+| | ... | with Dot1Q tagged interface to TG-if1 and vhost-user interface to
+| | ... | local VM, second one with vhost-user interface to local VM and Dot1Q
+| | ... | tagged interface towards TG-if2. Configure linux bridge on VM to pass
+| | ... | traffic between both vhost-user interfaces.
+| | ... | [Ver] Make TG send ICMPv6 Echo Req tagged with one Dot1q tag
+| | ... | from one of its interfaces to another one via DUT and VM; verify
+| | ... | that packet is received.
+| | ... | [Ref] IEEE 802.1q
+| | ...
+| | Given Path for 2-node testing is set
+| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
+| | And Interfaces in 2-node path are up
+| | ${vlan1_name} | ${vlan1_index}= | When Vlan Subinterface Created
+| | ... | ${dut_node} | ${dut_to_tg_if1} | ${vlan_id1}
+| | ${vlan2_name} | ${vlan2_index}= | And Vlan Subinterface Created
+| | ... | ${dut_node} | ${dut_to_tg_if2} | ${vlan_id1}
+| | And VPP Vhost interfaces for L2BD forwarding are setup
+| | ... | ${dut_node} | ${sock1} | ${sock2}
+| | And VM for Vhost L2BD forwarding is setup
+| | ... | ${dut_node} | ${sock1} | ${sock2}
+| | And Interface is added to bridge domain | ${dut_node} | ${vlan1_index}
+| | ...                                     | ${bd_id1}
+| | And Interface is added to bridge domain | ${dut_node} | ${vhost_if1}
+| | ...                                     | ${bd_id1}
+| | And Interface is added to bridge domain | ${dut_node} | ${vlan2_index}
+| | ...                                     | ${bd_id2}
+| | And Interface is added to bridge domain | ${dut_node} | ${vhost_if2}
+| | ...                                     | ${bd_id2}
+| | Then Send and receive ICMP Packet
+| | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2} | ${ip6_1} | ${ip6_2}
+| | ... | encaps=Dot1q | vlan1=${vlan_id1} | encaps_rx=Dot1q
+| | And Send and receive ICMP Packet
+| | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1} | ${ip6_2} | ${ip6_1}
+| | ... | encaps=Dot1q | vlan1=${vlan_id1} | encaps_rx=Dot1q
+
+
+
+

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.