예제 #1
0
 def setUp(self):
     global interface_to_front_mapping
     BaseTest.setUp(self)
     self.test_params = testutils.test_params_get()
     self.loadPortMap()
     self.createRpcClient()
     return
예제 #2
0
파일: base_test.py 프로젝트: renaissanxe/PI
    def setUp(self):
        BaseTest.setUp(self)
        self.device_id = 0

        # Setting up PTF dataplane
        self.dataplane = ptf.dataplane_instance
        self.dataplane.flush()

        self._swports = []
        for device, port, ifname in config["interfaces"]:
            self._swports.append(port)

        grpc_addr = testutils.test_param_get("grpcaddr")
        if grpc_addr is None:
            grpc_addr = 'localhost:50051'

        self.channel = grpc.insecure_channel(grpc_addr)
        self.stub = p4runtime_pb2.P4RuntimeStub(self.channel)

        proto_txt_path = testutils.test_param_get("p4info")
        print "Importing p4info proto from", proto_txt_path
        self.p4info = p4info_pb2.P4Info()
        with open(proto_txt_path, "rb") as fin:
            google.protobuf.text_format.Merge(fin.read(), self.p4info)

        self.import_p4info_names()

        # used to store write requests sent to the P4Runtime server, useful for
        # autocleanup of tests (see definition of autocleanup decorator below)
        self._reqs = []

        self.set_up_stream()
예제 #3
0
 def setUp(self):
     global interface_to_front_mapping
     BaseTest.setUp(self)
     self.test_params = testutils.test_params_get()
     self.loadPortMap()
     self.createRpcClient()
     return
예제 #4
0
    def setUp(self):
        BaseTest.setUp(self)

        # 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()
예제 #5
0
    def setUp(self):
        BaseTest.setUp(self)

        # 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()
예제 #6
0
    def setUp(self):
        BaseTest.setUp(self)
        self._swports = []
        for device, port, ifname in config["interfaces"]:
            self._swports.append(port)

        grpc_addr = testutils.test_param_get("grpcaddr")
        if grpc_addr is None:
            grpc_addr = 'localhost:50051'

        self.device_id = int(testutils.test_param_get("device_id"))
        if self.device_id is None:
            self.fail("Device ID is not set")

        self.cpu_port = int(testutils.test_param_get("cpu_port"))
        if self.cpu_port is None:
            self.fail("CPU port is not set")

        self.device = testutils.test_param_get("device")
        if self.device is None:
            self.fail("Device is not set")

        pltfm = testutils.test_param_get("pltfm")
        if pltfm is not None and pltfm == 'hw' and getattr(
                self, "_skip_on_hw", False):
            raise SkipTest("Skipping test in HW")

        proto_txt_path = testutils.test_param_get("p4info")
        # print "Importing p4info proto from", proto_txt_path
        self.p4info = p4info_pb2.P4Info()
        with open(proto_txt_path, "rb") as fin:
            google.protobuf.text_format.Merge(fin.read(), self.p4info)

        self.import_p4info_names()

        # used to store write requests sent to the P4Runtime server, useful for
        # autocleanup of tests (see definition of autocleanup decorator below)
        self.reqs = []

        self.election_id = 1
        if testutils.test_param_get("generate_tv") == 'True':
            self.generate_tv = True
        else:
            self.generate_tv = False
        if self.generate_tv:
            self.tv_list = []
            self.tv_name = self.__class__.__name__
        else:
            # Setting up PTF dataplane
            self.dataplane = ptf.dataplane_instance
            self.dataplane.flush()
            self.channel = grpc.insecure_channel(grpc_addr)
            self.stub = p4runtime_pb2_grpc.P4RuntimeStub(self.channel)
            self.set_up_stream()
예제 #7
0
파일: voq.py 프로젝트: xumia/sonic-mgmt
    def setUp(self):
        BaseTest.setUp(self)

        self.test_params = test_params_get()
        logger.info("You specified the following test-params when invoking ptf:")
        logger.info(self.test_params)

        self.dataplane = ptf.dataplane_instance
        self.dataplane.flush()
        if config["log_dir"] is not None:
            filename = os.path.join(config["log_dir"], str(self)) + ".pcap"
            self.dataplane.start_pcap(filename)
예제 #8
0
    def setUp(self):
        BaseTest.setUp(self)

        self.test_params = 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
        add_filter(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)
예제 #9
0
    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
예제 #10
0
    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()
