diff options
Diffstat (limited to 'resources')
17 files changed, 0 insertions, 1193 deletions
diff --git a/resources/libraries/python/SFC/SFCConstants.py b/resources/libraries/python/SFC/SFCConstants.py deleted file mode 100644 index b9eef22788..0000000000 --- a/resources/libraries/python/SFC/SFCConstants.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2017 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. - -""" -This module define some constants. -""" - -class SFCConstants(object): - """ - Define some constants for the test filed verify. - """ - - DEF_SRC_PORT = 1234 - DEF_DST_PORT = 5678 - UDP_PROTOCOL = 17 - VxLAN_UDP_PORT = 4789 - VxLANGPE_UDP_PORT = 4790 - VxLAN_FLAGS = 0x8 - VxLAN_DEFAULT_VNI = 1 - VxLANGPE_FLAGS = 0xc - VxLANGPE_NEXT_PROTOCOL = 0x4 - VxLANGPE_DEFAULT_VNI = 9 - NSH_HEADER_LENGTH = 0x6 - NSH_DEFAULT_MDTYPE = 0x1 - NSH_NEXT_PROTOCOL = 0x3 - NSH_DEFAULT_NSP = 185 - NSH_DEFAULT_NSI = 255 - NSH_DEFAULT_C1 = 3232248395 - NSH_DEFAULT_C2 = 9 - NSH_DEFAULT_C3 = 3232248392 - NSH_DEFAULT_C4 = 50336437 diff --git a/resources/libraries/python/SFC/SFCTest.py b/resources/libraries/python/SFC/SFCTest.py deleted file mode 100644 index 3794d3a2a1..0000000000 --- a/resources/libraries/python/SFC/SFCTest.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright (c) 2017 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. - -""" -This module implements functionality which configure and start -the NSH SFC functional test. -""" - -from resources.libraries.python.ssh import SSH -from resources.libraries.python.Constants import Constants as con -from resources.libraries.python.topology import Topology - - -class SFCTest(object): - """Configure and Start the NSH SFC functional tests.""" - - @staticmethod - def config_and_start_sfc_test(dut_node, dut_if1, dut_if2, if1_adj_mac, - if2_adj_mac, testtype): - """ - Start the SFC functional on the dut_node. - - :param dut_node: Will execute the SFC on this node. - :param dut_if1: The first ingress interface on the DUT. - :param dut_if2: The last egress interface on the DUT. - :param if1_adj_mac: The interface 1 adjacency MAC. - :param if2_adj_mac: The interface 2 adjacency MAC. - :param testtype: The SFC functional test type. - (Classifier, Proxy Inbound, Proxy Outbound, SFF). - :type dut_node: dict - :type dut_if1: str - :type dut_if2: str - :type if1_adj_mac: str - :type if2_adj_mac: str - :type testtype: str - :raises RuntimeError: If the script execute fails. - """ - - vpp_intf_name1 = Topology.get_interface_name(dut_node, dut_if1) - vpp_intf_name2 = Topology.get_interface_name(dut_node, dut_if2) - - ssh = SSH() - ssh.connect(dut_node) - - if testtype == "Classifier": - exec_shell = "set_sfc_classifier.sh" - elif testtype == "Proxy Inbound": - exec_shell = "set_nsh_proxy_inbound.sh" - elif testtype == "Proxy Outbound": - exec_shell = "set_nsh_proxy_outbound.sh" - else: - exec_shell = "set_sfc_sff.sh" - - cmd = 'cd {0}/tests/nsh_sfc/sfc_scripts/ && sudo ./{1} {2} {3} {4} ' \ - '{5}'.format(con.REMOTE_FW_DIR, exec_shell, vpp_intf_name1, - vpp_intf_name2, if1_adj_mac, if2_adj_mac) - - (ret_code, _, _) = ssh.exec_command(cmd, timeout=600) - if ret_code != 0: - raise RuntimeError('Failed to execute SFC setup script ' \ - '{0} at node {1}'.format(exec_shell, dut_node['host'])) diff --git a/resources/libraries/python/SFC/SetupSFCTest.py b/resources/libraries/python/SFC/SetupSFCTest.py deleted file mode 100644 index 7daf49c82d..0000000000 --- a/resources/libraries/python/SFC/SetupSFCTest.py +++ /dev/null @@ -1,226 +0,0 @@ -# Copyright (c) 2018 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. - -"""This module exists to provide setup utilities for the framework on topology -nodes. All tasks required to be run before the actual tests are started is -supposed to end up here. -""" - -from shlex import split -from subprocess import Popen, PIPE, call -from multiprocessing import Pool -from tempfile import NamedTemporaryFile -from os.path import basename - -from robot.api import logger -from robot.libraries.BuiltIn import BuiltIn - -from resources.libraries.python.ssh import SSH -from resources.libraries.python.Constants import Constants as con -from resources.libraries.python.topology import NodeType -from resources.libraries.python.topology import Topology - -__all__ = ["SetupSFCTest"] - - -def pack_framework_dir(): - """Pack the testing WS into temp file, return its name. - - :returns: the temporary package file name. - :rtype: str - :raises RuntimeError: If execute the tar command failed. - """ - - tmpfile = NamedTemporaryFile(suffix=".tgz", prefix="SFC-testing-") - file_name = tmpfile.name - tmpfile.close() - - proc = Popen( - split("tar --exclude-vcs --exclude=./tmp -zcf {0} .".format(file_name)), - stdout=PIPE, stderr=PIPE) - (stdout, stderr) = proc.communicate() - - logger.debug(stdout) - logger.debug(stderr) - - return_code = proc.wait() - if return_code != 0: - raise RuntimeError("Could not pack testing framework.") - - return file_name - - -def copy_tarball_to_node(tarball, node): - """Copy tarball file from local host to remote node. - - :param tarball: Path to tarball to upload. - :param node: Node in the topology where the tarball will be copied to. - :type tarball: str - :type node: dict - :returns: nothing - """ - logger.console('Copying tarball to {0}'.format(node['host'])) - ssh = SSH() - ssh.connect(node) - - ssh.scp(tarball, "/tmp/") - - -def extract_tarball_at_node(tarball, node): - """Extract tarball at given node. - - Extracts tarball using tar on given node to specific CSIT loocation. - - :param tarball: Path to tarball to upload. - :param node: Dictionary created from topology. - :type tarball: str - :type node: dict - :returns: nothing - :raises RuntimeError: If unpack the file failed. - """ - logger.console('Extracting tarball to {0} on {1}'.format( - con.REMOTE_FW_DIR, node['host'])) - ssh = SSH() - ssh.connect(node) - - cmd = 'sudo rm -rf {1}; mkdir {1} ; tar -zxf {0} -C {1}; ' \ - 'rm -f {0}'.format(tarball, con.REMOTE_FW_DIR) - (ret_code, _, stderr) = ssh.exec_command(cmd, timeout=30) - if ret_code != 0: - logger.error('Unpack error: {0}'.format(stderr)) - raise RuntimeError('Failed to unpack {0} at node {1}'.format( - tarball, node['host'])) - - -def create_env_directory_at_node(node): - """Create fresh virtualenv to a directory, install pip requirements. - - :param node: Dictionary created from topology, will only install in the TG - :type node: dict - :returns: nothing - """ - logger.console('Extracting virtualenv, installing requirements.txt ' - 'on {0}'.format(node['host'])) - ssh = SSH() - ssh.connect(node) - (ret_code, stdout, stderr) = ssh.exec_command( - 'cd {0} && rm -rf env && ' - 'virtualenv --system-site-packages --never-download env && ' - '. env/bin/activate && pip install -r requirements.txt' - .format(con.REMOTE_FW_DIR), timeout=100) - if ret_code != 0: - logger.error('Virtualenv creation error: {0}'.format(stdout + stderr)) - raise RuntimeError('Virtualenv setup failed') - else: - logger.console('Virtualenv created on {0}'.format(node['host'])) - -def install_sfc_test(node): - """Prepare the NSH SFC test envrionment. - - :param node: Dictionary created from topology - :type node: dict - :returns: nothing - """ - logger.console('Install the NSH SFC on {0}'.format(node['host'])) - - if_name_list = Topology.get_node_interfaces(node) - - ssh = SSH() - ssh.connect(node) - - (ret_code, _, stderr) = ssh.exec_command( - 'cd {0}/tests/nsh_sfc/sfc_scripts/ && ./install_sfc.sh {1} {2}' - .format(con.REMOTE_FW_DIR, if_name_list[0], if_name_list[1]), \ - timeout=600) - - if ret_code != 0: - logger.error('Install the NSH SFC error: {0}'.format(stderr)) - raise RuntimeError('Install the NSH SFC failed') - else: - logger.console('Install the NSH SFC on {0} success!'. - format(node['host'])) - -def setup_node(args): - """Run all set-up methods for a node. - - This method is used as map_async parameter. It receives tuple with all - parameters as passed to map_async function. - - :param args: All parameters needed to setup one node. - :type args: tuple - :returns: True - success, False - error - :rtype: bool - """ - tarball, remote_tarball, node = args - try: - copy_tarball_to_node(tarball, node) - extract_tarball_at_node(remote_tarball, node) - if node['type'] == NodeType.DUT: - install_sfc_test(node) - if node['type'] == NodeType.TG: - create_env_directory_at_node(node) - except RuntimeError as exc: - logger.error("Node setup failed, error:'{0}'".format(exc.message)) - return False - else: - logger.console('Setup of node {0} done'.format(node['host'])) - return True - -def delete_local_tarball(tarball): - """Delete local tarball to prevent disk pollution. - - :param tarball: Path to tarball to upload. - :type tarball: str - :returns: nothing - """ - call(split('sh -c "rm {0} > /dev/null 2>&1"'.format(tarball))) - - -class SetupSFCTest(object): - """Setup suite run on topology nodes. - - Many VAT/CLI based tests need the scripts at remote hosts before executing - them. This class packs the whole testing directory and copies it over - to all nodes in topology under /tmp/ - """ - - @staticmethod - def setup_nsh_sfc_test(nodes): - """Pack the whole directory and extract in temp on each node.""" - - tarball = pack_framework_dir() - msg = 'Framework packed to {0}'.format(tarball) - logger.console(msg) - logger.trace(msg) - remote_tarball = "/tmp/{0}".format(basename(tarball)) - - # Turn off logging since we use multiprocessing - log_level = BuiltIn().set_log_level('NONE') - params = ((tarball, remote_tarball, node) for node in nodes.values()) - pool = Pool(processes=len(nodes)) - result = pool.map_async(setup_node, params) - pool.close() - pool.join() - - # Turn on logging - BuiltIn().set_log_level(log_level) - - logger.info( - 'Executed node setups in parallel, waiting for processes to end') - result.wait() - - logger.info('Results: {0}'.format(result.get())) - - logger.trace('Test framework copied to all topology nodes') - delete_local_tarball(tarball) - logger.console('All nodes are ready') diff --git a/resources/libraries/python/SFC/TunnelProtocol.py b/resources/libraries/python/SFC/TunnelProtocol.py deleted file mode 100644 index 3248cf9103..0000000000 --- a/resources/libraries/python/SFC/TunnelProtocol.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2017 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. - -""" -This module implements the VxLAN/VXLAN-GPE/NSH protocol -for the packet analyse. -""" -from scapy.all import Packet -from scapy.all import XByteField, ShortField -from scapy.all import BitField, XBitField, IntField - -class VxLAN(Packet): - """Define the vxlan protocol for the packet analysis.""" - name = "vxlan" - fields_desc = [XByteField("flags", 0x08), BitField("reserved", 0, 24), - BitField("vni", 0, 24), XByteField("reserved", 0x00)] - -class VxLANGPE(Packet): - """Define the vxlan-gpe protocol for the packet analysis.""" - name = "vxlan-gpe" - fields_desc = [XByteField("flags", 0x0c), ShortField("reserved", 0), - XByteField("nextproto", 0x3), BitField("vni", 0, 24), - XByteField("reserved", 0x0)] - -class NSH(Packet): - """Define the NSH protocol for the packet analysis.""" - name = "nsh" - fields_desc = [XBitField("Version", 0x0, 2), XBitField("OAM", 0x0, 1), - XBitField("Unassigned", 0x0, 1), XBitField("TTL", 0x0, 6), - XBitField("length", 0x6, 6), XBitField("Unassigned", 0x0, 4), - XBitField("MDtype", 0x1, 4), XByteField("nextproto", 0x3), - IntField("nsp_nsi", 0), IntField("c1", 0), - IntField("c2", 0), IntField("c3", 0), IntField("c4", 0)] diff --git a/resources/libraries/python/SFC/VerifyPacket.py b/resources/libraries/python/SFC/VerifyPacket.py deleted file mode 100644 index a13c7601d5..0000000000 --- a/resources/libraries/python/SFC/VerifyPacket.py +++ /dev/null @@ -1,213 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2017 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. - -""" -This module defines the common functions. -""" - -import ipaddress - -from scapy.layers.inet import IP, UDP -from scapy.all import Raw -from resources.libraries.python.SFC.SFCConstants import SFCConstants as sfccon -from resources.libraries.python.SFC.TunnelProtocol import VxLAN, VxLANGPE, NSH - - -def valid_ipv4(ipaddr): - """Check if IP address has the correct IPv4 address format. - - :param ipaddr: IP address. - :type ipaddr: str - :returns: True in case of correct IPv4 address format, - otherwise return False. - :rtype: bool - """ - try: - ipaddress.IPv4Address(unicode(ipaddr)) - return True - except (AttributeError, ipaddress.AddressValueError): - return False - - -def valid_ipv6(ipaddr): - """Check if IP address has the correct IPv6 address format. - - :param ipaddr: IP address. - :type ipaddr: str - :returns: True in case of correct IPv6 address format, - otherwise return False. - :rtype: bool - """ - try: - ipaddress.IPv6Address(unicode(ipaddr)) - return True - except (AttributeError, ipaddress.AddressValueError): - return False - - -class VerifyPacket(object): - """Define some functions for the test filed verify.""" - - @staticmethod - def check_vxlan_protocol(payload_data): - """ - verify the vxlan protocol in the payload data. - - :param payload_data: the payload data in the packet. - :type payload_data: str - :raises RuntimeError: If the vxlan protocol field verify fails. - """ - # get the vxlan packet and check it - vxlan_pkt = VxLAN(payload_data[0:8]) - if vxlan_pkt.flags != sfccon.VxLAN_FLAGS: - raise RuntimeError("Unexpected Vxlan flags: {0}". - format(vxlan_pkt.flags)) - - if vxlan_pkt.vni != sfccon.VxLAN_DEFAULT_VNI: - raise RuntimeError("Unexpected VNI flag: {0}".format(vxlan_pkt.vni)) - - @staticmethod - def check_vxlangpe_nsh_protocol(payload_data, test_type): - """ - verify the vxlangpe and nsh protocol in the payload data. - - :param payload_data: the payload data in the packet. - :param test_type: the functional test type. - :type payload_data: str - :type test_type: str - :raises RuntimeError: If the vxlangpe and nsh protocol - field verify fails. - """ - # get the vxlan-gpe packet and check it - vxlangpe_pkt = VxLANGPE(payload_data[0:8]) - if vxlangpe_pkt.flags != sfccon.VxLANGPE_FLAGS: - raise RuntimeError("Unexpected Vxlan-GPE flags: {0}". - format(vxlangpe_pkt.flags)) - - if vxlangpe_pkt.nextproto != sfccon.VxLANGPE_NEXT_PROTOCOL: - raise RuntimeError("next protocol not the NSH") - - if vxlangpe_pkt.vni != sfccon.VxLANGPE_DEFAULT_VNI: - raise RuntimeError("Unexpected VNI flag: {0}". - format(vxlangpe_pkt.vni)) - - # get the NSH packet and check it - nsh_pkt = NSH(payload_data[8:32]) - if nsh_pkt.Version != 0: - raise RuntimeError("Unexpected NSH version: {0}". - format(nsh_pkt.Version)) - - if nsh_pkt.OAM != 0 and nsh_pkt.OAM != 1: - raise RuntimeError("Unexpected NSH OAM: {0}". - format(nsh_pkt.OAM)) - - if nsh_pkt.length != sfccon.NSH_HEADER_LENGTH: - raise RuntimeError("NSH length {0} incorrect". - format(nsh_pkt.length)) - - if nsh_pkt.MDtype != sfccon.NSH_DEFAULT_MDTYPE: - raise RuntimeError("NSH MD-Type {0} incorrect". - format(nsh_pkt.MDtype)) - - if nsh_pkt.nextproto != sfccon.NSH_NEXT_PROTOCOL: - raise RuntimeError("NSH next protocol {0} incorrect". - format(nsh_pkt.nextproto)) - - if test_type == "Proxy Outbound" or test_type == "SFF": - expect_nsi = sfccon.NSH_DEFAULT_NSI - 1 - else: - expect_nsi = sfccon.NSH_DEFAULT_NSI - - nsp_nsi = nsh_pkt.nsp_nsi - nsp = nsp_nsi >> 8 - nsi = nsp_nsi & 0x000000FF - if nsp != sfccon.NSH_DEFAULT_NSP: - raise RuntimeError("NSH Service Path ID {0} incorrect".format(nsp)) - - if nsi != expect_nsi: - raise RuntimeError("NSH Service Index {0} incorrect".format(nsi)) - - nsh_c1 = nsh_pkt.c1 - if nsh_c1 != sfccon.NSH_DEFAULT_C1: - raise RuntimeError("NSH c1 {0} incorrect".format(nsh_c1)) - - nsh_c2 = nsh_pkt.c2 - if nsh_c2 != sfccon.NSH_DEFAULT_C2: - raise RuntimeError("NSH c2 {0} incorrect".format(nsh_c2)) - - nsh_c3 = nsh_pkt.c3 - if nsh_c3 != sfccon.NSH_DEFAULT_C3: - raise RuntimeError("NSH c3 {0} incorrect".format(nsh_c3)) - - nsh_c4 = nsh_pkt.c4 - if nsh_c4 != sfccon.NSH_DEFAULT_C4: - raise RuntimeError("NSH c4 {0} incorrect".format(nsh_c4)) - - - @staticmethod - def check_the_nsh_sfc_packet(ether, frame_size, test_type): - """ - verify the NSH SFC functional test loopback packet field - is correct. - - :param ether: The Ethernet packet data. - :param frame_size: The origin frame size. - :param test_type: The test type. - (Classifier, Proxy Inbound, Proxy Outbound, SFF). - - :type ether: scapy.Ether - :type frame_size: Integer - :type test_type: str - :raises RuntimeError: If the packet field verify fails. - """ - - origin_size = int(frame_size) - if test_type == "Classifier": - expect_pkt_len = origin_size + 74 - 4 - elif test_type == "Proxy Inbound": - expect_pkt_len = origin_size - 24 - 4 - elif test_type == "Proxy Outbound": - expect_pkt_len = origin_size + 24 - 4 - else: - expect_pkt_len = origin_size - 4 - - recv_pkt_len = len(ether) - if recv_pkt_len != expect_pkt_len: - raise RuntimeError("Received packet size {0} not " - "the expect size {1}".format(recv_pkt_len, - expect_pkt_len)) - - if not ether.haslayer(IP): - raise RuntimeError("Not a IPv4 packet") - - pkt_proto = ether[IP].proto - if pkt_proto != sfccon.UDP_PROTOCOL: - raise RuntimeError("Not a UDP packet , {0}".format(pkt_proto)) - - if test_type == "Proxy Inbound": - expect_udp_port = sfccon.VxLAN_UDP_PORT - else: - expect_udp_port = sfccon.VxLANGPE_UDP_PORT - - dst_port = ether[UDP].dport - if dst_port != expect_udp_port: - raise RuntimeError("UDP dest port must be {0}, {1}". - format(expect_udp_port, dst_port)) - - payload_data = ether[Raw].load - - if test_type == "Proxy Inbound": - VerifyPacket.check_vxlan_protocol(payload_data) - else: - VerifyPacket.check_vxlangpe_nsh_protocol(payload_data, test_type) diff --git a/resources/libraries/python/SFC/__init__.py b/resources/libraries/python/SFC/__init__.py deleted file mode 100644 index e90d968cca..0000000000 --- a/resources/libraries/python/SFC/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2017 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. - -""" -__init__ file for directory resources/libraries/python/SFC -""" diff --git a/resources/libraries/robot/nsh_sfc/default.robot b/resources/libraries/robot/nsh_sfc/default.robot deleted file mode 100644 index 64d31a9897..0000000000 --- a/resources/libraries/robot/nsh_sfc/default.robot +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) 2017 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 *** -| Variables | resources/libraries/python/topology.py -| Library | resources.libraries.python.topology.Topology -| Library | resources.libraries.python.InterfaceUtil -| Library | resources.libraries.python.SFC.SFCTest -| Library | Collections - -*** Keywords *** -| Setup DUT nodes for '${type}' functional testing -| | [Documentation] | Configure and Start the SFC functional test -| | ... | on the DUT node. -| | ${testtype}= | Convert to String | ${type} -| | Append Nodes | ${nodes['TG']} | ${nodes['DUT1']} -| | ... | ${nodes['TG']} -| | Compute Path | always_same_link=${FALSE} -| | ${tg_to_dut_if1} | ${tg_node}= | First Interface -| | ${tg_to_dut_if2} | ${tg_node}= | Last Interface -| | ${dut_to_tg_if1} | ${dut_node}= | First Ingress Interface -| | ${dut_to_tg_if2} | ${dut_node}= | Last Egress Interface -| | ${tg_to_dut_if1_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut_if1} -| | ${tg_to_dut_if2_mac}= | Get interface mac | ${tg_node} | ${tg_to_dut_if2} -| | ${dut_to_tg_if1_mac}= | Get interface mac | ${dut_node} | ${dut_to_tg_if1} -| | ${dut_to_tg_if2_mac}= | Get interface mac | ${dut_node} | ${dut_to_tg_if2} -| | Set Suite Variable | ${tg_to_dut_if1} -| | Set Suite Variable | ${tg_to_dut_if2} -| | Set Suite Variable | ${dut_to_tg_if1} -| | Set Suite Variable | ${dut_to_tg_if2} -| | Set Suite Variable | ${tg_to_dut_if1_mac} -| | Set Suite Variable | ${tg_to_dut_if2_mac} -| | Set Suite Variable | ${dut_to_tg_if1_mac} -| | Set Suite Variable | ${dut_to_tg_if2_mac} -| | Set Suite Variable | ${tg_node} -| | Set Suite Variable | ${dut_node} -| | Set Interface State | ${tg_node} | ${tg_to_dut_if1} | 'up' -| | Set Interface State | ${tg_node} | ${tg_to_dut_if2} | 'up' -| | Set Interface Ethernet MTU | ${tg_node} | ${tg_to_dut_if1} | 9000 -| | Set Interface Ethernet MTU | ${tg_node} | ${tg_to_dut_if2} | 9000 -| | Config and Start SFC test | ${dut_node} | ${dut_to_tg_if1} -| | ... | ${dut_to_tg_if2} | ${tg_to_dut_if1_mac} | ${tg_to_dut_if2_mac} -| | ... | ${testtype} - - -| Node "${from_node}" interface "${from_port}" send "${size}" Bytes packet to node "${to_node}" interface "${to_port}" for "${type}" test -| | [Documentation] | At the first start the tcpdump on the TG node, -| | ... | then build the packet with the scapy and send the packet to the -| | ... | DUT node, DUT node will receive the packet on the ingress interface -| | ... | DUT will loopback packet to the TG after processed. TG will use -| | ... | the tcpdump to capture the packet and check the packet is correct. -| | ${src_ip}= | Set Variable If | "${type}" == "Classifier" | 10.10.12.101 | 192.168.50.72 -| | ${dst_ip}= | Set Variable If | "${type}" == "Classifier" | 10.10.12.100 | 192.168.50.76 -| | ${src_mac}= | Get interface mac | ${from_node} | ${from_port} -| | ${dst_mac}= | Get interface mac | ${to_node} | ${to_port} -| | ${tx_port_name}= | Get interface name | ${from_node} | ${from_port} -| | ${rx_port_name}= | Get interface name | ${from_node} | ${tg_to_dut_if2} -| | ${timeout}= | Set Variable | 10 -| | ${frame_size}= | Convert To Integer | ${size} -| | ${args}= | Traffic Script Gen Arg | ${rx_port_name} | ${tx_port_name} -| | | ... | ${src_mac} | ${dst_mac} | ${src_ip} | ${dst_ip} -| | ${args}= | Catenate | ${args} | --framesize ${frame_size} -| | | ... | --timeout ${timeout} | --testtype "${type}" -| | Run Keyword If | "${type}" == "Classifier" | Run Traffic Script On Node -| | | | | ... | send_tcp_for_classifier_test.py | ${from_node} | ${args} -| | ... | ELSE IF | "${type}" == "Proxy Inbound" | Run Traffic Script On Node -| | | | | ... | send_vxlangpe_nsh_for_proxy_test.py | ${from_node} | ${args} -| | ... | ELSE IF | "${type}" == "Proxy Outbound" | Run Traffic Script On Node -| | | | | ... | send_vxlan_for_proxy_test.py | ${from_node} | ${args} -| | ... | ELSE | Run Traffic Script On Node | send_vxlangpe_nsh_for_sff_test.py -| | | | | ... | ${from_node} | ${args} diff --git a/resources/tools/doc_gen/src/index.rst b/resources/tools/doc_gen/src/index.rst index 6ba9a2671b..fb12eb517b 100644 --- a/resources/tools/doc_gen/src/index.rst +++ b/resources/tools/doc_gen/src/index.rst @@ -11,7 +11,6 @@ Contents resources.libraries.robot tests.dmm.func tests.dpdk.perf - tests.nsh_sfc.func tests.tldk.func tests.vpp.device tests.vpp.perf diff --git a/resources/tools/doc_gen/src/tests.nsh_sfc.func.rst b/resources/tools/doc_gen/src/tests.nsh_sfc.func.rst deleted file mode 100644 index e06d26dc7c..0000000000 --- a/resources/tools/doc_gen/src/tests.nsh_sfc.func.rst +++ /dev/null @@ -1,3 +0,0 @@ -NSH SFC Functional Tests -======================== - diff --git a/resources/tools/presentation/conf.py b/resources/tools/presentation/conf.py index 9b1a8ef33d..ae781bdac8 100644 --- a/resources/tools/presentation/conf.py +++ b/resources/tools/presentation/conf.py @@ -82,7 +82,6 @@ rst_epilog = """ .. _CSIT DPDK Performance Tests Documentation: https://docs.fd.io/csit/{release}/doc/tests.dpdk.perf.html .. _CSIT VPP Functional Tests Documentation: https://docs.fd.io/csit/{release}/doc/tests.vpp.func.html .. _CSIT VPP Performance Tests Documentation: https://docs.fd.io/csit/{release}/doc/tests.vpp.perf.html -.. _CSIT NSH_SFC Functional Tests Documentation: https://docs.fd.io/csit/{release}/doc/tests.nsh_sfc.func.html .. _CSIT DMM Functional Tests Documentation: https://docs.fd.io/csit/{release}/doc/tests.dmm.func.html .. _CSIT VPP Device Tests Documentation: https://docs.fd.io/csit/{release}/doc/tests.vpp.device.html .. _VPP test framework documentation: https://docs.fd.io/vpp/{vpprelease}/vpp_make_test/html/ @@ -103,7 +102,6 @@ rst_epilog = """ .. _FD.io test executor vpp functional jobs using CentOs: https://jenkins.fd.io/view/csit/job/csit-vpp-functional-{srelease}-centos7-virl .. _FD.io test executor vpp device jobs using Ubuntu: https://jenkins.fd.io/view/csit/job/csit-vpp-device-{srelease}-ubuntu1804-1n-skx .. _FD.io test executor Honeycomb functional jobs: https://jenkins.fd.io/view/csit/job/hc2vpp-csit-integration-{srelease}-ubuntu1604 -.. _FD.io test executor NSH_SFC functional jobs: https://jenkins.fd.io/view/csit/job/csit-nsh_sfc-verify-func-{srelease}-ubuntu1604-virl .. _FD.io test executor DMM functional jobs: https://jenkins.fd.io/view/csit/job/csit-dmm-functional-{srelease}-ubuntu1604-virl .. _FD.io VPP compile job: https://jenkins.fd.io/view/vpp/job/vpp-merge-{srelease}-ubuntu1604/ .. _FD.io DPDK compile job: https://jenkins.fd.io/view/deb-dpdk/job/deb_dpdk-merge-{sdpdkrelease}-ubuntu1604/ diff --git a/resources/tools/presentation/doc/pal_lld.rst b/resources/tools/presentation/doc/pal_lld.rst index e3589ae748..d3a9782681 100644 --- a/resources/tools/presentation/doc/pal_lld.rst +++ b/resources/tools/presentation/doc/pal_lld.rst @@ -170,7 +170,6 @@ The structure of the section "Environment" is as follows (example): DIR[DTR,PERF,DPDK]: "{DIR[DTR]}/dpdk_performance_results" DIR[DTR,PERF,VPP]: "{DIR[DTR]}/vpp_performance_results" DIR[DTR,FUNC,VPP]: "{DIR[DTR]}/vpp_functional_results" - DIR[DTR,FUNC,NSHSFC]: "{DIR[DTR]}/nshsfc_functional_results" DIR[DTR,PERF,VPP,IMPRV]: "{DIR[WORKING,SRC]}/vpp_performance_tests/performance_improvements" # Detailed test configurations @@ -365,10 +364,6 @@ The structure of the section "Debug" is as follows (example): - build: 9 file: "csit-dpdk-perf-1707-all__9.xml" - csit-nsh_sfc-verify-func-1707-ubuntu1604-virl: - - - build: 2 - file: "csit-nsh_sfc-verify-func-1707-ubuntu1604-virl-2.xml" csit-vpp-functional-1707-ubuntu1604-virl: - build: lastSuccessfulBuild @@ -471,9 +466,6 @@ The structure of the section "Input" is as follows (example from 17.07 report): - 9 hc2vpp-csit-integration-1707-ubuntu1604: - lastSuccessfulBuild - csit-nsh_sfc-verify-func-1707-ubuntu1604-virl: - - 2 - Section: Output ''''''''''''''' diff --git a/resources/tools/presentation/specification.yaml b/resources/tools/presentation/specification.yaml index 127768d680..f4ad61686d 100644 --- a/resources/tools/presentation/specification.yaml +++ b/resources/tools/presentation/specification.yaml @@ -45,7 +45,6 @@ DIR[DTR,FUNC,VPP,UBUNTU]: "{DIR[DTR]}/vpp_functional_results_ubuntu" DIR[DTR,FUNC,VPP,CENTOS]: "{DIR[DTR]}/vpp_functional_results_centos" DIR[DTR,FUNC,VPP,DEVICE,UBUNTU]: "{DIR[DTR]}/vpp_device_results_ubuntu" - DIR[DTR,FUNC,NSHSFC]: "{DIR[DTR]}/nshsfc_functional_results" DIR[DTR,FUNC,DMM]: "{DIR[DTR]}/dmm_functional_results" DIR[DTR,PERF,VPP,IMPRV]: "{DIR[WORKING,SRC]}/vpp_performance_tests/performance_improvements" diff --git a/resources/tools/scripts/download_nsh_sfc_pkgs.sh b/resources/tools/scripts/download_nsh_sfc_pkgs.sh deleted file mode 100755 index 2261f084e5..0000000000 --- a/resources/tools/scripts/download_nsh_sfc_pkgs.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2017 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. - -set -ex - -trap 'rm -f *.deb.md5; exit' EXIT -trap 'rm -f *.deb.md5;rm -f *.deb; exit' ERR - -STREAM=$1 -OS=$2 - -URL="https://nexus.fd.io/service/local/artifact/maven/content" -VER="RELEASE" -GROUP="io.fd.vpp" -NSH_GROUP="io.fd.nsh_sfc" -VPP_ARTIFACTS="vpp vpp-dbg vpp-dev vpp-dpdk-dkms vpp-lib vpp-plugins vpp-api-java vpp-api-python vpp-api-lua" -NSH_ARTIFACTS="vpp-nsh-plugin" - -if [ "${OS}" == "ubuntu1404" ]; then - OS="ubuntu.trusty.main" - PACKAGE="deb deb.md5" - CLASS="deb" -elif [ "${OS}" == "ubuntu1604" ]; then - OS="ubuntu.xenial.main" - PACKAGE="deb deb.md5" - CLASS="deb" -elif [ "${OS}" == "centos7" ]; then - OS="centos7" - PACKAGE="rpm rpm.md5" - CLASS="rpm" -fi - -REPO="fd.io.${STREAM}.${OS}" - -for ART in ${VPP_ARTIFACTS}; do - for PAC in $PACKAGE; do - curl "${URL}?r=${REPO}&g=${GROUP}&a=${ART}&p=${PAC}&v=${VER}&c=${CLASS}" -O -J || exit - done -done - -for ART in ${NSH_ARTIFACTS}; do - for PAC in $PACKAGE; do - curl "${URL}?r=${REPO}&g=${NSH_GROUP}&a=${ART}&p=${PAC}&v=${VER}&c=${CLASS}" -O -J || exit - done -done - -for FILE in *.deb; do - echo " "${FILE} >> ${FILE}.md5 -done - -for MD5FILE in *.md5; do - md5sum -c ${MD5FILE} || exit -done diff --git a/resources/traffic_scripts/send_tcp_for_classifier_test.py b/resources/traffic_scripts/send_tcp_for_classifier_test.py deleted file mode 100755 index 5a6873ab4e..0000000000 --- a/resources/traffic_scripts/send_tcp_for_classifier_test.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2017 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 TCP packet -from TG to DUT. -""" -import sys - -from scapy.all import Ether, Packet, Raw -from scapy.layers.inet import IP, TCP -from scapy.layers.inet6 import IPv6, ICMPv6ND_NS - -from resources.libraries.python.SFC.VerifyPacket import * -from resources.libraries.python.SFC.SFCConstants import SFCConstants as SfcCon -from resources.libraries.python.TrafficScriptArg import TrafficScriptArg -from resources.libraries.python.PacketVerifier import RxQueue, TxQueue - - -def main(): - """Send TCP packet from one traffic generator interface to DUT. - - :raises: If the IP address is invalid. - """ - args = TrafficScriptArg(['src_mac', 'dst_mac', 'src_ip', 'dst_ip', - 'timeout', 'framesize', 'testtype']) - - src_mac = args.get_arg('src_mac') - dst_mac = args.get_arg('dst_mac') - src_ip = args.get_arg('src_ip') - dst_ip = args.get_arg('dst_ip') - tx_if = args.get_arg('tx_if') - rx_if = args.get_arg('rx_if') - timeout = int(args.get_arg('timeout')) - frame_size = int(args.get_arg('framesize')) - test_type = args.get_arg('testtype') - - rxq = RxQueue(rx_if) - txq = TxQueue(tx_if) - sent_packets = [] - - protocol = TCP - source_port = SfcCon.DEF_SRC_PORT - destination_port = SfcCon.DEF_DST_PORT - - if valid_ipv4(src_ip) and valid_ipv4(dst_ip): - ip_version = IP - elif valid_ipv6(src_ip) and valid_ipv6(dst_ip): - ip_version = IPv6 - else: - raise ValueError("Invalid IP version!") - - pkt_header = (Ether(src=src_mac, dst=dst_mac) / - ip_version(src=src_ip, dst=dst_ip) / - protocol(sport=int(source_port), dport=int(destination_port))) - - fsize_no_fcs = frame_size - 4 - pad_len = max(0, fsize_no_fcs - len(pkt_header)) - pad_data = "A" * pad_len - - pkt_raw = pkt_header / Raw(load=pad_data) - - # Send created packet on one interface and receive on the other - sent_packets.append(pkt_raw) - txq.send(pkt_raw) - - while True: - ether = rxq.recv(timeout) - if ether is None: - raise RuntimeError('No packet is received!') - - if ether.haslayer(ICMPv6ND_NS): - # read another packet in the queue if the current one is ICMPv6ND_NS - continue - else: - # otherwise process the current packet - break - - # let us begin to check the NSH SFC loopback packet - VerifyPacket.check_the_nsh_sfc_packet(ether, frame_size, test_type) - - # we check all the fields about the loopback packet, this test will pass - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/resources/traffic_scripts/send_vxlan_for_proxy_test.py b/resources/traffic_scripts/send_vxlan_for_proxy_test.py deleted file mode 100755 index d33ed413c8..0000000000 --- a/resources/traffic_scripts/send_vxlan_for_proxy_test.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2017 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 VxLAN packet -from TG to DUT. -""" -import sys -import time - -from scapy.layers.inet import IP, UDP, TCP -from scapy.layers.inet6 import IPv6, ICMPv6ND_NS -from scapy.all import Ether, Packet, Raw - -from resources.libraries.python.SFC.VerifyPacket import * -from resources.libraries.python.SFC.SFCConstants import SFCConstants as SfcCon -from resources.libraries.python.TrafficScriptArg import TrafficScriptArg -from resources.libraries.python.PacketVerifier import RxQueue, TxQueue - - -def main(): - """Send VxLAN packet from TG to DUT. - - :raises: If the IP address is invalid. - """ - args = TrafficScriptArg(['src_mac', 'dst_mac', 'src_ip', 'dst_ip', - 'timeout', 'framesize', 'testtype']) - - src_mac = args.get_arg('src_mac') - dst_mac = args.get_arg('dst_mac') - src_ip = args.get_arg('src_ip') - dst_ip = args.get_arg('dst_ip') - tx_if = args.get_arg('tx_if') - rx_if = args.get_arg('rx_if') - timeout = max(2, int(args.get_arg('timeout'))) - frame_size = int(args.get_arg('framesize')) - test_type = args.get_arg('testtype') - - rxq = RxQueue(rx_if) - txq = TxQueue(tx_if) - sent_packets = [] - - protocol = TCP - source_port = SfcCon.DEF_SRC_PORT - destination_port = SfcCon.DEF_DST_PORT - - if valid_ipv4(src_ip) and valid_ipv4(dst_ip): - ip_version = IP - elif valid_ipv6(src_ip) and valid_ipv6(dst_ip): - ip_version = IPv6 - else: - raise ValueError("Invalid IP version!") - - innerpkt = (Ether(src=src_mac, dst=dst_mac) / - ip_version(src=src_ip, dst=dst_ip) / - protocol(sport=int(source_port), dport=int(destination_port))) - - vxlan = '\x08\x00\x00\x00\x00\x00\x01\x00' - - raw_data = vxlan + str(innerpkt) - - pkt_header = (Ether(src=src_mac, dst=dst_mac) / - ip_version(src=src_ip, dst=dst_ip) / - UDP(sport=int(source_port), dport=4789) / - Raw(load=raw_data)) - - fsize_no_fcs = frame_size - 4 - pad_len = max(0, fsize_no_fcs - len(pkt_header)) - pad_data = "A" * pad_len - - pkt_raw = pkt_header / Raw(load=pad_data) - - # Send created packet on one interface and receive on the other - sent_packets.append(pkt_raw) - txq.send(pkt_raw) - - while True: - ether = rxq.recv(timeout) - if ether is None: - raise RuntimeError('No packet is received!') - - if ether.haslayer(ICMPv6ND_NS): - # read another packet in the queue if the current one is ICMPv6ND_NS - continue - else: - # otherwise process the current packet - break - - # let us begin to check the proxy outbound packet - VerifyPacket.check_the_nsh_sfc_packet(ether, frame_size, test_type) - - # we check all the fields about the proxy outbound, this test will pass - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/resources/traffic_scripts/send_vxlangpe_nsh_for_proxy_test.py b/resources/traffic_scripts/send_vxlangpe_nsh_for_proxy_test.py deleted file mode 100755 index 3ea1f0bc62..0000000000 --- a/resources/traffic_scripts/send_vxlangpe_nsh_for_proxy_test.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2017 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 VxLAN-GPE+NSH packet -from TG to DUT. -""" -import sys - -from scapy.layers.inet import IP, UDP, TCP -from scapy.layers.inet6 import IPv6, ICMPv6ND_NS -from scapy.all import Ether, Packet, Raw - -from resources.libraries.python.SFC.VerifyPacket import * -from resources.libraries.python.SFC.SFCConstants import SFCConstants as SfcCon -from resources.libraries.python.TrafficScriptArg import TrafficScriptArg -from resources.libraries.python.PacketVerifier import RxQueue, TxQueue - - -def main(): - """Send VxLAN-GPE+NSH packet from TG to DUT. - - :raises: If the IP address is invalid. - """ - args = TrafficScriptArg(['src_mac', 'dst_mac', 'src_ip', 'dst_ip', - 'timeout', 'framesize', 'testtype']) - - src_mac = args.get_arg('src_mac') - dst_mac = args.get_arg('dst_mac') - src_ip = args.get_arg('src_ip') - dst_ip = args.get_arg('dst_ip') - tx_if = args.get_arg('tx_if') - rx_if = args.get_arg('rx_if') - timeout = max(2, int(args.get_arg('timeout'))) - frame_size = int(args.get_arg('framesize')) - test_type = args.get_arg('testtype') - - rxq = RxQueue(rx_if) - txq = TxQueue(tx_if) - sent_packets = [] - - protocol = TCP - source_port = SfcCon.DEF_SRC_PORT - destination_port = SfcCon.DEF_DST_PORT - - if valid_ipv4(src_ip) and valid_ipv4(dst_ip): - ip_version = IP - elif valid_ipv6(src_ip) and valid_ipv6(dst_ip): - ip_version = IPv6 - else: - raise ValueError("Invalid IP version!") - - innerpkt = (Ether(src=src_mac, dst=dst_mac) / - ip_version(src=src_ip, dst=dst_ip) / - protocol(sport=int(source_port), dport=int(destination_port))) - - vxlangpe_nsh = '\x0c\x00\x00\x04\x00\x00\x09\x00\x00\x06' \ - '\x01\x03\x00\x00\xb9\xff\xC0\xA8\x32\x4B' \ - '\x00\x00\x00\x09\xC0\xA8\x32\x48\x03\x00\x12\xB5' - - raw_data = vxlangpe_nsh + str(innerpkt) - - pkt_header = (Ether(src=src_mac, dst=dst_mac) / - ip_version(src=src_ip, dst=dst_ip) / - UDP(sport=int(source_port), dport=4790) / - Raw(load=raw_data)) - - fsize_no_fcs = frame_size - 4 - pad_len = max(0, fsize_no_fcs - len(pkt_header)) - pad_data = "A" * pad_len - - pkt_raw = pkt_header / Raw(load=pad_data) - - # Send created packet on one interface and receive on the other - sent_packets.append(pkt_raw) - txq.send(pkt_raw) - - while True: - ether = rxq.recv(timeout) - if ether is None: - raise RuntimeError('No packet is received!') - - if ether.haslayer(ICMPv6ND_NS): - # read another packet in the queue if the current one is ICMPv6ND_NS - continue - else: - # otherwise process the current packet - break - - # let us begin to check the proxy inbound packet - VerifyPacket.check_the_nsh_sfc_packet(ether, frame_size, test_type) - - # we check all the fields about the proxy inbound, this test will pass - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/resources/traffic_scripts/send_vxlangpe_nsh_for_sff_test.py b/resources/traffic_scripts/send_vxlangpe_nsh_for_sff_test.py deleted file mode 100755 index 6879d20f2c..0000000000 --- a/resources/traffic_scripts/send_vxlangpe_nsh_for_sff_test.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2017 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 VxLAN-GPE+NSH packet -from TG to DUT. -""" -import sys - -from scapy.layers.inet import IP, UDP, TCP -from scapy.layers.inet6 import IPv6, ICMPv6ND_NS -from scapy.all import Ether, Packet, Raw - -from resources.libraries.python.SFC.VerifyPacket import * -from resources.libraries.python.SFC.SFCConstants import SFCConstants as SfcCon -from resources.libraries.python.TrafficScriptArg import TrafficScriptArg -from resources.libraries.python.PacketVerifier import RxQueue, TxQueue - - -def main(): - """Send VxLAN-GPE+NSH packet from TG to DUT. - - :raises: If the IP address is invalid. - """ - args = TrafficScriptArg(['src_mac', 'dst_mac', 'src_ip', 'dst_ip', - 'timeout', 'framesize', 'testtype']) - - src_mac = args.get_arg('src_mac') - dst_mac = args.get_arg('dst_mac') - src_ip = args.get_arg('src_ip') - dst_ip = args.get_arg('dst_ip') - tx_if = args.get_arg('tx_if') - rx_if = args.get_arg('rx_if') - timeout = max(2, int(args.get_arg('timeout'))) - frame_size = int(args.get_arg('framesize')) - test_type = args.get_arg('testtype') - - rxq = RxQueue(rx_if) - txq = TxQueue(tx_if) - sent_packets = [] - - protocol = TCP - source_port = SfcCon.DEF_SRC_PORT - destination_port = SfcCon.DEF_DST_PORT - - if valid_ipv4(src_ip) and valid_ipv4(dst_ip): - ip_version = IP - elif valid_ipv6(src_ip) and valid_ipv6(dst_ip): - ip_version = IPv6 - else: - raise ValueError("Invalid IP version!") - - innerpkt = (Ether(src=src_mac, dst=dst_mac) / - ip_version(src=src_ip, dst=dst_ip) / - protocol(sport=int(source_port), dport=int(destination_port))) - - vxlangpe_nsh = '\x0c\x00\x00\x04\x00\x00\x0a\x00\x00\x06' \ - '\x01\x03\x00\x00\xb9\xff\xC0\xA8\x32\x4B' \ - '\x00\x00\x00\x09\xC0\xA8\x32\x48\x03\x00\x12\xB5' - - raw_data = vxlangpe_nsh + str(innerpkt) - - pkt_header = (Ether(src=src_mac, dst=dst_mac) / - ip_version(src=src_ip, dst=dst_ip) / - UDP(sport=int(source_port), dport=4790) / - Raw(load=raw_data)) - - fsize_no_fcs = frame_size - 4 - pad_len = max(0, fsize_no_fcs - len(pkt_header)) - pad_data = "A" * pad_len - - pkt_raw = pkt_header / Raw(load=pad_data) - - # Send created packet on one interface and receive on the other - sent_packets.append(pkt_raw) - txq.send(pkt_raw) - - while True: - ether = rxq.recv(timeout) - if ether is None: - raise RuntimeError('No packet is received!') - - if ether.haslayer(ICMPv6ND_NS): - # read another packet in the queue if the current one is ICMPv6ND_NS - continue - else: - # otherwise process the current packet - break - - # let us begin to check the sfc sff packet - VerifyPacket.check_the_nsh_sfc_packet(ether, frame_size, test_type) - - # we check all the fields about the sfc sff, this test will pass - sys.exit(0) - - -if __name__ == "__main__": - main() |