|
|
|
@ -701,87 +701,6 @@ static dispatch_once_t initGlobalInterceptorFactory; |
|
|
|
|
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)testUnaryRPCWithV2APIFlowControl { |
|
|
|
|
XCTAssertNotNil([[self class] host]); |
|
|
|
|
__weak XCTestExpectation *expectReceive = |
|
|
|
|
[self expectationWithDescription:@"LargeUnaryWithV2API received message"]; |
|
|
|
|
__weak XCTestExpectation *expectComplete = |
|
|
|
|
[self expectationWithDescription:@"LargeUnaryWithV2API received complete"]; |
|
|
|
|
|
|
|
|
|
const int responseSize = 123; |
|
|
|
|
RMTSimpleRequest *request = [RMTSimpleRequest message]; |
|
|
|
|
request.responseType = RMTPayloadType_Compressable; |
|
|
|
|
request.responseSize = responseSize; |
|
|
|
|
request.payload.body = [NSMutableData dataWithLength:456]; |
|
|
|
|
|
|
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
|
// For backwards compatibility |
|
|
|
|
options.transportType = [[self class] transportType]; |
|
|
|
|
options.transport = [[self class] transport]; |
|
|
|
|
options.PEMRootCertificates = [[self class] PEMRootCertificates]; |
|
|
|
|
options.hostNameOverride = [[self class] hostNameOverride]; |
|
|
|
|
options.flowControlEnabled = YES; |
|
|
|
|
|
|
|
|
|
GRPCUnaryProtoCall *call = [_service |
|
|
|
|
unaryCallWithMessage:request |
|
|
|
|
responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil |
|
|
|
|
messageCallback:^(id message) { |
|
|
|
|
XCTAssertNotNil(message); |
|
|
|
|
if (message) { |
|
|
|
|
RMTSimpleResponse *expectedResponse = |
|
|
|
|
[RMTSimpleResponse message]; |
|
|
|
|
expectedResponse.payload.type = RMTPayloadType_Compressable; |
|
|
|
|
expectedResponse.payload.body = |
|
|
|
|
[NSMutableData dataWithLength:responseSize]; |
|
|
|
|
XCTAssertEqualObjects(message, expectedResponse); |
|
|
|
|
[expectReceive fulfill]; |
|
|
|
|
[call finish]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
closeCallback:^(NSDictionary *trailingMetadata, NSError *error) { |
|
|
|
|
XCTAssertNil(error, @"Unexpected error: %@", error); |
|
|
|
|
[expectComplete fulfill]; |
|
|
|
|
}] |
|
|
|
|
callOptions:options]; |
|
|
|
|
[call start]; |
|
|
|
|
[call receiveNextMessage]; |
|
|
|
|
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)testUnaryRPCWithV2APIFlowControlNotReceivingMessage { |
|
|
|
|
XCTAssertNotNil([[self class] host]); |
|
|
|
|
|
|
|
|
|
__weak XCTestExpectation *expectTimeout = |
|
|
|
|
[self expectationWithDescription: |
|
|
|
|
@"testUnaryRPCWithV2APIFlowControlNotReceivingMessage received timeout"]; |
|
|
|
|
|
|
|
|
|
RMTSimpleRequest *request = [RMTSimpleRequest message]; |
|
|
|
|
request.responseType = RMTPayloadType_Compressable; |
|
|
|
|
request.responseSize = 123; |
|
|
|
|
request.payload.body = [NSMutableData dataWithLength:456]; |
|
|
|
|
|
|
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
|
// For backwards compatibility |
|
|
|
|
options.transportType = [[self class] transportType]; |
|
|
|
|
options.transport = [[self class] transport]; |
|
|
|
|
options.PEMRootCertificates = [[self class] PEMRootCertificates]; |
|
|
|
|
options.hostNameOverride = [[self class] hostNameOverride]; |
|
|
|
|
options.flowControlEnabled = YES; |
|
|
|
|
|
|
|
|
|
GRPCUnaryProtoCall *call = [_service |
|
|
|
|
unaryCallWithMessage:request |
|
|
|
|
responseHandler:[[InteropTestsBlockCallbacks alloc] |
|
|
|
|
initWithInitialMetadataCallback:nil |
|
|
|
|
messageCallback:^(id message) { |
|
|
|
|
XCTFail("Not expected to receive message"); |
|
|
|
|
} |
|
|
|
|
closeCallback:nil] |
|
|
|
|
callOptions:options]; |
|
|
|
|
[call start]; |
|
|
|
|
XCTWaiterResult result = [XCTWaiter waitForExpectations:@[ expectTimeout ] timeout:5]; |
|
|
|
|
XCTAssertEqual(XCTWaiterResultTimedOut, result, @"Unexpected waiter result %@", @(result)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)testConcurrentRPCsWithErrorsWithV2API { |
|
|
|
|
NSMutableArray *completeExpectations = [NSMutableArray array]; |
|
|
|
|
NSMutableArray *calls = [NSMutableArray array]; |
|
|
|
@ -1159,72 +1078,9 @@ static dispatch_once_t initGlobalInterceptorFactory; |
|
|
|
|
[self waitForExpectationsWithTimeout:STREAMING_CALL_TEST_TIMEOUT handler:nil]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)testPingPongUnaryRPCWithFlowControl { |
|
|
|
|
- (void)testPingPongRPCWithFlowControl { |
|
|
|
|
XCTAssertNotNil([[self class] host]); |
|
|
|
|
__weak XCTestExpectation *expectation = |
|
|
|
|
[self expectationWithDescription:@"UnaryPingPongWithV2API"]; |
|
|
|
|
|
|
|
|
|
NSNumber *requestSize = @321; |
|
|
|
|
NSArray *responseSizes = @[ @123, @234 ]; |
|
|
|
|
|
|
|
|
|
RMTStreamingOutputCallRequest *request = [RMTStreamingOutputCallRequest message]; |
|
|
|
|
request.payload.body = [NSMutableData dataWithLength:requestSize.unsignedIntegerValue]; |
|
|
|
|
for (NSNumber *responseSize in responseSizes) { |
|
|
|
|
RMTResponseParameters *parameters = [RMTResponseParameters message]; |
|
|
|
|
parameters.size = responseSize.intValue; |
|
|
|
|
[request.responseParametersArray addObject:parameters]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
|
// For backwards compatibility |
|
|
|
|
options.transportType = [[self class] transportType]; |
|
|
|
|
options.transport = [[self class] transport]; |
|
|
|
|
options.PEMRootCertificates = [[self class] PEMRootCertificates]; |
|
|
|
|
options.hostNameOverride = [[self class] hostNameOverride]; |
|
|
|
|
options.flowControlEnabled = YES; |
|
|
|
|
|
|
|
|
|
__block GRPCUnaryProtoCall *call = nil; |
|
|
|
|
__block int receivedMessageCount = 0; |
|
|
|
|
|
|
|
|
|
id messageHandler = ^(id message) { |
|
|
|
|
NSLog(@"received message %@", @(receivedMessageCount)); |
|
|
|
|
XCTAssertLessThan(receivedMessageCount, responseSizes.count, |
|
|
|
|
"More than expected messages received"); |
|
|
|
|
id expected = |
|
|
|
|
[RMTStreamingOutputCallResponse messageWithPayloadSize:responseSizes[receivedMessageCount]]; |
|
|
|
|
XCTAssertEqualObjects(message, expected); |
|
|
|
|
|
|
|
|
|
receivedMessageCount += 1; |
|
|
|
|
if (receivedMessageCount < responseSizes.count) { |
|
|
|
|
[call receiveNextMessage]; |
|
|
|
|
} else { |
|
|
|
|
[call finish]; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
id closeHandler = ^(NSDictionary *trailingMetadata, NSError *error) { |
|
|
|
|
XCTAssertNil(error, @"Finished with unexpected error: %@", error); |
|
|
|
|
[expectation fulfill]; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
InteropTestsBlockCallbacks *handler = |
|
|
|
|
[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil |
|
|
|
|
messageCallback:messageHandler |
|
|
|
|
closeCallback:closeHandler |
|
|
|
|
writeMessageCallback:nil]; |
|
|
|
|
|
|
|
|
|
call = [_service streamingOutputCallWithMessage:request |
|
|
|
|
responseHandler:handler |
|
|
|
|
callOptions:options]; |
|
|
|
|
[call start]; |
|
|
|
|
[call receiveNextMessage]; |
|
|
|
|
[self waitForExpectationsWithTimeout:STREAMING_CALL_TEST_TIMEOUT handler:nil]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)testPingPongStreamingRPCWithFlowControl { |
|
|
|
|
XCTAssertNotNil([[self class] host]); |
|
|
|
|
__weak XCTestExpectation *expectation = |
|
|
|
|
[self expectationWithDescription:@"StreamingPingPongWithV2API"]; |
|
|
|
|
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPongWithV2API"]; |
|
|
|
|
|
|
|
|
|
NSArray *requests = @[ @27182, @8, @1828, @45904 ]; |
|
|
|
|
NSArray *responses = @[ @31415, @9, @2653, @58979 ]; |
|
|
|
|