예제 #11
0
    def setUp(self):
        BaseTest.setUp(self)

        # Set up thrift client and contact server
        self.transport = TSocket.TSocket('localhost', 9090)
        self.transport = TTransport.TBufferedTransport(self.transport)
        bprotocol = TBinaryProtocol.TBinaryProtocol(self.transport)

        self.mc_protocol = TMultiplexedProtocol.TMultiplexedProtocol(bprotocol, "mc")
        self.conn_mgr_protocol = TMultiplexedProtocol.TMultiplexedProtocol(bprotocol, "conn_mgr")
        self.p4_protocol = TMultiplexedProtocol.TMultiplexedProtocol(bprotocol, self.p4_name)

        self.client = self.p4_client_module.Client(self.p4_protocol)
        self.mc = self.mc_client_module.Client(self.mc_protocol)
        self.conn_mgr = self.conn_mgr_client_module.Client(self.conn_mgr_protocol)
        self.transport.open()
예제 #12
0
    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()
예제 #13
0
    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()
예제 #14
0
    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()
예제 #15
0
파일: base_test.py 프로젝트: usha1830/p4c
    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)
예제 #16
0
    def setUp(self, proto_bin_path):
        BaseTest.setUp(self)

        self.target = testutils.test_param_get('target')
        if not self.target:
            self.target = "bmv2"
        elif self.target not in {"bmv2"}:
            print "Unsupported target", self.target
            sys.exit(1)

        self.device_id = 0

        # Setting up PTF dataplane
        self.dataplane = ptf.dataplane_instance
        self.dataplane.flush()

        self.device_id = 0

        self.channel = grpc.insecure_channel('localhost:50051')
        self.stub = p4runtime_pb2.P4RuntimeStub(self.channel)

        ConfigRequest = p4runtime_pb2.SetForwardingPipelineConfigRequest
        req = ConfigRequest()

        print "Connecting to device"
        req.action = ConfigRequest().VERIFY_AND_COMMIT
        config = req.configs.add()
        config.device_id = self.device_id

        print "Importing p4info proto from", proto_bin_path
        with open(proto_bin_path, "rb") as fin:
            config.p4info.ParseFromString(fin.read())

        # we save p4info for name -> id lookups
        self.p4info = config.p4info

        if self.target == "bmv2":
            device_config = p4config_pb2.P4DeviceConfig()
            extras = device_config.extras
            extras.kv["port"] = "9090"
            extras.kv["notifications"] = "ipc:///tmp/bmv2-0-notifications.ipc"
            config.p4_device_config = device_config.SerializeToString()

        rep = self.stub.SetForwardingPipelineConfig(req)
예제 #17
0
    def setUp(self):
        BaseTest.setUp(self)

        # Set up thrift client and contact server
        self.transport = TSocket.TSocket('localhost', 9090)
        self.transport = TTransport.TBufferedTransport(self.transport)
        bprotocol = TBinaryProtocol.TBinaryProtocol(self.transport)

        self.mc_protocol = TMultiplexedProtocol.TMultiplexedProtocol(
            bprotocol, "mc")
        self.conn_mgr_protocol = TMultiplexedProtocol.TMultiplexedProtocol(
            bprotocol, "conn_mgr")
        self.p4_protocol = TMultiplexedProtocol.TMultiplexedProtocol(
            bprotocol, self.p4_name)

        self.client = self.p4_client_module.Client(self.p4_protocol)
        self.mc = self.mc_client_module.Client(self.mc_protocol)
        self.conn_mgr = self.conn_mgr_client_module.Client(
            self.conn_mgr_protocol)
        self.transport.open()
예제 #18
0
    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"
            )

        # 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()
예제 #19
0
파일: sai_base_test.py 프로젝트: ampg99/SAI
    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()
예제 #20
0
    def setUp(self):
        BaseTest.setUp(self)

        # Set up thrift client and contact server
        self.thrift_server = 'localhost'
        if test_param_get('thrift_server') is not None:
            self.thrift_server = test_param_get('thrift_server')
        self.transport = TSocket.TSocket(self.thrift_server, 9091)
        self.transport = TTransport.TBufferedTransport(self.transport)
        self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport)

        self.client = switch_api_rpc.Client(self.protocol)
        self.transport.open()

        self.pd_transport = TSocket.TSocket(self.thrift_server, 9090)
        self.pd_transport = TTransport.TBufferedTransport(self.pd_transport)
        self.pd_protocol = TBinaryProtocol.TBinaryProtocol(self.pd_transport)
        self.pd_protocol = TMultiplexedProtocol.TMultiplexedProtocol(
            self.pd_protocol, "devport_mgr")
        self.devport_mgr_client_module = importlib.import_module(".".join(
            ["devport_mgr_pd_rpc", "devport_mgr"]))
        self.devport_mgr = self.devport_mgr_client_module.Client(
            self.pd_protocol)
        self.pd_transport.open()
예제 #21
0
파일: test.py 프로젝트: wsobow/ptf
 def setUp(self):
     BaseTest.setUp(self)
예제 #22
0
 def setUp(self):
     BaseTest.setUp(self)
     self.dataplane = ptf.dataplane_instance
     self.dataplane.flush()