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