• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 gRPC authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""The entry point for the qps worker."""
15
16import argparse
17import logging
18import time
19
20import grpc
21from src.proto.grpc.testing import worker_service_pb2_grpc
22
23from tests.qps import worker_server
24from tests.unit import test_common
25
26
27def run_worker_server(driver_port, server_port):
28    server = test_common.test_server()
29    servicer = worker_server.WorkerServer(server_port)
30    worker_service_pb2_grpc.add_WorkerServiceServicer_to_server(
31        servicer, server)
32    server.add_insecure_port('[::]:{}'.format(driver_port))
33    server.start()
34    servicer.wait_for_quit()
35    server.stop(0)
36
37
38if __name__ == '__main__':
39    logging.basicConfig(level=logging.DEBUG)
40    parser = argparse.ArgumentParser(
41        description='gRPC Python performance testing worker')
42    parser.add_argument(
43        '--driver_port',
44        type=int,
45        dest='driver_port',
46        help='The port for the worker to expose for driver communication')
47    parser.add_argument(
48        '--server_port',
49        type=int,
50        default=None,
51        dest='server_port',
52        help='The port for the server if not specified by server config message'
53    )
54    args = parser.parse_args()
55
56    run_worker_server(args.driver_port, args.server_port)
57