1# Copyright 2019 The 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 gRPC interoperability test server using AsyncIO stack.""" 15 16import argparse 17import asyncio 18import logging 19import sys 20 21import grpc 22 23from tests.interop import server as interop_server_lib 24from tests_aio.unit import _test_server 25 26logging.basicConfig(level=logging.DEBUG) 27_LOGGER = logging.getLogger(__name__) 28_LOGGER.setLevel(logging.DEBUG) 29 30 31async def serve(args): 32 if args.use_tls or args.use_alts: 33 credentials = interop_server_lib.get_server_credentials(args.use_tls) 34 address, server = await _test_server.start_test_server( 35 port=args.port, secure=True, server_credentials=credentials 36 ) 37 else: 38 address, server = await _test_server.start_test_server( 39 port=args.port, 40 secure=False, 41 ) 42 43 _LOGGER.info("Server serving at %s", address) 44 await server.wait_for_termination() 45 _LOGGER.info("Server stopped; exiting.") 46 47 48if __name__ == "__main__": 49 args = interop_server_lib.parse_interop_server_arguments(sys.argv) 50 asyncio.get_event_loop().run_until_complete(serve(args)) 51