|
|
@ -47,14 +47,10 @@ NSString *kDummyHost = @"dummy.host"; |
|
|
|
|
|
|
|
|
|
|
|
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; |
|
|
|
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; |
|
|
|
|
|
|
|
|
|
|
|
GRPCChannel *channel1 = [pool channelWithHost:kDummyHost |
|
|
|
GRPCChannel *channel1 = [pool channelWithHost:kDummyHost callOptions:options1]; |
|
|
|
callOptions:options1]; |
|
|
|
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost callOptions:options2]; |
|
|
|
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost |
|
|
|
GRPCChannel *channel3 = [pool channelWithHost:kDummyHost2 callOptions:options1]; |
|
|
|
callOptions:options2]; |
|
|
|
GRPCChannel *channel4 = [pool channelWithHost:kDummyHost callOptions:options3]; |
|
|
|
GRPCChannel *channel3 = [pool channelWithHost:kDummyHost2 |
|
|
|
|
|
|
|
callOptions:options1]; |
|
|
|
|
|
|
|
GRPCChannel *channel4 = [pool channelWithHost:kDummyHost |
|
|
|
|
|
|
|
callOptions:options3]; |
|
|
|
|
|
|
|
XCTAssertEqual(channel1, channel2); |
|
|
|
XCTAssertEqual(channel1, channel2); |
|
|
|
XCTAssertNotEqual(channel1, channel3); |
|
|
|
XCTAssertNotEqual(channel1, channel3); |
|
|
|
XCTAssertNotEqual(channel1, channel4); |
|
|
|
XCTAssertNotEqual(channel1, channel4); |
|
|
@ -66,16 +62,14 @@ NSString *kDummyHost = @"dummy.host"; |
|
|
|
|
|
|
|
|
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; |
|
|
|
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; |
|
|
|
GRPCChannel *channel = [pool channelWithHost:kDummyHost |
|
|
|
GRPCChannel *channel = [pool channelWithHost:kDummyHost callOptions:options]; |
|
|
|
callOptions:options]; |
|
|
|
|
|
|
|
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" |
|
|
|
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" |
|
|
|
completionQueue:[GRPCCompletionQueue completionQueue] |
|
|
|
completionQueue:[GRPCCompletionQueue completionQueue] |
|
|
|
callOptions:options |
|
|
|
callOptions:options |
|
|
|
disconnected:nil]; |
|
|
|
disconnected:nil]; |
|
|
|
[pool destroyAllChannels]; |
|
|
|
[pool destroyAllChannels]; |
|
|
|
XCTAssertTrue(channel.disconnected); |
|
|
|
XCTAssertTrue(channel.disconnected); |
|
|
|
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost |
|
|
|
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost callOptions:options]; |
|
|
|
callOptions:options]; |
|
|
|
|
|
|
|
XCTAssertNotEqual(channel, channel2); |
|
|
|
XCTAssertNotEqual(channel, channel2); |
|
|
|
grpc_call_unref(call); |
|
|
|
grpc_call_unref(call); |
|
|
|
} |
|
|
|
} |
|
|
@ -86,9 +80,8 @@ NSString *kDummyHost = @"dummy.host"; |
|
|
|
|
|
|
|
|
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; |
|
|
|
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; |
|
|
|
GRPCChannel *channel = [pool channelWithHost:kDummyHost |
|
|
|
GRPCChannel *channel = |
|
|
|
callOptions:options |
|
|
|
[pool channelWithHost:kDummyHost callOptions:options destroyDelay:kDestroyDelay]; |
|
|
|
destroyDelay:kDestroyDelay]; |
|
|
|
|
|
|
|
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" |
|
|
|
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" |
|
|
|
completionQueue:[GRPCCompletionQueue completionQueue] |
|
|
|
completionQueue:[GRPCCompletionQueue completionQueue] |
|
|
|
callOptions:options |
|
|
|
callOptions:options |
|
|
@ -97,9 +90,8 @@ NSString *kDummyHost = @"dummy.host"; |
|
|
|
[channel unref]; |
|
|
|
[channel unref]; |
|
|
|
|
|
|
|
|
|
|
|
// Test that we can still get the channel at this time |
|
|
|
// Test that we can still get the channel at this time |
|
|
|
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost |
|
|
|
GRPCChannel *channel2 = |
|
|
|
callOptions:options |
|
|
|
[pool channelWithHost:kDummyHost callOptions:options destroyDelay:kDestroyDelay]; |
|
|
|
destroyDelay:kDestroyDelay]; |
|
|
|
|
|
|
|
XCTAssertEqual(channel, channel2); |
|
|
|
XCTAssertEqual(channel, channel2); |
|
|
|
call = [channel2 unmanagedCallWithPath:@"dummy.path" |
|
|
|
call = [channel2 unmanagedCallWithPath:@"dummy.path" |
|
|
|
completionQueue:[GRPCCompletionQueue completionQueue] |
|
|
|
completionQueue:[GRPCCompletionQueue completionQueue] |
|
|
@ -117,9 +109,8 @@ NSString *kDummyHost = @"dummy.host"; |
|
|
|
|
|
|
|
|
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; |
|
|
|
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; |
|
|
|
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; |
|
|
|
GRPCChannel *channel = [pool channelWithHost:kDummyHost |
|
|
|
GRPCChannel *channel = |
|
|
|
callOptions:options |
|
|
|
[pool channelWithHost:kDummyHost callOptions:options destroyDelay:kDestroyDelay]; |
|
|
|
destroyDelay:kDestroyDelay]; |
|
|
|
|
|
|
|
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" |
|
|
|
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" |
|
|
|
completionQueue:[GRPCCompletionQueue completionQueue] |
|
|
|
completionQueue:[GRPCCompletionQueue completionQueue] |
|
|
|
callOptions:options |
|
|
|
callOptions:options |
|
|
@ -130,9 +121,8 @@ NSString *kDummyHost = @"dummy.host"; |
|
|
|
sleep(kDestroyDelay + 1); |
|
|
|
sleep(kDestroyDelay + 1); |
|
|
|
|
|
|
|
|
|
|
|
// Test that we get new channel to the same host and with the same callOptions |
|
|
|
// Test that we get new channel to the same host and with the same callOptions |
|
|
|
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost |
|
|
|
GRPCChannel *channel2 = |
|
|
|
callOptions:options |
|
|
|
[pool channelWithHost:kDummyHost callOptions:options destroyDelay:kDestroyDelay]; |
|
|
|
destroyDelay:kDestroyDelay]; |
|
|
|
|
|
|
|
XCTAssertNotEqual(channel, channel2); |
|
|
|
XCTAssertNotEqual(channel, channel2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|