Fix local server tests & exceptions tests

pull/7572/head
Jorge Canizales 8 years ago
parent 32fde7af29
commit 9e83d7ef0f
  1. 9
      src/objective-c/tests/GRPCClientTests.m
  2. 7
      src/objective-c/tests/InteropTests.h
  3. 8
      src/objective-c/tests/InteropTests.m
  4. 4
      src/objective-c/tests/InteropTestsLocalCleartext.m
  5. 4
      src/objective-c/tests/InteropTestsLocalSSL.m
  6. 4
      src/objective-c/tests/InteropTestsRemote.m
  7. 6
      src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/AllTests.xcscheme

@ -292,15 +292,6 @@ static GRPCProtoMethod *kUnaryCallMethod;
// TODO(makarandd): Move to a different file that contains only unit tests // TODO(makarandd): Move to a different file that contains only unit tests
- (void)testExceptions { - (void)testExceptions {
// Try to set userAgentPrefix for host that is nil. This should cause
// an exception.
@try {
[GRPCCall setUserAgentPrefix:@"Foo" forHost:nil];
XCTFail(@"Did not receive an exception when host is nil");
} @catch(NSException *theException) {
NSLog(@"Received exception as expected: %@", theException.name);
}
// Try to set parameters to nil for GRPCCall. This should cause an exception // Try to set parameters to nil for GRPCCall. This should cause an exception
@try { @try {
(void)[[GRPCCall alloc] initWithHost:nil (void)[[GRPCCall alloc] initWithHost:nil

@ -46,4 +46,11 @@
* Override in a subclass to perform these tests against a specific address. * Override in a subclass to perform these tests against a specific address.
*/ */
+ (NSString *)host; + (NSString *)host;
/**
* Bytes of overhead of test proto responses due to encoding. This is used to excercise the behavior
* when responses are just above or below the max response size. For some reason, the local and
* remote servers enconde responses with different overhead (?), so this is defined per-subclass.
*/
- (int32_t)encodingOverhead;
@end @end

@ -88,6 +88,10 @@
return nil; return nil;
} }
- (int32_t)encodingOverhead {
return 0;
}
- (void)setUp { - (void)setUp {
self.continueAfterFailure = NO; self.continueAfterFailure = NO;
@ -150,7 +154,7 @@
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"MaxResponseSize"]; __weak XCTestExpectation *expectation = [self expectationWithDescription:@"MaxResponseSize"];
RMTSimpleRequest *request = [RMTSimpleRequest message]; RMTSimpleRequest *request = [RMTSimpleRequest message];
const size_t kPayloadSize = 4 * 1024 * 1024 - 12; // 4MB - 12B of protobuf encoding overhead const int32_t kPayloadSize = 4 * 1024 * 1024 - self.encodingOverhead; // 4MB - encoding overhead
request.responseSize = kPayloadSize; request.responseSize = kPayloadSize;
[_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) { [_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) {
@ -167,7 +171,7 @@
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"]; __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"];
RMTSimpleRequest *request = [RMTSimpleRequest message]; RMTSimpleRequest *request = [RMTSimpleRequest message];
const size_t kPayloadSize = 4 * 1024 * 1024 - 11; // 1B over max size (see above test) const int32_t kPayloadSize = 4 * 1024 * 1024 - self.encodingOverhead + 1; // 1B over max size
request.responseSize = kPayloadSize; request.responseSize = kPayloadSize;
[_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) { [_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) {

@ -47,6 +47,10 @@ static NSString * const kLocalCleartextHost = @"localhost:5050";
return kLocalCleartextHost; return kLocalCleartextHost;
} }
- (int32_t)encodingOverhead {
return 10; // bytes
}
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];

@ -47,6 +47,10 @@ static NSString * const kLocalSSLHost = @"localhost:5051";
return kLocalSSLHost; return kLocalSSLHost;
} }
- (int32_t)encodingOverhead {
return 10; // bytes
}
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];

@ -47,4 +47,8 @@ static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com";
return kRemoteSSLHost; return kRemoteSSLHost;
} }
- (int32_t)encodingOverhead {
return 12; // bytes
}
@end @end

@ -38,12 +38,6 @@
ReferencedContainer = "container:Tests.xcodeproj"> ReferencedContainer = "container:Tests.xcodeproj">
</BuildableReference> </BuildableReference>
<SkippedTests> <SkippedTests>
<Test
Identifier = "GRPCClientTests/testConnectionToRemoteServer">
</Test>
<Test
Identifier = "GRPCClientTests/testMetadata">
</Test>
<Test <Test
Identifier = "InteropTests"> Identifier = "InteropTests">
</Test> </Test>

Loading…
Cancel
Save