def __init__(self): BaseTest.__init__(self) self.sniff_timeout = testutils.test_params_get().get("sniff_timeout") self.sniff_filter = testutils.test_params_get().get("sniff_filter") self.capture_pcap = testutils.test_params_get().get("capture_pcap") self.sniffer_log = testutils.test_params_get().get("sniffer_logs") self.port_filter_expression = testutils.test_params_get().get("port_filter_expression")
def setUp(self): if config["use_pswitch"] == 0: global interface_to_front_mapping BaseTest.setUp(self) self.test_params = testutils.test_params_get() self.loadPortMap() self.createRpcClient() return if config["use_pswitch"] == 1: BaseTest.setUp(self) self.test_params = testutils.test_params_get() self.loadPortMap() self.createRpcClient() return
def runTest(self): pkt = scapy2.Ether(src="e4:1d:2d:a5:f3:ac", dst="00:02:03:04:05:00") pkt /= scapy2.IP(src="20.0.0.2", dst="20.0.0.1") # get L4 port number port_number = testutils.test_params_get("port_number") port = port_number["port_number"] pkt /= scapy2.TCP(sport=int(port)) pkt /= ("badabadaboom") # get packets number count = testutils.test_params_get("count") pack_number = count["count"] # send packets send(self, 0, pkt, int(pack_number))
def setUp(self): global interface_to_front_mapping BaseTest.setUp(self) self.test_params = testutils.test_params_get() self.loadPortMap() self.createRpcClient() return
def setUp(self): self.dataplane = ptf.dataplane_instance self.test_params = test_params_get() self.dut_mac = self.test_params['dut_mac'] self.vxlan_port = self.test_params['vxlan_port'] self.expect_encap_success = self.test_params['expect_encap_success'] self.packet_count = self.test_params['packet_count'] # The ECMP check fails occasionally if there is not enough packets. # We should keep the packet count atleast MIN_PACKET_COUNT. if self.packet_count < MIN_PACKET_COUNT: logger.warning("Packet_count is below minimum, resetting to {}", MIN_PACKET_COUNT) self.packet_count = MIN_PACKET_COUNT self.random_mac = "00:aa:bb:cc:dd:ee" self.ptf_mac_addrs = read_ptf_macs() with open(self.test_params['config_file']) as fp: self.config_data = json.load(fp) with open(self.test_params['topo_file']) as fp: self.topo_data = json.load(fp) self.fill_loopback_ip() self.t2_ports = self.test_params['t2_ports'] self.nbr_info = self.config_data['neighbors'] self.packets = [] self.dataplane.flush() self.vxlan_enabled = True return
def __init__(self): BaseTest.__init__(self) self.log_fp = open('/tmp/copp.log', 'a') test_params = testutils.test_params_get() self.verbose = 'verbose' in test_params and test_params['verbose'] self.pkt_tx_count = test_params.get('pkt_tx_count', self.PKT_TX_COUNT) if self.pkt_tx_count == 0: self.pkt_tx_count = self.PKT_TX_COUNT self.pkt_rx_limit = self.pkt_tx_count * 0.90 target_port_str = test_params.get('target_port', self.TARGET_PORT) self.target_port = int(target_port_str) self.timeout_thr = None self.minig_bgp = test_params.get('minig_bgp', None) idx = 0 self.myip = {} self.peerip = {} for peer in self.minig_bgp: if str(peer['peer_addr']).find('10.0.0') == 0:#filter IPv6 info. self.myip[idx] = peer['addr'] self.peerip[idx] = peer['peer_addr'] idx = idx+1 #if port number is out of the total of IPv4, take the last IPv4 if int(target_port_str) > idx-1: self.myip[self.target_port] = self.myip[idx-1] self.peerip[self.target_port] = self.peerip[idx-1] return
def __init__(self): self.test_params = testutils.test_params_get() self.client_port_index = int(self.test_params['client_port_index']) self.client_link_local = self.generate_client_interace_ipv6_link_local_address( self.client_port_index) DataplaneBaseTest.__init__(self)
def setUp(self): """ Sets up Populate FDB instance data Args: None Returns: None """ self.dataplane = ptf.dataplane_instance self.dataplane.flush() self.testParams = testutils.test_params_get() self.packetCount = self.testParams["packet_count"] self.startMac = self.testParams["start_mac"] self.configFile = self.testParams["config_data"] with open(self.configFile) as fp: self.configData = json.load(fp) self.dutMac = self.configData["dut_mac"] self.macToIpRatio = [int(i) for i in self.testParams["mac_to_ip_ratio"].split(':')] self.assertTrue( len(self.macToIpRatio) == 2 and self.macToIpRatio[0] > 0 and self.macToIpRatio[1] > 0, "Invalid MAC to IP ratio: {0}".format(self.testParams["mac_to_ip_ratio"]) ) if config["log_dir"] is not None: filename = os.path.join(config["log_dir"], str(self)) + ".pcap" self.dataplane.start_pcap(filename)
def __init__(self): BaseTest.__init__(self) self.fails = {} self.info = {} self.cli_info = {} self.logs_info = {} self.log_fp = open('/tmp/fast-reboot.log', 'w') self.test_params = testutils.test_params_get() self.check_param('verbose', False, required=False) self.check_param('dut_username', '', required=True) self.check_param('dut_hostname', '', required=True) self.check_param('fast_reboot_limit', 30, required=False) self.check_param('graceful_limit', 120, required=False) self.check_param('portchannel_ports_file', '', required=True) self.check_param('vlan_ports_file', '', required=True) self.check_param('ports_file', '', required=True) self.check_param('dut_mac', '', required=True) self.check_param('default_ip_range', '', required=True) self.check_param('vlan_ip_range', '', required=True) self.check_param('lo_prefix', '10.1.0.32/32', required=False) self.check_param('lo_v6_prefix', 'fc00:1::/64', required=False) self.check_param('arista_vms', [], required=True) self.check_param('min_bgp_gr_timeout', 15, required=False) # Default settings self.nr_pc_pkts = 100 self.nr_tests = 3 self.reboot_delay = 10 self.task_timeout = 300 # Wait up to 5 minutes for tasks to complete self.max_nr_vl_pkts = 500 # FIXME: should be 1000. # But ptf is not fast enough + swss is slow for FDB and ARP entries insertions self.timeout_thr = None return
def setUp(self): ''' @summary: Setup for the test ''' self.dataplane = ptf.dataplane_instance self.test_params = testutils.test_params_get() self.max_deviation = 0.25 if 'test_case' in self.test_params: self.test_case = self.test_params['test_case'] else: raise Exception("Need a test case param") if self.test_case == 'withdraw_nh': self.withdraw_nh_port = self.test_params['withdraw_nh_port'] elif self.test_case == 'add_nh': self.add_nh_port = self.test_params['add_nh_port'] elif self.test_case == 'withdraw_bank': self.withdraw_nh_bank = self.test_params['withdraw_nh_bank'] elif self.test_case == 'add_first_nh': self.first_nh = self.test_params['first_nh'] if 'config_file' not in self.test_params: raise Exception("required parameter 'config_file' is not present") config = self.test_params['config_file'] if 'exp_flow_count' not in self.test_params: raise Exception( "required parameter 'exp_flow_count' is not present") self.exp_flow_count = self.test_params['exp_flow_count'] if not os.path.isfile(config): raise Exception("the config file %s doesn't exist" % config) with open(config) as fp: graph = json.load(fp) self.net_ports = graph['net_ports'] self.exp_ports = graph['port_list'] self.exp_port_set_one = graph['bank_0_port'] self.exp_port_set_two = graph['bank_1_port'] self.dst_ip = graph['dst_ip'] self.router_mac = graph['dut_mac'] self.ip_to_port = graph['ip_to_port'] self.num_flows = graph['num_flows'] self.inner_hashing = graph['inner_hashing'] self.log(self.net_ports) self.log(self.exp_ports) self.log(self.exp_port_set_one) self.log(self.exp_port_set_two) self.log(self.dst_ip) self.log(self.router_mac) self.log(self.test_case) self.log(self.ip_to_port) self.log(self.num_flows) self.log(self.inner_hashing) self.log(self.exp_flow_count) self.trigger_mac_learning(self.ip_to_port) time.sleep(3)
def __init__(self): ''' @summary: constructor ''' BaseTest.__init__(self) self.test_params = test_params_get() self.check_required_params()
def setUp(self): DataplaneBaseTest.setUp(self) self.test_params = testutils.test_params_get() # These are the interfaces we are injected into that link to out leaf switches self.server_port_indices = ast.literal_eval( self.test_params['leaf_port_indices']) self.num_dhcp_servers = int(self.test_params['num_dhcp_servers']) self.server_ip = self.test_params['server_ip'] self.relay_iface_name = self.test_params['relay_iface_name'] self.relay_iface_ip = self.test_params['relay_iface_ip'] self.relay_iface_mac = self.test_params['relay_iface_mac'] self.client_port_index = int(self.test_params['client_port_index']) self.client_iface_mac = self.dataplane.get_mac(0, self.client_port_index) # relay_agent_info is a byte string created by the relay agent to specify which # interface it received the message on. It is stored as suboption 1 of option 82. # It consists of the following: # Byte 0: Suboption number, always set to 1 # Byte 1: Length of suboption data in bytes (i.e., length of interface name) # Bytes 2+: Suboption data (interface name) self.relay_agent_info = struct.pack('BB', 1, len(self.relay_iface_name)) self.relay_agent_info += self.relay_iface_name # We'll assign our client the IP address 1 greater than our relay interface (i.e., gateway) IP self.client_ip = incrementIpAddress(self.relay_iface_ip, 1) self.client_subnet = self.test_params['relay_iface_netmask']
def setUp(self): """ Fetches all the parameters we need to run the tests. """ self.dataplane = ptf.dataplane_instance self.test_params = testutils.test_params_get() self.hwsku = self.test_params['hwsku'] self.asic_type = self.test_params['asic_type'] self.router_mac = self.test_params['router_mac'] self.src_port = int(self.test_params['src_port']) self.mirror_stage = self.test_params['mirror_stage'] self.dst_mirror_ports = [ int(p) for p in self.test_params['dst_mirror_ports'].split(",") if p ] self.dst_ports = [ int(p) for p in self.test_params['dst_ports'].split(",") ] self.base_pkt = testutils.simple_arp_packet( eth_dst=self.router_mac, eth_src=self.dataplane.get_mac(0, 0)) self.basev6_pkt = testutils.simple_icmpv6_packet( eth_dst=self.router_mac, eth_src=self.dataplane.get_mac(0, 0), icmp_type=135) testutils.add_filter(self.gre_filter)
def runTest(self): params = testutils.test_params_get(default=None) if params is None: print(">>>None") else: for k, v in params.items(): print(">>>{}={}".format(k, v))
def setUp(self): super(P4EbpfTest, self).setUp() if self.skip: self.skipTest(self.skip_reason) if not os.path.exists(self.p4_file_path): self.fail("P4 program not found, no such file.") if not os.path.exists("ptf_out"): os.makedirs("ptf_out") head, tail = os.path.split(self.p4_file_path) filename = tail.split(".")[0] self.test_prog_image = os.path.join("ptf_out", filename + ".o") p4args = "--Wdisable=unused --max-ternary-masks 3" if self.is_trace_logs_enabled(): p4args += " --trace" if "xdp2tc" in testutils.test_params_get(): p4args += " --xdp2tc=" + self.xdp2tc_mode() logger.info("P4ARGS=" + p4args) self.exec_cmd( "make -f ../runtime/kernel.mk BPFOBJ={output} P4FILE={p4file} " "ARGS=\"{cargs}\" P4C=p4c-ebpf P4ARGS=\"{p4args}\" psa".format( output=self.test_prog_image, p4file=self.p4_file_path, cargs="-DPSA_PORT_RECIRCULATE=2", p4args=p4args), "Compilation error") self.dataplane = ptf.dataplane_instance self.dataplane.flush() logger.info("\nUsing test params: %s", testutils.test_params_get()) if "namespace" in testutils.test_params_get(): self.switch_ns = testutils.test_param_get("namespace") self.interfaces = testutils.test_param_get("interfaces").split(",") self.exec_ns_cmd( "psabpf-ctl pipeline load id {} {}".format(TEST_PIPELINE_ID, self.test_prog_image), "Can't load programs into eBPF subsystem") for intf in self.interfaces: self.add_port(dev=intf)
def __init__(self): BaseTest.__init__(self) self.test_params = testutils.test_params_get() self.myip = self.my_ip self.peerip = self.peer_ip self.init_interfaces() return
def get_param(self, param_name, required=True, default = None): params = testutils.test_params_get() if param_name not in params: if required: raise Exception("required parameter '%s' is not presented" % param_name) else: return default else: return params[param_name]
def __init__(self): sai_base_test.ThriftInterfaceDataPlane.__init__(self) self.test_params = testutils.test_params_get() self.myip = self.my_ip self.peerip = self.peer_ip self.myipv6ip = self.my_ipv6_ip self.peeripv6ip = self.peer_ipv6_ip self.init_interfaces() return
def setUp(self): DataplaneBaseTest.setUp(self) self.test_params = testutils.test_params_get() self.hostname = self.test_params['hostname'] # These are the interfaces we are injected into that link to out leaf switches self.server_port_indices = ast.literal_eval( self.test_params['leaf_port_indices']) self.num_dhcp_servers = int(self.test_params['num_dhcp_servers']) self.assertTrue( self.num_dhcp_servers > 0, "Error: This test requires at least one DHCP server to be specified!" ) # We will simulate a responding DHCP server on the first interface in the provided set self.server_ip = self.test_params['server_ip'] self.server_iface_mac = self.dataplane.get_mac( 0, self.server_port_indices[0]) self.relay_iface_ip = self.test_params['relay_iface_ip'] self.relay_iface_mac = self.test_params['relay_iface_mac'] self.client_iface_alias = self.test_params['client_iface_alias'] self.client_port_index = int(self.test_params['client_port_index']) self.client_mac = self.dataplane.get_mac(0, self.client_port_index) # option82 is a byte string created by the relay agent. It contains the circuit_id and remote_id fields. # circuit_id is stored as suboption 1 of option 82. # It consists of the following: # Byte 0: Suboption number, always set to 1 # Byte 1: Length of suboption data in bytes # Bytes 2+: Suboption data # Our circuit_id string is of the form "hostname:portname" circuit_id_string = self.hostname + ":" + self.client_iface_alias self.option82 = struct.pack('BB', 1, len(circuit_id_string)) self.option82 += circuit_id_string # remote_id is stored as suboption 2 of option 82. # It consists of the following: # Byte 0: Suboption number, always set to 2 # Byte 1: Length of suboption data in bytes # Bytes 2+: Suboption data # Our remote_id string simply consists of the MAC address of the port that received the request remote_id_string = self.relay_iface_mac self.option82 += struct.pack('BB', 2, len(remote_id_string)) self.option82 += remote_id_string # We'll assign our client the IP address 1 greater than our relay interface (i.e., gateway) IP self.client_ip = incrementIpAddress(self.relay_iface_ip, 1) self.client_subnet = self.test_params['relay_iface_netmask']
def __init__(self, thrift_port=9199, use_pswitch=1): unittest.TestCase.__init__(self) config["use_pswitch"] = use_pswitch config["thrift_port"] = ptf.config["thirft_port"] if 'goldengate' == testutils.test_params_get()['chipname']: print "load default_interface_to_front_map_gg.ini" config["port_map_file"] = os.path.join(ptf.config['test_dir'], 'default_interface_to_front_map_gg.ini') elif 'tsingma_mx' == testutils.test_params_get()['chipname']: print "load default_interface_to_front_map_tmmx.ini" config["port_map_file"] = os.path.join(ptf.config['test_dir'], 'default_interface_to_front_map_tmmx.ini') else: #tsingma print "load default_interface_to_front_map.ini" config["port_map_file"] = os.path.join(ptf.config['test_dir'], 'default_interface_to_front_map.ini') ################################################################ # # Thrift interface base tests # ################################################################ if config["use_pswitch"] == 0: import switch_sai_thrift.switch_sai_rpc as switch_sai_rpc from thrift.transport import TSocket from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol if config["use_pswitch"] == 1: if sys.version_info[0] > 2: from urllib.parse import urlparse else: from urlparse import urlparse from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient from thrift.protocol.TJSONProtocol import TJSONProtocol from thrift.protocol.TBinaryProtocol import TBinaryProtocol import switch_sai.switch_sai_rpc as switch_sai_rpc return
def setUp(self): BaseTest.setUp(self) self.test_params = testutils.test_params_get() print "You specified the following test-params when invoking ptf:" print self.test_params # shows how to use a filter on all our tests testutils.add_filter(testutils.not_ipv6_filter) self.dataplane = ptf.dataplane_instance self.dataplane.flush() if config["log_dir"] != None: filename = os.path.join(config["log_dir"], str(self)) + ".pcap" self.dataplane.start_pcap(filename)
def __init__(self): BaseTest.__init__(self) self.log_fp = open('/tmp/copp.log', 'a') test_params = testutils.test_params_get() self.verbose = 'verbose' in test_params and test_params['verbose'] target_port_str = test_params.get('target_port', self.TARGET_PORT) self.target_port = int(target_port_str) self.timeout_thr = None self.myip = test_params.get('myip', None) self.peerip = test_params.get('peerip', None) self.needPreSend = None
def setUp(self): BaseTest.setUp(self) test_params = testutils.test_params_get() print print "You specified the following test-params when invoking ptf:" for k, v in test_params.items(): print k, ":\t\t\t", v # Set up thrift client and contact server self.transport = TSocket.TSocket('localhost', 9092) self.transport = TTransport.TBufferedTransport(self.transport) self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) self.client = switch_sai_rpc.Client(self.protocol) self.transport.open()
def setUp(self): BaseTest.setUp(self) self.test_params = testutils.test_params_get() if self.test_params.has_key("server"): server = self.test_params['server'] else: server = 'localhost' # Set up thrift client and contact server self.transport = TSocket.TSocket(server, 9092) self.transport = TTransport.TBufferedTransport(self.transport) self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) self.client = switch_sai_rpc.Client(self.protocol) self.transport.open()
def __init__(self): BaseTest.__init__(self) self.log_fp = open('/tmp/copp.log', 'a') test_params = testutils.test_params_get() self.verbose = 'verbose' in test_params and test_params['verbose'] target_port_str = test_params.get('target_port', self.TARGET_PORT) self.target_port = int(target_port_str) self.timeout_thr = None self.myip = test_params.get('myip', None) self.peerip = test_params.get('peerip', None) self.default_server_send_rate_limit_pps = test_params.get('send_rate_limit', 2000) self.needPreSend = None self.has_trap = test_params.get('has_trap', True)
def setUp(self): DataplaneBaseTest.setUp(self) self.test_params = testutils.test_params_get() self.hostname = self.test_params['hostname'] self.downlink_vlan_mac = self.test_params['downlink_vlan_mac'] self.downlink_vlan_ip6 = self.test_params['downlink_vlan_ip6'] self.ptf_port_index = int(self.test_params['ptf_port_index']) self.ptf_port_mac = self.dataplane.get_mac(0, self.ptf_port_index) self.radv_max_ra_interval = int(self.test_params['max_ra_interval']) rapkt = self.create_icmpv6_router_advertisement_packet_send( src_mac=self.downlink_vlan_mac, dst_mac=ALL_NODES_MULTICAST_MAC_ADDRESS, src_ip=self.downlink_vlan_ip6, dst_ip=ALL_NODES_IPV6_MULTICAST_ADDRESS) self.masked_rapkt = self.mask_off_dont_care_ra_packet_fields(rapkt)
def setUp(self): BaseTest.setUp(self) self.bridge = "br0" self.pipeline_id = 1 self.map_id = 1 test_params = testutils.test_params_get() print print "You specified the following test-params when invoking ptf:" for k, v in test_params.items(): print k, ":\t\t\t", v self.dataplane = ptf.dataplane_instance self.dataplane.flush() if config["log_dir"] != None: filename = os.path.join(config["log_dir"], str(self)) + ".pcap" self.dataplane.start_pcap(filename)
def __init__(self): BaseTest.__init__(self) self.test_params = testutils.test_params_get() self.mac_map = [] for i in xrange(self.MAX_PORTS): output = ControlPlaneBaseTest.cmd_run('ip link show dev eth%d' % (i)) second = output.split('\n')[1] mac = second.split()[1] self.mac_map.append(mac) self.myip = {} self.peerip = {} for i in xrange(self.MAX_PORTS): self.myip[i] = "10.0.0.%d" % (i * 2 + 1) self.peerip[i] = "10.0.0.%d" % (i * 2) return
def __init__(self): BaseTest.__init__(self) self.log_fp = open('/tmp/copp.log', 'a') test_params = testutils.test_params_get() self.verbose = 'verbose' in test_params and test_params['verbose'] self.pkt_tx_count = test_params.get('pkt_tx_count', self.PKT_TX_COUNT) if self.pkt_tx_count == 0: self.pkt_tx_count = self.PKT_TX_COUNT self.pkt_rx_limit = self.pkt_tx_count * 0.90 target_port_str = test_params.get('target_port', self.TARGET_PORT) self.target_port = int(target_port_str) self.timeout_thr = None self.myip = test_params.get('myip', None) self.peerip = test_params.get('peerip', None) return
def __init__(self): BaseTest.__init__(self) self.log_fp = open('/tmp/copp.log', 'a') test_params = testutils.test_params_get() self.verbose = 'verbose' in test_params and test_params['verbose'] self.pkt_tx_count = test_params.get('pkt_tx_count', self.PKT_TX_COUNT) if self.pkt_tx_count == 0: self.pkt_tx_count = self.PKT_TX_COUNT self.pkt_rx_limit = self.pkt_tx_count * 0.90 self.timeout_thr = None self.myip = {} self.peerip = {} for i in xrange(self.MAX_PORTS): self.myip[i] = "10.0.0.%d" % (i * 2 + 1) self.peerip[i] = "10.0.0.%d" % (i * 2) return
def setUp(self): global interface_to_front_mapping BaseTest.setUp(self) self.test_params = testutils.test_params_get() if self.test_params.has_key("server"): server = self.test_params['server'] else: server = 'localhost' if self.test_params.has_key("port_map"): user_input = self.test_params['port_map'] splitted_map = user_input.split(",") for item in splitted_map: interface_front_pair = item.split("@") interface_to_front_mapping[interface_front_pair[0]] = interface_front_pair[1] elif self.test_params.has_key("port_map_file"): user_input = self.test_params['port_map_file'] f = open(user_input, 'r') for line in f: if (len(line) > 0 and (line[0] == '#' or line[0] == ';' or line[0]=='/')): continue; interface_front_pair = line.split("@") interface_to_front_mapping[interface_front_pair[0]] = interface_front_pair[1].strip() else: exit("No ptf interface<-> switch front port mapping, please specify as parameter or in external file") print interface_to_front_mapping # Set up thrift client and contact server self.transport = TSocket.TSocket(server, 9092) self.transport = TTransport.TBufferedTransport(self.transport) self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) self.client = switch_sai_rpc.Client(self.protocol) self.transport.open()