aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/tests
diff options
context:
space:
mode:
authorGravatar Muxi Yan <muxi@users.noreply.github.com>2018-03-28 17:14:26 -0700
committerGravatar GitHub <noreply@github.com>2018-03-28 17:14:26 -0700
commit53f0b8d1487f31b4de44cebaf8bca68ca043d3e8 (patch)
tree52fb0eb9273aa89179cd2445ac118acfb89c86af /src/objective-c/tests
parent07e75a02a0b004b93bc32667159c327747548855 (diff)
parent4c0872d44e94ac59fe1f3f478fc842e0aa9913e3 (diff)
Merge pull request #14781 from muxi/objc-keep-alive
Allow gRPC ObjC user to set keepalive options
Diffstat (limited to 'src/objective-c/tests')
-rw-r--r--src/objective-c/tests/InteropTests.m42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m
index dfa874adab..bfc4755c15 100644
--- a/src/objective-c/tests/InteropTests.m
+++ b/src/objective-c/tests/InteropTests.m
@@ -486,4 +486,46 @@ BOOL isRemoteInteropTest(NSString *host) {
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
+#ifndef GRPC_COMPILE_WITH_CRONET
+- (void)testKeepalive {
+ XCTAssertNotNil(self.class.host);
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"];
+
+ [GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:self.class.host];
+
+ NSArray *requests = @[@27182, @8];
+ NSArray *responses = @[@31415, @9];
+
+ GRXBufferedPipe *requestsBuffer = [[GRXBufferedPipe alloc] init];
+
+ __block int index = 0;
+
+ id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index]
+ requestedResponseSize:responses[index]];
+ [requestsBuffer writeValue:request];
+
+ [_service fullDuplexCallWithRequestsWriter:requestsBuffer
+ eventHandler:^(BOOL done,
+ RMTStreamingOutputCallResponse *response,
+ NSError *error) {
+ if (index == 0) {
+ XCTAssertNil(error, @"Finished with unexpected error: %@", error);
+ XCTAssertTrue(response, @"Event handler called without an event.");
+ XCTAssertFalse(done);
+ index++;
+ } else {
+ // Keepalive should kick after 1s elapsed and fails the call.
+ XCTAssertNotNil(error);
+ XCTAssertEqual(error.code, GRPC_STATUS_INTERNAL);
+ XCTAssertEqualObjects(error.localizedDescription, @"keepalive watchdog timeout",
+ @"Unexpected failure that is not keepalive watchdog timeout.");
+ XCTAssertTrue(done);
+ [expectation fulfill];
+ }
+ }];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+#endif
+
@end