14 """Common utilities for tests of the Cython layer of gRPC Python."""
25 INVOCATION_METADATA = (
26 (
'client-md-key',
'client-md-key'),
27 (
'client-md-key-bin', b
'\x00\x01' * 3000),
31 (
'server-initial-md-key',
'server-initial-md-value'),
32 (
'server-initial-md-key-bin', b
'\x00\x02' * 3000),
36 (
'server-trailing-md-key',
'server-trailing-md-value'),
37 (
'server-trailing-md-key-bin', b
'\x00\x03' * 3000),
43 def __init__(self, condition, completion_queue):
46 self.
_due = collections.defaultdict(int)
47 self.
_events = collections.defaultdict(list)
56 self.
_events[event.tag].append(event)
57 self.
_due[event.tag] -= 1
59 if self.
_due[event.tag] <= 0:
60 self.
_due.pop(event.tag)
64 thread = threading.Thread(target=in_thread)
79 return tuple(behavior()
for _
in range(RPC_COUNT))
83 collections.namedtuple(
'OperationResult', (
92 cygrpc.CallError.ok, cygrpc.CompletionType.operation_complete,
True)
99 self.
server = cygrpc.Server([(b
'grpc.so_reuseport', 0)],
False)
101 port = self.
server.add_http2_port(b
'[::]:0')
123 self.
server.cancel_all_calls()