Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 1 | # Copyright 2017 gRPC authors. |
Eric Gribkoff | 22afddf | 2017-03-15 15:43:43 -0700 | [diff] [blame] | 2 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
Eric Gribkoff | 22afddf | 2017-03-15 15:43:43 -0700 | [diff] [blame] | 6 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
Eric Gribkoff | 22afddf | 2017-03-15 15:43:43 -0700 | [diff] [blame] | 8 | # |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
Eric Gribkoff | 22afddf | 2017-03-15 15:43:43 -0700 | [diff] [blame] | 14 | |
| 15 | import argparse |
| 16 | import hyper |
| 17 | import 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. |
| 21 | if __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) |