src/python/grpcio_tests/tests/fork/client.py
Go to the documentation of this file.
1 # Copyright 2018 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 Python implementation of the GRPC interoperability test client."""
15 
16 import argparse
17 import logging
18 import sys
19 
20 from tests.fork import methods
21 
22 
23 def _args():
24 
25  def parse_bool(value):
26  if value == 'true':
27  return True
28  if value == 'false':
29  return False
30  raise argparse.ArgumentTypeError('Only true/false allowed')
31 
32  parser = argparse.ArgumentParser()
33  parser.add_argument('--server_host',
34  default="localhost",
35  type=str,
36  help='the host to which to connect')
37  parser.add_argument('--server_port',
38  type=int,
39  required=True,
40  help='the port to which to connect')
41  parser.add_argument('--test_case',
42  default='large_unary',
43  type=str,
44  help='the test case to execute')
45  parser.add_argument('--use_tls',
46  default=False,
47  type=parse_bool,
48  help='require a secure connection')
49  return parser.parse_args()
50 
51 
52 def _test_case_from_arg(test_case_arg):
53  for test_case in methods.TestCase:
54  if test_case_arg == test_case.value:
55  return test_case
56  else:
57  raise ValueError('No test case "%s"!' % test_case_arg)
58 
59 
60 def test_fork():
61  logging.basicConfig(level=logging.INFO)
62  args = vars(_args())
63  if args['test_case'] == "all":
64  for test_case in methods.TestCase:
65  test_case.run_test(args)
66  else:
67  test_case = _test_case_from_arg(args['test_case'])
68  test_case.run_test(args)
69 
70 
71 if __name__ == '__main__':
72  test_fork()
tests.fork
Definition: src/python/grpcio_tests/tests/fork/__init__.py:1
tests.fork.client._test_case_from_arg
def _test_case_from_arg(test_case_arg)
Definition: src/python/grpcio_tests/tests/fork/client.py:52
tests.fork.client._args
def _args()
Definition: src/python/grpcio_tests/tests/fork/client.py:23
tests.interop.resources.parse_bool
def parse_bool(value)
Definition: interop/resources.py:37
tests.fork.client.test_fork
def test_fork()
Definition: src/python/grpcio_tests/tests/fork/client.py:60
tests.fork.methods.TestCase
Definition: fork/methods.py:409


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:54