Merge pull request #10609 from makdharma/xcodebuild_cmdline

add cmdline arg for ObjC interop tests. Add objc to interop_tests.py
pull/10707/head
makdharma 8 years ago committed by GitHub
commit 8938943fce
  1. 6
      src/objective-c/tests/InteropTestsLocalCleartext.m
  2. 7
      src/objective-c/tests/InteropTestsLocalSSL.m
  3. 6
      src/objective-c/tests/InteropTestsRemote.m
  4. 7
      src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m
  5. 4
      src/objective-c/tests/Tests.xcodeproj/project.pbxproj
  6. 4
      src/objective-c/tests/run_tests.sh
  7. 39
      tools/jenkins/run_interop_objc.sh
  8. 49
      tools/run_tests/run_interop_tests.py

@ -36,7 +36,11 @@
#import "InteropTests.h" #import "InteropTests.h"
static NSString * const kLocalCleartextHost = @"localhost:5050"; // The server address is derived from preprocessor macro, which is
// in turn derived from environment variable of the same name.
#define NSStringize_helper(x) #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.

@ -35,8 +35,11 @@
#import <GRPCClient/internal_testing/GRPCCall+InternalTests.h> #import <GRPCClient/internal_testing/GRPCCall+InternalTests.h>
#import "InteropTests.h" #import "InteropTests.h"
// The server address is derived from preprocessor macro, which is
static NSString * const kLocalSSLHost = @"localhost:5051"; // in turn derived from environment variable of the same name.
#define NSStringize_helper(x) #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.

@ -36,7 +36,11 @@
#import "InteropTests.h" #import "InteropTests.h"
static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; // The server address is derived from preprocessor macro, which is
// in turn derived from environment variable of the same name.
#define NSStringize_helper(x) #x
#define NSStringize(x) @NSStringize_helper(x)
static NSString * const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE);
// The Protocol Buffers encoding overhead of remote interop server. Acquired // The Protocol Buffers encoding overhead of remote 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,12 @@
#import "InteropTests.h" #import "InteropTests.h"
static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; // The server address is derived from preprocessor macro, which is
// in turn derived from environment variable of the same name.
#define NSStringize_helper(x) #x
#define NSStringize(x) @NSStringize_helper(x)
static NSString * const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE);
// The Protocol Buffers encoding overhead of remote interop server. Acquired // The Protocol Buffers encoding overhead of remote interop server. Acquired
// by experiment. Adjust this when server's proto file changes. // by experiment. Adjust this when server's proto file changes.

@ -1282,6 +1282,9 @@
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1", "DEBUG=1",
"$(inherited)", "$(inherited)",
"HOST_PORT_LOCALSSL=$(HOST_PORT_LOCALSSL)",
"HOST_PORT_LOCAL=$(HOST_PORT_LOCAL)",
"HOST_PORT_REMOTE=$(HOST_PORT_REMOTE)",
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@ -1565,6 +1568,7 @@
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1", "DEBUG=1",
"$(inherited)", "$(inherited)",
"HOST_PORT_REMOTE=$(HOST_PORT_REMOTE)",
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES;

@ -59,6 +59,9 @@ xcodebuild \
-workspace Tests.xcworkspace \ -workspace Tests.xcworkspace \
-scheme AllTests \ -scheme AllTests \
-destination name="iPhone 6" \ -destination name="iPhone 6" \
HOST_PORT_LOCALSSL=localhost:5051 \
HOST_PORT_LOCAL=localhost:5050 \
HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \
test | xcpretty test | xcpretty
echo "TIME: $(date)" echo "TIME: $(date)"
@ -84,4 +87,5 @@ xcodebuild \
-workspace Tests.xcworkspace \ -workspace Tests.xcworkspace \
-scheme InteropTestsRemoteWithCronet \ -scheme InteropTestsRemoteWithCronet \
-destination name="iPhone 6" \ -destination name="iPhone 6" \
HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \
test | xcpretty test | xcpretty

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Copyright 2017, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# This script is invoked by Jenkins and runs interop test suite.
set -ex
export LANG=en_US.UTF-8
# Enter the gRPC repo root
cd $(dirname $0)/../..
tools/run_tests/run_interop_tests.py -l objc -s all --use_docker -t -j 1 $@ || true

