1# Copyright 2017 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 15import argparse 16import hyper 17import sys 18 19# Utility to healthcheck the http2 server. Used when starting the server to 20# verify that the server is live before tests begin. 21if __name__ == '__main__': 22 parser = argparse.ArgumentParser() 23 parser.add_argument('--server_host', type=str, default='localhost') 24 parser.add_argument('--server_port', type=int, default=8080) 25 args = parser.parse_args() 26 server_host = args.server_host 27 server_port = args.server_port 28 conn = hyper.HTTP20Connection('%s:%d' % (server_host, server_port)) 29 conn.request('POST', '/grpc.testing.TestService/UnaryCall') 30 resp = conn.get_response() 31 if resp.headers.get('grpc-encoding') is None: 32 sys.exit(1) 33 else: 34 sys.exit(0) 35