[ObjC]interop tests with bazel (#29800)

* interop tests with bazel

* remove env in BUILD

* clang format
pull/29981/head
Hannah Shi 2 years ago committed by GitHub
parent 8459824e5c
commit 3ad945947c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/objective-c/tests/InteropTests/InteropTestsLocalCleartext.m
  2. 9
      src/objective-c/tests/InteropTests/InteropTestsLocalSSL.m
  3. 17
      src/objective-c/tests/InteropTests/InteropTestsMultipleChannels.m
  4. 2
      tools/internal_ci/macos/grpc_objc_bazel_test.sh
  5. 7
      tools/run_tests/run_tests.py

@ -20,13 +20,13 @@
#import <GRPCClient/GRPCTransport.h> #import <GRPCClient/GRPCTransport.h>
#import <GRPCClient/internal_testing/GRPCCall+InternalTests.h> #import <GRPCClient/internal_testing/GRPCCall+InternalTests.h>
#import "../Common/TestUtils.h"
#import "InteropTests.h" #import "InteropTests.h"
// The server address is derived from preprocessor macro, which is // The server address is derived from preprocessor macro, which is
// in turn derived from environment variable of the same name. // in turn derived from environment variable of the same name.
#define NSStringize_helper(x) #x #define NSStringize_helper(x) #x
#define NSStringize(x) @NSStringize_helper(x) #define NSStringize(x) @NSStringize_helper(x)
static NSString *const kLocalCleartextHost = NSStringize(HOST_PORT_LOCAL);
// The Protocol Buffers encoding overhead of local interop server. Acquired // The Protocol Buffers encoding overhead of local interop server. Acquired
// by experiment. Adjust this when server's proto file changes. // by experiment. Adjust this when server's proto file changes.
@ -39,7 +39,7 @@ static int32_t kLocalInteropServerOverhead = 10;
@implementation InteropTestsLocalCleartext @implementation InteropTestsLocalCleartext
+ (NSString *)host { + (NSString *)host {
return kLocalCleartextHost; return GRPCGetLocalInteropTestServerAddressPlainText();
} }
+ (NSString *)PEMRootCertificates { + (NSString *)PEMRootCertificates {
@ -58,7 +58,7 @@ static int32_t kLocalInteropServerOverhead = 10;
[super setUp]; [super setUp];
// Register test server as non-SSL. // Register test server as non-SSL.
[GRPCCall useInsecureConnectionsForHost:kLocalCleartextHost]; [GRPCCall useInsecureConnectionsForHost:GRPCGetLocalInteropTestServerAddressPlainText()];
} }
+ (GRPCTransportID)transport { + (GRPCTransportID)transport {

@ -20,12 +20,13 @@
#import <GRPCClient/GRPCTransport.h> #import <GRPCClient/GRPCTransport.h>
#import <GRPCClient/internal_testing/GRPCCall+InternalTests.h> #import <GRPCClient/internal_testing/GRPCCall+InternalTests.h>
#import "../Common/TestUtils.h"
#import "InteropTests.h" #import "InteropTests.h"
// The server address is derived from preprocessor macro, which is // The server address is derived from preprocessor macro, which is
// in turn derived from environment variable of the same name. // in turn derived from environment variable of the same name.
#define NSStringize_helper(x) #x #define NSStringize_helper(x) #x
#define NSStringize(x) @NSStringize_helper(x) #define NSStringize(x) @NSStringize_helper(x)
static NSString *const kLocalSSLHost = NSStringize(HOST_PORT_LOCALSSL);
// The Protocol Buffers encoding overhead of local interop server. Acquired // The Protocol Buffers encoding overhead of local interop server. Acquired
// by experiment. Adjust this when server's proto file changes. // by experiment. Adjust this when server's proto file changes.
@ -38,7 +39,7 @@ static int32_t kLocalInteropServerOverhead = 10;
@implementation InteropTestsLocalSSL @implementation InteropTestsLocalSSL
+ (NSString *)host { + (NSString *)host {
return kLocalSSLHost; return GRPCGetLocalInteropTestServerAddressSSL();
} }
+ (NSString *)PEMRootCertificates { + (NSString *)PEMRootCertificates {
@ -68,7 +69,9 @@ static int32_t kLocalInteropServerOverhead = 10;
NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates" NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
ofType:@"pem"]; ofType:@"pem"];
[GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:kLocalSSLHost]; [GRPCCall useTestCertsPath:certsPath
testName:@"foo.test.google.fr"
forHost:GRPCGetLocalInteropTestServerAddressSSL()];
} }
- (void)testExceptions { - (void)testExceptions {

@ -25,14 +25,12 @@
#import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbobjc.h"
#import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h" #import "src/objective-c/tests/RemoteTestClient/Test.pbrpc.h"
#import "../Common/TestUtils.h"
#import "../ConfigureCronet.h" #import "../ConfigureCronet.h"
#import "InteropTestsBlockCallbacks.h" #import "InteropTestsBlockCallbacks.h"
#define NSStringize_helper(x) #x #define NSStringize_helper(x) #x
#define NSStringize(x) @NSStringize_helper(x) #define NSStringize(x) @NSStringize_helper(x)
static NSString *const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE);
static NSString *const kLocalSSLHost = NSStringize(HOST_PORT_LOCALSSL);
static NSString *const kLocalCleartextHost = NSStringize(HOST_PORT_LOCAL);
static const NSTimeInterval TEST_TIMEOUT = 8000; static const NSTimeInterval TEST_TIMEOUT = 8000;
@ -84,19 +82,23 @@ dispatch_once_t initCronet;
self.continueAfterFailure = NO; self.continueAfterFailure = NO;
_remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:nil]; _remoteService = [RMTTestService serviceWithHost:GRPCGetRemoteInteropTestServerAddress()
callOptions:nil];
configureCronet(/*enable_netlog=*/false); configureCronet(/*enable_netlog=*/false);
// Default stack with remote host // Default stack with remote host
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeCronet; options.transportType = GRPCTransportTypeCronet;
// Cronet stack with remote host // Cronet stack with remote host
_remoteCronetService = [RMTTestService serviceWithHost:kRemoteSSLHost callOptions:options]; _remoteCronetService = [RMTTestService serviceWithHost:GRPCGetRemoteInteropTestServerAddress()
callOptions:options];
// Local stack with no SSL // Local stack with no SSL
options = [[GRPCMutableCallOptions alloc] init]; options = [[GRPCMutableCallOptions alloc] init];
options.transportType = GRPCTransportTypeInsecure; options.transportType = GRPCTransportTypeInsecure;
_localCleartextService = [RMTTestService serviceWithHost:kLocalCleartextHost callOptions:options]; _localCleartextService =
[RMTTestService serviceWithHost:GRPCGetLocalInteropTestServerAddressPlainText()
callOptions:options];
// Local stack with SSL // Local stack with SSL
NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSBundle *bundle = [NSBundle bundleForClass:[self class]];
@ -112,7 +114,8 @@ dispatch_once_t initCronet;
options.transportType = GRPCTransportTypeChttp2BoringSSL; options.transportType = GRPCTransportTypeChttp2BoringSSL;
options.PEMRootCertificates = certs; options.PEMRootCertificates = certs;
options.hostNameOverride = @"foo.test.google.fr"; options.hostNameOverride = @"foo.test.google.fr";
_localSSLService = [RMTTestService serviceWithHost:kLocalSSLHost callOptions:options]; _localSSLService = [RMTTestService serviceWithHost:GRPCGetLocalInteropTestServerAddressSSL()
callOptions:options];
} }
- (void)testEmptyUnaryRPC { - (void)testEmptyUnaryRPC {

@ -47,7 +47,7 @@ EXAMPLE_TARGETS=(
TEST_TARGETS=( TEST_TARGETS=(
# TODO(jtattermusch): ideally we'd say "//src/objective-c/tests/..." but not all the targets currently build # TODO(jtattermusch): ideally we'd say "//src/objective-c/tests/..." but not all the targets currently build
# TODO(jtattermusch): make //src/objective-c/tests:TvTests test pass with bazel # TODO(jtattermusch): make //src/objective-c/tests:TvTests test pass with bazel
# TODO(jtattermusch): make sure the //src/objective-c/tests:InteropTests test passes reliably under bazel //src/objective-c/tests:InteropTests
//src/objective-c/tests:MacTests //src/objective-c/tests:MacTests
//src/objective-c/tests:UnitTests //src/objective-c/tests:UnitTests
# codegen plugin tests # codegen plugin tests

@ -1030,13 +1030,6 @@ class ObjCLanguage(object):
shortname='ios-test-core-tests', shortname='ios-test-core-tests',
cpu_cost=1e6, cpu_cost=1e6,
environ=_FORCE_ENVIRON_FOR_WRAPPERS)) environ=_FORCE_ENVIRON_FOR_WRAPPERS))
# TODO(jtattermusch): Make sure the //src/objective-c/tests:InteropTests bazel test passes reliably and remove the test from there.
out.append(
self.config.job_spec(['src/objective-c/tests/run_one_test.sh'],
timeout_seconds=60 * 60,
shortname='ios-test-interoptests',
cpu_cost=1e6,
environ={'SCHEME': 'InteropTests'}))
# TODO(jtattermusch): Create bazel target for the test and remove the test from here # TODO(jtattermusch): Create bazel target for the test and remove the test from here
# (how does one add the cronet dependency in bazel?) # (how does one add the cronet dependency in bazel?)
out.append( out.append(

Loading…
Cancel
Save