diff options
Diffstat (limited to 'resources')
8 files changed, 105 insertions, 86 deletions
diff --git a/resources/libraries/python/SFC/SFCTest.py b/resources/libraries/python/SFC/SFCTest.py index 456457f9f6..ec08efd17c 100644 --- a/resources/libraries/python/SFC/SFCTest.py +++ b/resources/libraries/python/SFC/SFCTest.py @@ -24,24 +24,30 @@ class SFCTest(object): """Configure and Start the NSH SFC functional tests.""" @staticmethod - def config_and_start_SFC_test(dut_node, dut_port, adj_mac, testtype): + 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_port: The ingress interface on the DUT. - :param adj_mac: The adjacency interface MAC. + :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_port: str - :type adj_mac: str + :type dut_if1: str + :type dut_if2: str + :type if1_adj_mac: str + :type if2_adj_mac: str :type testtype: str :returns: none :raises RuntimeError: If the script execute fails. """ - vpp_intf_name = Topology.get_interface_name(dut_node, dut_port) + 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) @@ -55,39 +61,11 @@ class SFCTest(object): else: exec_shell = "set_sfc_sff.sh" - cmd = 'cd {0}/nsh_sfc_tests/sfc_scripts/ && sudo ./{1} {2} ' \ - '{3} {4}'.format(con.REMOTE_FW_DIR, exec_shell, vpp_intf_name, - adj_mac, dut_port) + 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'])) - - @staticmethod - def start_the_tcpdump_on_the_node(from_node, from_port, filter_ip): - """ - Start the tcpdump on the frome_node. - - :param from_node: Will execute the tcpdump on this node. - :param from_port: Will capture the packets on this interface. - :param filter_ip: filter the dest ip. - :type from_node: dict - :type from_port: str - :type filter_ip: str - :returns: none - :raises RuntimeError: If the script "start_tcpdump.sh" fails. - """ - - interface_name = Topology.get_interface_name(from_node, from_port) - - ssh = SSH() - ssh.connect(from_node) - - cmd = 'cd {0}/nsh_sfc_tests/sfc_scripts/ && sudo ./start_tcpdump.sh ' \ - '{1} {2}'.format(con.REMOTE_FW_DIR, interface_name, filter_ip) - - (ret_code, _, _) = ssh.exec_command(cmd, timeout=600) - if ret_code != 0: - raise RuntimeError('Failed to exec start_tcpdump.sh at node {0}'. - format(from_node['host'])) diff --git a/resources/libraries/python/SFC/SetupSFCTest.py b/resources/libraries/python/SFC/SetupSFCTest.py index d481202837..a1d99c5cc6 100644 --- a/resources/libraries/python/SFC/SetupSFCTest.py +++ b/resources/libraries/python/SFC/SetupSFCTest.py @@ -139,7 +139,7 @@ def install_sfc_test(node): ssh.connect(node) (ret_code, _, stderr) = ssh.exec_command( - 'cd {0}/nsh_sfc_tests/sfc_scripts/ && ./install_sfc.sh {1} {2}' + '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) diff --git a/resources/libraries/python/SFC/VerifyPacket.py b/resources/libraries/python/SFC/VerifyPacket.py index 66bd09899d..fd72bb296b 100644 --- a/resources/libraries/python/SFC/VerifyPacket.py +++ b/resources/libraries/python/SFC/VerifyPacket.py @@ -20,7 +20,6 @@ import ipaddress from scapy.layers.inet import IP, UDP from scapy.all import Raw -from scapy.utils import rdpcap from resources.libraries.python.constants import Constants as con from resources.libraries.python.SFC.SFCConstants import SFCConstants as sfccon from resources.libraries.python.SFC.TunnelProtocol import VxLAN, VxLANGPE, NSH @@ -157,31 +156,23 @@ class VerifyPacket(object): @staticmethod - def check_the_nsh_sfc_packet(frame_size, test_type): + def check_the_nsh_sfc_packet(ether, frame_size, test_type): """ verify the NSH SFC functional test loopback packet field is correct. - :param frame_size: the origin frame size. - :param test_type: the test type. + :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 :returns: none :raises RuntimeError: If the packet field verify fails. """ - rx_pcapfile = '{0}/nsh_sfc_tests/sfc_scripts/temp_packet.pcap' \ - .format(con.REMOTE_FW_DIR) - - logger.trace('read pcap file:{0}'.format(rx_pcapfile)) - - packets = rdpcap(rx_pcapfile) - if len(packets) < 1: - raise RuntimeError("No packet is received!") - - ether = packets[0] - origin_size = int(frame_size) if test_type == "Classifier": expect_pkt_len = origin_size + 74 - 4 diff --git a/resources/libraries/robot/nsh_sfc/default.robot b/resources/libraries/robot/nsh_sfc/default.robot index fc70523cdd..64d31a9897 100644 --- a/resources/libraries/robot/nsh_sfc/default.robot +++ b/resources/libraries/robot/nsh_sfc/default.robot @@ -24,18 +24,34 @@ | | ... | on the DUT node. | | ${testtype}= | Convert to String | ${type} | | Append Nodes | ${nodes['TG']} | ${nodes['DUT1']} -| | Compute Path -| | ${src_port} | ${src_node}= | First Interface -| | ${dst_port} | ${dst_node}= | Last Interface -| | Set Suite Variable | ${src_node} -| | Set Suite Variable | ${src_port} -| | Set Suite Variable | ${dst_node} -| | Set Suite Variable | ${dst_port} -| | Set Interface State | ${src_node} | ${src_port} | 'up' -| | Set Interface Ethernet MTU | ${src_node} | ${src_port} | 9000 -| | ${adj_mac}= | Get interface mac | ${src_node} | ${src_port} -| | Config and Start SFC test | ${dst_node} | ${dst_port} -| | ... | ${adj_mac} | ${testtype} +| | ... | ${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, @@ -43,17 +59,15 @@ | | ... | 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. -| | ${filter_dst_ip}= | Set Variable | 192.168.50.71 -| | Start the tcpdump on the Node | ${from_node} | ${from_port} | ${filter_dst_ip} | | ${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} -| | ${from_port_name}= | Get interface name | ${from_node} | ${from_port} -| | ${to_port_name}= | Get interface name | ${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 | ${from_port_name} | ${from_port_name} +| | ${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}" diff --git a/resources/traffic_scripts/send_tcp_for_classifier_test.py b/resources/traffic_scripts/send_tcp_for_classifier_test.py index f08816eaae..5d8d387767 100755 --- a/resources/traffic_scripts/send_tcp_for_classifier_test.py +++ b/resources/traffic_scripts/send_tcp_for_classifier_test.py @@ -22,11 +22,11 @@ import time from scapy.layers.inet import IP, UDP, TCP from scapy.layers.inet6 import IPv6 from scapy.all import Ether, Packet, Raw -from scapy.all import sendp 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 from robot.api import logger @@ -49,6 +49,10 @@ def main(): 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 @@ -71,12 +75,17 @@ def main(): pkt_raw = pkt_header / Raw(load=pad_data) - sendp(pkt_raw, iface=tx_if, count=3) + # Send created packet on one interface and receive on the other + sent_packets.append(pkt_raw) + txq.send(pkt_raw) + + ether = rxq.recv(timeout) - time.sleep(timeout) + if ether is None: + raise RuntimeError("No packet is received!") # let us begin to check the NSH SFC loopback packet - VerifyPacket.check_the_nsh_sfc_packet(frame_size, test_type) + 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) diff --git a/resources/traffic_scripts/send_vxlan_for_proxy_test.py b/resources/traffic_scripts/send_vxlan_for_proxy_test.py index 4087c7f6d8..c356e1977e 100755 --- a/resources/traffic_scripts/send_vxlan_for_proxy_test.py +++ b/resources/traffic_scripts/send_vxlan_for_proxy_test.py @@ -21,11 +21,11 @@ import time from scapy.layers.inet import IP, UDP, TCP from scapy.layers.inet6 import IPv6 from scapy.all import Ether, Packet, Raw -from scapy.all import sendp 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 from robot.api import logger @@ -48,6 +48,10 @@ def main(): 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 @@ -79,12 +83,17 @@ def main(): pkt_raw = pkt_header / Raw(load=pad_data) - sendp(pkt_raw, iface=tx_if, count=3) + # Send created packet on one interface and receive on the other + sent_packets.append(pkt_raw) + txq.send(pkt_raw) + + ether = rxq.recv(2) - time.sleep(timeout) + if ether is None: + raise RuntimeError("No packet is received!") # let us begin to check the proxy outbound packet - VerifyPacket.check_the_nsh_sfc_packet(frame_size, test_type) + 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) diff --git a/resources/traffic_scripts/send_vxlangpe_nsh_for_proxy_test.py b/resources/traffic_scripts/send_vxlangpe_nsh_for_proxy_test.py index ea1f9b15a7..d998d7c6a0 100755 --- a/resources/traffic_scripts/send_vxlangpe_nsh_for_proxy_test.py +++ b/resources/traffic_scripts/send_vxlangpe_nsh_for_proxy_test.py @@ -21,11 +21,11 @@ import time from scapy.layers.inet import IP, UDP, TCP from scapy.layers.inet6 import IPv6 from scapy.all import Ether, Packet, Raw -from scapy.all import sendp 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 from robot.api import logger @@ -48,6 +48,10 @@ def main(): 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 @@ -81,12 +85,17 @@ def main(): pkt_raw = pkt_header / Raw(load=pad_data) - sendp(pkt_raw, iface=tx_if, count=3) + # Send created packet on one interface and receive on the other + sent_packets.append(pkt_raw) + txq.send(pkt_raw) + + ether = rxq.recv(2) - time.sleep(timeout) + if ether is None: + raise RuntimeError("No packet is received!") # let us begin to check the proxy inbound packet - VerifyPacket.check_the_nsh_sfc_packet(frame_size, test_type) + 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) diff --git a/resources/traffic_scripts/send_vxlangpe_nsh_for_sff_test.py b/resources/traffic_scripts/send_vxlangpe_nsh_for_sff_test.py index b82e2a8938..55c06f0691 100755 --- a/resources/traffic_scripts/send_vxlangpe_nsh_for_sff_test.py +++ b/resources/traffic_scripts/send_vxlangpe_nsh_for_sff_test.py @@ -21,11 +21,11 @@ import time from scapy.layers.inet import IP, UDP, TCP from scapy.layers.inet6 import IPv6 from scapy.all import Ether, Packet, Raw -from scapy.all import sendp 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 from robot.api import logger @@ -48,6 +48,10 @@ def main(): 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 @@ -81,12 +85,17 @@ def main(): pkt_raw = pkt_header / Raw(load=pad_data) - sendp(pkt_raw, iface=tx_if, count=3) + # Send created packet on one interface and receive on the other + sent_packets.append(pkt_raw) + txq.send(pkt_raw) + + ether = rxq.recv(2) - time.sleep(timeout) + if ether is None: + raise RuntimeError("No packet is received!") # let us begin to check the sfc sff packet - VerifyPacket.check_the_nsh_sfc_packet(frame_size, test_type) + 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) |