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 16 import argparse 17 import time 18 19 import grpc 20 from src.proto.grpc.testing import worker_service_pb2_grpc 21 22 from tests.qps import worker_server 23 from tests.unit import test_common 24 25 26 def run_worker_server(port): 27 server = test_common.test_server() 28 servicer = worker_server.WorkerServer() 29 worker_service_pb2_grpc.add_WorkerServiceServicer_to_server( 30 servicer, server) 31 server.add_insecure_port('[::]:{}'.format(port)) 32 server.start() 33 servicer.wait_for_quit() 34 server.stop(0) 35 36 37 if __name__ == '__main__': 38 parser = argparse.ArgumentParser( 39 description='gRPC Python performance testing worker') 40 parser.add_argument( 41 '--driver_port', 42 type=int, 43 dest='port', 44 help='The port the worker should listen on') 45 args = parser.parse_args() 46 47 run_worker_server(args.port) 48