14 """The Python client used to test negative http2 conditions.""" 
   21 from src.proto.grpc.testing 
import messages_pb2
 
   22 from src.proto.grpc.testing 
import test_pb2_grpc
 
   26     if response.payload.type 
is not expected_type:
 
   27         raise ValueError(
'expected payload type %s, got %s' %
 
   28                          (expected_type, 
type(response.payload.type)))
 
   29     elif len(response.payload.body) != expected_length:
 
   30         raise ValueError(
'expected payload body size %d, got %d' %
 
   31                          (expected_length, 
len(response.payload.body)))
 
   35     if call.code() != expected_code:
 
   36         raise ValueError(
'expected code %s, got %s' %
 
   37                          (expected_code, call.code()))
 
   41     if call.details() != expected_details:
 
   42         raise ValueError(
'expected message %s, got %s' %
 
   43                          (expected_details, call.details()))
 
   52 _REQUEST_SIZE = 314159
 
   53 _RESPONSE_SIZE = 271828
 
   56     response_type=messages_pb2.COMPRESSABLE,
 
   57     response_size=_RESPONSE_SIZE,
 
   62     first_response = stub.UnaryCall(_SIMPLE_REQUEST)
 
   66     second_response = stub.UnaryCall(_SIMPLE_REQUEST)
 
   68                                       messages_pb2.COMPRESSABLE, _RESPONSE_SIZE)
 
   72     resp_future = stub.UnaryCall.future(_SIMPLE_REQUEST)
 
   74                                       "Received RST_STREAM with error code 0")
 
   78     resp_future = stub.UnaryCall.future(_SIMPLE_REQUEST)
 
   80                                       "Received RST_STREAM with error code 0")
 
   84     resp_future = stub.UnaryCall.future(_SIMPLE_REQUEST)
 
   86                                       "Received RST_STREAM with error code 0")
 
   90     response = stub.UnaryCall(_SIMPLE_REQUEST)
 
   97     response = stub.UnaryCall(_SIMPLE_REQUEST)
 
  104         futures.append(stub.UnaryCall.future(_SIMPLE_REQUEST))
 
  105     for future 
in futures:
 
  107                                           messages_pb2.COMPRESSABLE,
 
  112     if test_case == 
'goaway':
 
  114     elif test_case == 
'rst_after_header':
 
  116     elif test_case == 
'rst_during_data':
 
  118     elif test_case == 
'rst_after_data':
 
  120     elif test_case == 
'ping':
 
  122     elif test_case == 
'max_streams':
 
  125         raise ValueError(
"Invalid test case: %s" % test_case)
 
  129     parser = argparse.ArgumentParser()
 
  130     parser.add_argument(
'--server_host',
 
  131                         help=
'the host to which to connect',
 
  134     parser.add_argument(
'--server_port',
 
  135                         help=
'the port to which to connect',
 
  138     parser.add_argument(
'--test_case',
 
  139                         help=
'the test case to execute',
 
  142     return parser.parse_args()
 
  145 def _stub(server_host, server_port):
 
  146     target = 
'{}:{}'.
format(server_host, server_port)
 
  149     return test_pb2_grpc.TestServiceStub(channel)
 
  154     stub = 
_stub(args.server_host, args.server_port)
 
  158 if __name__ == 
'__main__':