def setUpClass(cls) -> None:
     nprobe = 10
     cls.CONFIG = FaissServiceConfig(nprobe=nprobe, normalize_query=False)
     cls.CONFIG_NORM = FaissServiceConfig(nprobe=nprobe,
                                          normalize_query=True)
     cls.FAISS_CONFIG = FaissConfig(dim=64, db_size=100000, nlist=100)
     cls.INDEX = cls.create_index()
     cls.SERVICE = faiss_pb2.DESCRIPTOR.services_by_name['FaissService']
     # faiss index must be cloned, because index attribute will be changed
     # FaissServiceServicer constructor (e.g. nprobe)
     cls.SERVER = grpc_testing.server_from_dictionary(
         {
             cls.SERVICE:
             FaissServiceServicer(faiss.clone_index(cls.INDEX), cls.CONFIG)
         },
         grpc_testing.strict_real_time(),
     )
     # server for normalize_query is True
     cls.SERVER_NORM = grpc_testing.server_from_dictionary(
         {
             cls.SERVICE:
             FaissServiceServicer(faiss.clone_index(cls.INDEX),
                                  cls.CONFIG_NORM)
         },
         grpc_testing.strict_real_time(),
     )
     # set nprobe, after complete cloning index
     cls.INDEX.nprobe = nprobe
 def setUp(self):
     self._real_time = grpc_testing.strict_real_time()
     self._fake_time = grpc_testing.strict_fake_time(time.time())
     service = CalculatorService()
     descriptors_to_services = {target_service: service}
     self._real_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_services, self._real_time)
     self._fake_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_services, self._fake_time)
예제 #3
0
 def setUp(self):
     self._real_time = grpc_testing.strict_real_time()
     self._fake_time = grpc_testing.strict_fake_time(time.time())
     self.mock_cowsay_client = Mock()
     # noinspection PyTypeChecker
     service = QuoteService(self.mock_cowsay_client, 'key')
     descriptors_to_services = {target_service: service}
     self._real_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_services, self._real_time)
     self._fake_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_services, self._fake_time)
예제 #4
0
 def setUp(self):
     self._real_time = grpc_testing.strict_real_time()
     self._fake_time = grpc_testing.strict_fake_time(time.time())
     servicer = _server_application.FirstServiceServicer()
     descriptors_to_servicers = {
         _application_testing_common.FIRST_SERVICE: servicer
     }
     self._real_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_servicers, self._real_time)
     self._fake_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_servicers, self._fake_time)
예제 #5
0
    def setUp(self):
        self._real_time = grpc_testing.strict_real_time()
        self._fake_time = grpc_testing.strict_fake_time(time.time())

        service = main.ArbitrageServiceServicer()
        descriptors_to_servicers = {ARBITRAGE_SERVICE: service}

        self._real_time_server = grpc_testing.server_from_dictionary(
            descriptors_to_servicers, self._real_time)
        self._fake_time_server = grpc_testing.server_from_dictionary(
            descriptors_to_servicers, self._fake_time)
예제 #6
0
 def setUp(self):
     self._real_time = grpc_testing.strict_real_time()
     self._fake_time = grpc_testing.strict_fake_time(time.time())
     servicer = _server_application.FirstServiceServicer()
     descriptors_to_servicers = {
         _application_testing_common.FIRST_SERVICE: servicer
     }
     self._real_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_servicers, self._real_time)
     self._fake_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_servicers, self._fake_time)
예제 #7
0
 def setUp(self):
     app.load_config_file("./test/test-settings.yml")
     app.data_server = DataServer(app.config)
     app.system_logger = JsonSystemLogger(config=app.config)
     app.service_logger = JsonServiceLogger(config=app.config)
     self._real_time = grpc_testing.strict_real_time()
     self._fake_time = grpc_testing.strict_fake_time(time.time())
     servicer = RekcurdWorkerServicer(RekcurdPack(app, None))
     descriptors_to_services = {target_service: servicer}
     self._real_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_services, self._real_time)
     self._fake_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_services, self._fake_time)
예제 #8
0
def get_test_server():
    """Define test server"""
    service_names = {
        pb.DESCRIPTOR.services_by_name['Reverser']: ReverserService()
    }
    test_server = grpc_testing.server_from_dictionary(service_names, grpc_testing.strict_real_time())
    return test_server
예제 #9
0
    def setUp(self):
        servicers = {
            api_pb2.DESCRIPTOR.services_by_name['Suggestion']: DartsService()
        }

        self.test_server = grpc_testing.server_from_dictionary(
            servicers, grpc_testing.strict_real_time())
    def setUp(self):
        servicers = {
            helloworld_pb2.DESCRIPTOR.services_by_name['Greeter']: Greeter()
        }

        self.test_server = grpc_testing.server_from_dictionary(
            servicers, grpc_testing.strict_real_time())
예제 #11
0
def server():
    servicers = {
        temporal_service_pb2.DESCRIPTOR.services_by_name["TemporalService"]:
        TemporalServiceServicer()
    }
    return grpc_testing.server_from_dictionary(servicers,
                                               grpc_testing.strict_real_time())
예제 #12
0
    def setUp(self):
        servicers = {
            network_pb2.DESCRIPTOR.services_by_name['Network']: Network()
        }

        self.test_server = grpc_testing.server_from_dictionary(
            servicers, grpc_testing.strict_real_time())
예제 #13
0
    def greeter_server(self, greeter_service):
        descriptors_to_servicers = {
            greeter_service: helloworld.GreeterServicer()
        }

        return grpc_testing.server_from_dictionary(
            descriptors_to_servicers, grpc_testing.strict_real_time()
        )