@ -371,6 +371,39 @@ class PHP7Language:
def __str__(self): def __str__(self):
return 'php7' return 'php7'
class ObjcLanguage:
def __init__(self):
self.client_cwd = 'src/objective-c/tests'
self.safename = str(self)
def client_cmd(self, args):
# from args, extract the server port and craft xcodebuild command out of it
for arg in args:
port = re.search('--server_port=(\d+)', arg)
if port:
portnum = port.group(1)
cmdline = 'pod install && xcodebuild -workspace Tests.xcworkspace -scheme InteropTestsLocalSSL -destination name="iPhone 6" HOST_PORT_LOCALSSL=localhost:%s test'%portnum
return [cmdline]
def cloud_to_prod_env(self):
return {}
def global_env(self):
return {}
def unimplemented_test_cases(self):
# ObjC test runs all cases with the same command. It ignores the testcase
# cmdline argument. Here we return all but one test cases as unimplemented,
# and depend upon ObjC test's behavior that it runs all cases even when
# we tell it to run just one.
return _TEST_CASES[1:] + _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING
def unimplemented_test_cases_server(self):
return _SKIP_COMPRESSION
def __str__(self):
return 'objc'
class RubyLanguage: class RubyLanguage:
@ -402,7 +435,6 @@ class RubyLanguage:
def __str__(self): def __str__(self):
return 'ruby' return 'ruby'
class PythonLanguage: class PythonLanguage:
def __init__(self): def __init__(self):
@ -460,6 +492,7 @@ _LANGUAGES = {
'node' : NodeLanguage(), 'node' : NodeLanguage(),
'php' : PHPLanguage(), 'php' : PHPLanguage(),
'php7' : PHP7Language(), 'php7' : PHP7Language(),
'objc' : ObjcLanguage(),
'ruby' : RubyLanguage(), 'ruby' : RubyLanguage(),
'python' : PythonLanguage(), 'python' : PythonLanguage(),
} }
@ -667,7 +700,8 @@ def cloud_to_cloud_jobspec(language, test_case, server_name, server_host,
cwd = language.client_cwd cwd = language.client_cwd
environ = language.global_env() environ = language.global_env()
if docker_image: if docker_image and language.safename != 'objc':
# we can't run client in docker for objc.
container_name = dockerjob.random_name('interop_client_%s' % language.safename) container_name = dockerjob.random_name('interop_client_%s' % language.safename)
cmdline = docker_run_cmdline(cmdline, cmdline = docker_run_cmdline(cmdline,
image=docker_image, image=docker_image,
@ -820,7 +854,7 @@ argp.add_argument('-l', '--language',
choices=['all'] + sorted(_LANGUAGES), choices=['all'] + sorted(_LANGUAGES),
nargs='+', nargs='+',
default=['all'], default=['all'],
help='Clients to run.') help='Clients to run. Objc client can be only run on OSX.')
argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int) argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int)
argp.add_argument('--cloud_to_prod', argp.add_argument('--cloud_to_prod',
default=False, default=False,
@ -913,9 +947,13 @@ if not args.use_docker and servers:
print('Running interop servers is only supported with --use_docker option enabled.') print('Running interop servers is only supported with --use_docker option enabled.')
sys.exit(1) sys.exit(1)
# we want to include everything but objc in 'all'
# because objc won't run on non-mac platforms
all_but_objc = set(six.iterkeys(_LANGUAGES)) - set(['objc'])
languages = set(_LANGUAGES[l] languages = set(_LANGUAGES[l]
for l in itertools.chain.from_iterable( for l in itertools.chain.from_iterable(
six.iterkeys(_LANGUAGES) if x == 'all' else [x] all_but_objc if x == 'all' else [x]
for x in args.language)) for x in args.language))
languages_http2_clients_for_http2_server_interop = set() languages_http2_clients_for_http2_server_interop = set()
@ -942,6 +980,9 @@ if args.use_docker:
build_jobs = [] build_jobs = []
for l in languages_to_build: for l in languages_to_build:
if str(l) == 'objc':
# we don't need to build a docker image for objc
continue
job = build_interop_image_jobspec(l) job = build_interop_image_jobspec(l)
docker_images[str(l)] = job.tag docker_images[str(l)] = job.tag
build_jobs.append(job) build_jobs.append(job)

Loading…
Cancel
Save