blob: 5117c1aaaa29ee78a2c16c082ef39599105ef72b [file] [log] [blame]
Jan Tattermusch7897ae92017-06-07 22:57:36 +02001# Copyright 2017 gRPC authors.
Eric Gribkoff22afddf2017-03-15 15:43:43 -07002#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003# 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
Eric Gribkoff22afddf2017-03-15 15:43:43 -07006#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02007# http://www.apache.org/licenses/LICENSE-2.0
Eric Gribkoff22afddf2017-03-15 15:43:43 -07008#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009# 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.
Eric Gribkoff22afddf2017-03-15 15:43:43 -070014
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)