예제 #14
0
    def setUp(self):
        servicers = {
            api_pb2.DESCRIPTOR.services_by_name['EarlyStopping']:
            MedianStopService()
        }

        self.test_server = grpc_testing.server_from_dictionary(
            servicers, grpc_testing.strict_real_time())
예제 #15
0
def get_grpc_service_for_predict(get_fake_model):
    _real_time = grpc_testing.strict_real_time()
    servicer = PredictionServiceServicer(models={'test': get_fake_model})
    descriptors_to_servicers = {PREDICT_SERVICE: servicer}
    _real_time_server = grpc_testing.server_from_dictionary(
        descriptors_to_servicers, _real_time)

    return _real_time_server
예제 #16
0
def get_grpc_service_for_model_status(get_fake_model):
    _real_time = grpc_testing.strict_real_time()
    servicer = ModelServiceServicer(models={'test': get_fake_model})
    descriptors_to_servicers = {MODEL_SERVICE: servicer}
    _real_time_server = grpc_testing.server_from_dictionary(
        descriptors_to_servicers, _real_time)

    return _real_time_server
예제 #17
0
def setup_test_server():
    servicers = {
        groundstation_pb2.DESCRIPTOR.services_by_name['GroundStationService']:
        GroundStationServiceServicer()
    }

    return grpc_testing.server_from_dictionary(servicers,
                                               grpc_testing.strict_real_time())
    def setUp(self):
        def gen_eval():
            for d in eval_result_details:
                yield d
            return eval_result

        app.load_config_file("./test/test-settings.yml")
        app.data_server = DataServer(app.config)
        app.system_logger = JsonSystemLogger(config=app.config)
        app.service_logger = JsonServiceLogger(config=app.config)
        app.evaluate = Mock(return_value=gen_eval())
        self._real_time = grpc_testing.strict_real_time()
        self._fake_time = grpc_testing.strict_fake_time(time.time())
        servicer = RekcurdDashboardServicer(RekcurdPack(app, None))
        descriptors_to_services = {target_service: servicer}
        self._real_time_server = grpc_testing.server_from_dictionary(
            descriptors_to_services, self._real_time)
        self._fake_time_server = grpc_testing.server_from_dictionary(
            descriptors_to_services, self._fake_time)
예제 #19
0
def mock_server():
    """Constructor to initialise the test grpc servicer"""

    servicers = {
        alarm_pb2.DESCRIPTOR.services_by_name['AlarmStore']:
        AlarmStoreServicer(TEST_DATABASE, False)
    }

    return grpc_testing.server_from_dictionary(servicers,
                                               grpc_testing.strict_real_time())
예제 #20
0
def fixture_processor_servicer():
    processor_service = _ProcessorServicer(config={},
                                           pr=ExampleTestProcessor(),
                                           address='',
                                           health_servicer=None)
    yield grpc_testing.server_from_dictionary(
        {
            processing_pb2.DESCRIPTOR.services_by_name['Processor']:
            processor_service
        }, grpc_testing.strict_real_time())
예제 #21
0
    def get_test_server(self):
        if not self._test_server:
            servicers = {}
            for svc in self.app.services:
                if isinstance(svc, Service):
                    servicers[svc.descriptor] = svc.make_servicer_class()

            self._test_server = grpc_testing.server_from_dictionary(
                servicers, grpc_testing.strict_real_time()
            )
        return self._test_server
예제 #22
0
 def setUp(self):
     self._on_receiving_result = MagicMock()
     self._servicer = DeviceReportServicer(self._on_receiving_result)
     servicers = {
         DESCRIPTOR.services_by_name['DeviceReport']: self._servicer
     }
     self._test_server = server_from_dictionary(servicers,
                                                strict_real_time())
     port_learns = [('name', '1', '00:0X:00:00:00:01', 101),
                    ('name', '2', '00:0Y:00:00:00:02', 102),
                    ('name', '3', '00:0Z:00:00:00:03', 103)]
     for port_learn in port_learns:
         self._servicer.process_port_learn(*port_learn)
예제 #23
0
    def setUp(self):
        # Mock load Kubernetes config.
        patcher = patch(
            'pkg.earlystopping.v1beta1.medianstop.service.config.load_kube_config'
        )
        self.mock_sum = patcher.start()
        self.addCleanup(patcher.stop)

        servicers = {
            api_pb2.DESCRIPTOR.services_by_name['EarlyStopping']:
            MedianStopService()
        }

        self.test_server = grpc_testing.server_from_dictionary(
            servicers, grpc_testing.strict_real_time())
 def setUp(self):
     servicers = {
         DESCRIPTOR.services_by_name['StatisticsProcesser']: Calculator()
     }
     self.test_server = grpc_testing.server_from_dictionary(
         servicers, grpc_testing.strict_real_time())
     self.default_config = toml.load('server/server.toml')['statistics']
     with open('server/test/test.csv', 'r') as file:
         self.document = file.read().encode()
     with open('server/test/result.csv', 'r') as file:
         self.result = self.default_config['summary_header'] + file.read()
         self.result = self.result.encode()
     with open('server/test/result_full.csv', 'r') as file:
         self.result_full = self.default_config[
             'summary_header'] + file.read()
         self.result_full = self.result_full.encode()
예제 #25
0
 def setUp(self):
     self._real_time = grpc_testing.strict_real_time()
     servicer = RoomManagerServicer()
     descriptors_to_servicers = {SERVICE: servicer}
     self._real_time_server = grpc_testing.server_from_dictionary(
         descriptors_to_servicers, self._real_time)
예제 #26
0
def fixture_events_server():
    events_service = EventsServicer()
    yield grpc_testing.server_from_dictionary(
        {events_pb2.DESCRIPTOR.services_by_name['Events']: events_service},
        grpc_testing.strict_real_time())