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
- (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 {
(void)[[GRPCCall alloc] initWithHost:nil

@ -46,4 +46,11 @@
* Override in a subclass to perform these tests against a specific address.
*/
+ (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

@ -88,6 +88,10 @@
return nil;
}
- (int32_t)encodingOverhead {
return 0;
}
- (void)setUp {
self.continueAfterFailure = NO;
@ -150,7 +154,7 @@
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"MaxResponseSize"];
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;
[_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) {
@ -167,7 +171,7 @@
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"];
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;
[_service unaryCallWithRequest:request handler:^(RMTSimpleResponse *response, NSError *error) {

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

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

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

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

Loading…
Cancel
Save