• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 asyncio
17import argparse
18import logging
19
20import grpc
21
22from tests.interop import server as interop_server_lib
23from tests_aio.unit import _test_server
24
25logging.basicConfig(level=logging.DEBUG)
26_LOGGER = logging.getLogger(__name__)
27_LOGGER.setLevel(logging.DEBUG)
28
29
30async def serve():
31    args = interop_server_lib.parse_interop_server_arguments()
32
33    if args.use_tls or args.use_alts:
34        credentials = interop_server_lib.get_server_credentials(args.use_tls)
35        address, server = await _test_server.start_test_server(
36            port=args.port, secure=True, server_credentials=credentials)
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    asyncio.get_event_loop().run_until_complete(serve())
50