|
|
|
@ -33,6 +33,7 @@ import abc |
|
|
|
|
import unittest |
|
|
|
|
|
|
|
|
|
from grpc.framework.face import interfaces |
|
|
|
|
from grpc_test.framework.common import test_constants |
|
|
|
|
from grpc_test.framework.face.testing import callback as testing_callback |
|
|
|
|
from grpc_test.framework.face.testing import control |
|
|
|
|
from grpc_test.framework.face.testing import coverage |
|
|
|
@ -40,8 +41,6 @@ from grpc_test.framework.face.testing import digest |
|
|
|
|
from grpc_test.framework.face.testing import stock_service |
|
|
|
|
from grpc_test.framework.face.testing import test_case |
|
|
|
|
|
|
|
|
|
_TIMEOUT = 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
test_case.FaceTestCase, coverage.FullCoverage): |
|
|
|
@ -79,7 +78,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
self.stub.event_value_in_value_out( |
|
|
|
|
name, request, callback.complete, callback.abort, _TIMEOUT) |
|
|
|
|
name, request, callback.complete, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
response = callback.response() |
|
|
|
|
|
|
|
|
@ -93,7 +93,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
self.stub.event_value_in_stream_out( |
|
|
|
|
name, request, callback, callback.abort, _TIMEOUT) |
|
|
|
|
name, request, callback, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
responses = callback.responses() |
|
|
|
|
|
|
|
|
@ -107,7 +108,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
unused_call, request_consumer = self.stub.event_stream_in_value_out( |
|
|
|
|
name, callback.complete, callback.abort, _TIMEOUT) |
|
|
|
|
name, callback.complete, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
for request in requests: |
|
|
|
|
request_consumer.consume(request) |
|
|
|
|
request_consumer.terminate() |
|
|
|
@ -124,7 +126,7 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
unused_call, request_consumer = self.stub.event_stream_in_stream_out( |
|
|
|
|
name, callback, callback.abort, _TIMEOUT) |
|
|
|
|
name, callback, callback.abort, test_constants.SHORT_TIMEOUT) |
|
|
|
|
for request in requests: |
|
|
|
|
request_consumer.consume(request) |
|
|
|
|
request_consumer.terminate() |
|
|
|
@ -147,11 +149,11 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
first_callback.complete(first_response) |
|
|
|
|
self.stub.event_value_in_value_out( |
|
|
|
|
name, second_request, second_callback.complete, |
|
|
|
|
second_callback.abort, _TIMEOUT) |
|
|
|
|
second_callback.abort, test_constants.SHORT_TIMEOUT) |
|
|
|
|
|
|
|
|
|
self.stub.event_value_in_value_out( |
|
|
|
|
name, first_request, make_second_invocation, first_callback.abort, |
|
|
|
|
_TIMEOUT) |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
second_callback.block_until_terminated() |
|
|
|
|
|
|
|
|
|
first_response = first_callback.response() |
|
|
|
@ -168,7 +170,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
|
|
|
|
|
with self.control.pause(): |
|
|
|
|
self.stub.event_value_in_value_out( |
|
|
|
|
name, request, callback.complete, callback.abort, _TIMEOUT) |
|
|
|
|
name, request, callback.complete, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
|
self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion()) |
|
|
|
@ -182,7 +185,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
|
|
|
|
|
with self.control.pause(): |
|
|
|
|
self.stub.event_value_in_stream_out( |
|
|
|
|
name, request, callback, callback.abort, _TIMEOUT) |
|
|
|
|
name, request, callback, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
|
self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion()) |
|
|
|
@ -194,7 +198,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
self.stub.event_stream_in_value_out( |
|
|
|
|
name, callback.complete, callback.abort, _TIMEOUT) |
|
|
|
|
name, callback.complete, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
|
self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion()) |
|
|
|
@ -207,7 +212,7 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
unused_call, request_consumer = self.stub.event_stream_in_stream_out( |
|
|
|
|
name, callback, callback.abort, _TIMEOUT) |
|
|
|
|
name, callback, callback.abort, test_constants.SHORT_TIMEOUT) |
|
|
|
|
for request in requests: |
|
|
|
|
request_consumer.consume(request) |
|
|
|
|
callback.block_until_terminated() |
|
|
|
@ -223,10 +228,12 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
|
|
|
|
|
with self.control.fail(): |
|
|
|
|
self.stub.event_value_in_value_out( |
|
|
|
|
name, request, callback.complete, callback.abort, _TIMEOUT) |
|
|
|
|
name, request, callback.complete, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
|
self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, callback.abortion()) |
|
|
|
|
self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, |
|
|
|
|
callback.abortion()) |
|
|
|
|
|
|
|
|
|
def testFailedUnaryRequestStreamResponse(self): |
|
|
|
|
for name, test_messages_sequence in ( |
|
|
|
@ -237,10 +244,12 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
|
|
|
|
|
with self.control.fail(): |
|
|
|
|
self.stub.event_value_in_stream_out( |
|
|
|
|
name, request, callback, callback.abort, _TIMEOUT) |
|
|
|
|
name, request, callback, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
|
self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, callback.abortion()) |
|
|
|
|
self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, |
|
|
|
|
callback.abortion()) |
|
|
|
|
|
|
|
|
|
def testFailedStreamRequestUnaryResponse(self): |
|
|
|
|
for name, test_messages_sequence in ( |
|
|
|
@ -251,13 +260,15 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
|
|
|
|
|
with self.control.fail(): |
|
|
|
|
unused_call, request_consumer = self.stub.event_stream_in_value_out( |
|
|
|
|
name, callback.complete, callback.abort, _TIMEOUT) |
|
|
|
|
name, callback.complete, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
for request in requests: |
|
|
|
|
request_consumer.consume(request) |
|
|
|
|
request_consumer.terminate() |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
|
self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, callback.abortion()) |
|
|
|
|
self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, |
|
|
|
|
callback.abortion()) |
|
|
|
|
|
|
|
|
|
def testFailedStreamRequestStreamResponse(self): |
|
|
|
|
for name, test_messages_sequence in ( |
|
|
|
@ -268,7 +279,7 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
|
|
|
|
|
with self.control.fail(): |
|
|
|
|
unused_call, request_consumer = self.stub.event_stream_in_stream_out( |
|
|
|
|
name, callback, callback.abort, _TIMEOUT) |
|
|
|
|
name, callback, callback.abort, test_constants.SHORT_TIMEOUT) |
|
|
|
|
for request in requests: |
|
|
|
|
request_consumer.consume(request) |
|
|
|
|
request_consumer.terminate() |
|
|
|
@ -287,10 +298,10 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
|
|
|
|
|
self.stub.event_value_in_value_out( |
|
|
|
|
name, first_request, first_callback.complete, first_callback.abort, |
|
|
|
|
_TIMEOUT) |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
self.stub.event_value_in_value_out( |
|
|
|
|
name, second_request, second_callback.complete, |
|
|
|
|
second_callback.abort, _TIMEOUT) |
|
|
|
|
second_callback.abort, test_constants.SHORT_TIMEOUT) |
|
|
|
|
first_callback.block_until_terminated() |
|
|
|
|
second_callback.block_until_terminated() |
|
|
|
|
|
|
|
|
@ -312,7 +323,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
|
|
|
|
|
with self.control.pause(): |
|
|
|
|
call = self.stub.event_value_in_value_out( |
|
|
|
|
name, request, callback.complete, callback.abort, _TIMEOUT) |
|
|
|
|
name, request, callback.complete, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
call.cancel() |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
@ -326,7 +338,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
call = self.stub.event_value_in_stream_out( |
|
|
|
|
name, request, callback, callback.abort, _TIMEOUT) |
|
|
|
|
name, request, callback, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
call.cancel() |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
@ -340,7 +353,8 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
call, request_consumer = self.stub.event_stream_in_value_out( |
|
|
|
|
name, callback.complete, callback.abort, _TIMEOUT) |
|
|
|
|
name, callback.complete, callback.abort, |
|
|
|
|
test_constants.SHORT_TIMEOUT) |
|
|
|
|
for request in requests: |
|
|
|
|
request_consumer.consume(request) |
|
|
|
|
call.cancel() |
|
|
|
@ -355,7 +369,7 @@ class EventInvocationSynchronousEventServiceTestCase( |
|
|
|
|
callback = testing_callback.Callback() |
|
|
|
|
|
|
|
|
|
call, unused_request_consumer = self.stub.event_stream_in_stream_out( |
|
|
|
|
name, callback, callback.abort, _TIMEOUT) |
|
|
|
|
name, callback, callback.abort, test_constants.SHORT_TIMEOUT) |
|
|
|
|
call.cancel() |
|
|
|
|
callback.block_until_terminated() |
|
|
|
|
|
|
|
|
|