diff options
Diffstat (limited to 'tools/run_tests')
-rwxr-xr-x | tools/run_tests/build_node.sh | 5 | ||||
-rwxr-xr-x | tools/run_tests/build_python.sh | 49 | ||||
-rwxr-xr-x | tools/run_tests/port_server.py | 19 | ||||
-rwxr-xr-x | tools/run_tests/run_interop_tests.py | 65 | ||||
-rwxr-xr-x | tools/run_tests/run_node.sh | 12 | ||||
-rwxr-xr-x | tools/run_tests/run_python.sh | 2 | ||||
-rwxr-xr-x | tools/run_tests/run_tests.py | 69 |
7 files changed, 127 insertions, 94 deletions
diff --git a/tools/run_tests/build_node.sh b/tools/run_tests/build_node.sh index 95ffb94c6e..faa7b624b8 100755 --- a/tools/run_tests/build_node.sh +++ b/tools/run_tests/build_node.sh @@ -36,9 +36,4 @@ CONFIG=${CONFIG:-opt} # change to grpc repo root cd $(dirname $0)/../.. -export CXXFLAGS=-I`pwd`/include -export LDFLAGS=-L`pwd`/libs/$CONFIG - -cd src/node - npm install --unsafe-perm diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh index 2efc2c714d..24cf6ba7c8 100755 --- a/tools/run_tests/build_python.sh +++ b/tools/run_tests/build_python.sh @@ -39,6 +39,33 @@ GRPCIO=$ROOT/src/python/grpcio GRPCIO_TEST=$ROOT/src/python/grpcio_test GRPCIO_HEALTH_CHECKING=$ROOT/src/python/grpcio_health_checking +install_grpcio_deps() { + cd $GRPCIO + pip install -r requirements.txt +} +install_grpcio_test_deps() { + cd $GRPCIO_TEST + pip install -r requirements.txt +} + +install_grpcio() { + CFLAGS="-I$ROOT/include -std=c89" LDFLAGS=-L$ROOT/libs/$CONFIG GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install $GRPCIO +} +install_grpcio_test() { + pip install $GRPCIO_TEST +} +install_grpcio_health_checking() { + pip install $GRPCIO_HEALTH_CHECKING +} + +# Cleans the environment of previous installations +clean_grpcio_all() { + (yes | pip uninstall grpcio) || true + (yes | pip uninstall grpcio_test) || true + (yes | pip uninstall grpcio_health_checking) || true +} + +# Builds the testing environment. make_virtualenv() { virtualenv_name="python"$1"_virtual_environment" if [ ! -d $virtualenv_name ] @@ -48,33 +75,29 @@ make_virtualenv() { source $virtualenv_name/bin/activate # Install grpcio - cd $GRPCIO - pip install -r requirements.txt - CFLAGS="-I$ROOT/include -std=c89" LDFLAGS=-L$ROOT/libs/$CONFIG GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install $GRPCIO + install_grpcio_deps + install_grpcio # Install grpcio_test - cd $GRPCIO_TEST - pip install -r requirements.txt - pip install $GRPCIO_TEST + install_grpcio_test_deps + install_grpcio_test # Install grpcio_health_checking - pip install $GRPCIO_HEALTH_CHECKING + install_grpcio_health_checking else source $virtualenv_name/bin/activate # Uninstall and re-install the packages we care about. Don't use # --force-reinstall or --ignore-installed to avoid propagating this # unnecessarily to dependencies. Don't use --no-deps to avoid missing # dependency upgrades. - (yes | pip uninstall grpcio) || true - (yes | pip uninstall grpcio_test) || true - (yes | pip uninstall grpcio_health_checking) || true - (CFLAGS="-I$ROOT/include -std=c89" LDFLAGS=-L$ROOT/libs/$CONFIG GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install $GRPCIO) || ( + clean_grpcio_all + install_grpcio || ( # Fall back to rebuilding the entire environment rm -rf $virtualenv_name make_virtualenv $1 ) - pip install $GRPCIO_TEST - pip install $GRPCIO_HEALTH_CHECKING + install_grpcio_test + install_grpcio_health_checking fi } diff --git a/tools/run_tests/port_server.py b/tools/run_tests/port_server.py index 48b6214b95..b953df952c 100755 --- a/tools/run_tests/port_server.py +++ b/tools/run_tests/port_server.py @@ -38,6 +38,18 @@ import socket import sys import time + +# increment this number whenever making a change to ensure that +# the changes are picked up by running CI servers +# note that all changes must be backwards compatible +_MY_VERSION = 2 + + +if len(sys.argv) == 2 and sys.argv[1] == 'dump_version': + print _MY_VERSION + sys.exit(0) + + argp = argparse.ArgumentParser(description='Server for httpcli_test') argp.add_argument('-p', '--port', default=12345, type=int) args = argp.parse_args() @@ -47,9 +59,6 @@ print 'port server running on port %d' % args.port pool = [] in_use = {} -with open(__file__) as f: - _MY_VERSION = hashlib.sha1(f.read()).hexdigest() - def refill_pool(max_timeout, req): """Scan for ports not marked for being in use""" @@ -113,7 +122,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler): del in_use[p] pool.append(p) self.log_message('drop port %d' % p) - elif self.path == '/version': + elif self.path == '/version_number': # fetch a version string and the current process pid self.send_response(200) self.send_header('Content-Type', 'text/plain') @@ -128,7 +137,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler): self.end_headers() now = time.time() self.wfile.write(yaml.dump({'pool': pool, 'in_use': dict((k, now - v) for k, v in in_use.iteritems())})) - elif self.path == '/quit': + elif self.path == '/quitquitquit': self.send_response(200) self.end_headers() keep_running = False diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index f0935fb5d6..48c34f6871 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -82,7 +82,7 @@ class CXXLanguage: ['--use_tls=true']) def cloud_to_prod_env(self): - return None + return {} def server_args(self): return ['bins/opt/interop_server', '--use_tls=true'] @@ -132,7 +132,7 @@ class JavaLanguage: ['--use_tls=true', '--use_test_ca=true']) def cloud_to_prod_env(self): - return None + return {} def server_args(self): return ['./run-test-server.sh', '--use_tls=true'] @@ -158,7 +158,7 @@ class GoLanguage: ['--use_tls=true']) def cloud_to_prod_env(self): - return None + return {} def server_args(self): return ['go', 'run', 'server.go', '--use_tls=true'] @@ -250,8 +250,7 @@ _LANGUAGES = { } # languages supported as cloud_to_cloud servers -# TODO(jtattermusch): enable other languages as servers as well -_SERVERS = ['c++', 'node', 'csharp', 'java', 'go'] +_SERVERS = ['c++', 'node', 'csharp', 'java', 'go', 'ruby'] # TODO(jtattermusch): add empty_stream once PHP starts supporting it. # TODO(jtattermusch): add timeout_on_sleeping_server once java starts supporting it. @@ -260,6 +259,9 @@ _TEST_CASES = ['large_unary', 'empty_unary', 'ping_pong', 'client_streaming', 'server_streaming', 'cancel_after_begin', 'cancel_after_first_response'] +_AUTH_TEST_CASES = ['compute_engine_creds', 'jwt_token_creds', + 'oauth2_auth_token', 'per_rpc_creds'] + def docker_run_cmdline(cmdline, image, docker_args=[], cwd=None, environ=None): """Wraps given cmdline array to create 'docker run' cmdline from it.""" @@ -288,22 +290,54 @@ def bash_login_cmdline(cmdline): return ['bash', '-l', '-c', ' '.join(cmdline)] -def cloud_to_prod_jobspec(language, test_case, docker_image=None): +def add_auth_options(language, test_case, cmdline, env): + """Returns (cmdline, env) tuple with cloud_to_prod_auth test options.""" + + language = str(language) + cmdline = list(cmdline) + env = env.copy() + + # TODO(jtattermusch): this file path only works inside docker + key_filepath = '/root/service_account/stubbyCloudTestingTest-ee3fce360ac5.json' + oauth_scope_arg = '--oauth_scope=https://www.googleapis.com/auth/xapi.zoo' + key_file_arg = '--service_account_key_file=%s' % key_filepath + default_account_arg = '--default_service_account=830293263384-compute@developer.gserviceaccount.com' + + if test_case in ['jwt_token_creds', 'per_rpc_creds', 'oauth2_auth_token']: + if language in ['csharp', 'node', 'php', 'ruby']: + env['GOOGLE_APPLICATION_CREDENTIALS'] = key_filepath + else: + cmdline += [key_file_arg] + + if test_case in ['per_rpc_creds', 'oauth2_auth_token']: + cmdline += [oauth_scope_arg] + + if test_case == 'compute_engine_creds': + cmdline += [oauth_scope_arg, default_account_arg] + + return (cmdline, env) + + +def cloud_to_prod_jobspec(language, test_case, docker_image=None, auth=False): """Creates jobspec for cloud-to-prod interop test""" - cmdline = bash_login_cmdline(language.cloud_to_prod_args() + - ['--test_case=%s' % test_case]) + cmdline = language.cloud_to_prod_args() + ['--test_case=%s' % test_case] cwd = language.client_cwd environ = language.cloud_to_prod_env() + if auth: + cmdline, environ = add_auth_options(language, test_case, cmdline, environ) + cmdline = bash_login_cmdline(cmdline) + if docker_image: cmdline = docker_run_cmdline(cmdline, image=docker_image, cwd=cwd, environ=environ) cwd = None environ = None + suite_name='cloud_to_prod_auth' if auth else 'cloud_to_prod' test_job = jobset.JobSpec( cmdline=cmdline, cwd=cwd, environ=environ, - shortname="cloud_to_prod:%s:%s" % (language, test_case), + shortname="%s:%s:%s" % (suite_name, language, test_case), timeout_seconds=2*60, flake_retries=5 if args.allow_flakes else 0, timeout_retries=2 if args.allow_flakes else 0) @@ -382,6 +416,11 @@ argp.add_argument('--cloud_to_prod', action='store_const', const=True, help='Run cloud_to_prod tests.') +argp.add_argument('--cloud_to_prod_auth', + default=False, + action='store_const', + const=True, + help='Run cloud_to_prod_auth tests.') argp.add_argument('-s', '--server', choices=['all'] + sorted(_SERVERS), action='append', @@ -476,6 +515,14 @@ try: docker_image=docker_images.get(str(language))) jobs.append(test_job) + if args.cloud_to_prod_auth: + for language in languages: + for test_case in _AUTH_TEST_CASES: + test_job = cloud_to_prod_jobspec(language, test_case, + docker_image=docker_images.get(str(language)), + auth=True) + jobs.append(test_job) + for server in args.override_server: server_name = server[0] (server_host, server_port) = server[1].split(':') diff --git a/tools/run_tests/run_node.sh b/tools/run_tests/run_node.sh index e322ab1995..780969089d 100755 --- a/tools/run_tests/run_node.sh +++ b/tools/run_tests/run_node.sh @@ -37,19 +37,15 @@ cd $(dirname $0)/../.. root=`pwd` -cd $root/src/node - -export LD_LIBRARY_PATH=$root/libs/$CONFIG - if [ "$CONFIG" = "gcov" ] then - ./node_modules/.bin/istanbul cover --dir ../../reports/node_coverage \ - ./node_modules/.bin/_mocha -- --timeout 8000 + ./node_modules/.bin/istanbul cover --dir reports/node_coverage \ + ./node_modules/.bin/_mocha -- --timeout 8000 src/node/test cd build gcov Release/obj.target/grpc/ext/*.o lcov --base-directory . --directory . -c -o coverage.info - genhtml -o ../../../reports/node_ext_coverage --num-spaces 2 \ + genhtml -o ../reports/node_ext_coverage --num-spaces 2 \ -t 'Node gRPC test coverage' coverage.info else - ./node_modules/mocha/bin/mocha --timeout 8000 + ./node_modules/mocha/bin/mocha --timeout 8000 src/node/test fi diff --git a/tools/run_tests/run_python.sh b/tools/run_tests/run_python.sh index e2135be04c..848775e9b1 100755 --- a/tools/run_tests/run_python.sh +++ b/tools/run_tests/run_python.sh @@ -40,4 +40,4 @@ export DYLD_LIBRARY_PATH=$ROOT/libs/$CONFIG export PATH=$ROOT/bins/$CONFIG:$ROOT/bins/$CONFIG/protobuf:$PATH source "python"$PYVER"_virtual_environment"/bin/activate -"python"$PYVER $GRPCIO_TEST/setup.py test -a "-n8 --cov=grpc --junitxml=./report.xml --timeout=300" +"python"$PYVER $GRPCIO_TEST/setup.py test -a "-n8 --cov=grpc --junitxml=./report.xml --timeout=300 -v --boxed --timeout_method=thread" diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index e938520403..122102ea05 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -181,45 +181,6 @@ class CLanguage(object): def __str__(self): return self.make_target - -def gyp_test_paths(travis, config=None): - binaries = get_c_tests(travis, 'c') - out = [] - for target in binaries: - if config is not None and config.build_config in target['exclude_configs']: - continue - binary = 'out/Debug/%s' % target['name'] - out.append(binary) - return sorted(out) - - -class GYPCLanguage(object): - - def test_specs(self, config, travis): - return [config.job_spec([binary], [binary]) - for binary in gyp_test_paths(travis, config)] - - def pre_build_steps(self): - return [['gyp', '--depth=.', '--suffix=-gyp', 'grpc.gyp']] - - def make_targets(self): - # HACK(ctiller): force fling_client and fling_server to be built, as fling_test - # needs these - return gyp_test_paths(False) + ['fling_client', 'fling_server'] - - def build_steps(self): - return [] - - def makefile_name(self): - return 'Makefile-gyp' - - def supports_multi_config(self): - return False - - def __str__(self): - return 'gyp' - - class NodeLanguage(object): def test_specs(self, config, travis): @@ -230,7 +191,7 @@ class NodeLanguage(object): return [] def make_targets(self): - return ['static_c', 'shared_c'] + return [] def build_steps(self): return [['tools/run_tests/build_node.sh']] @@ -483,7 +444,6 @@ _DEFAULT = ['opt'] _LANGUAGES = { 'c++': CLanguage('cxx', 'c++'), 'c': CLanguage('c', 'c'), - 'gyp': GYPCLanguage(), 'node': NodeLanguage(), 'php': PhpLanguage(), 'python': PythonLanguage(), @@ -713,21 +673,24 @@ def _start_port_server(port_server_port): # if not running ==> start a new one # otherwise, leave it up try: - version = urllib2.urlopen('http://localhost:%d/version' % port_server_port, - timeout=1).read() - print 'detected port server running' + version = int(urllib2.urlopen( + 'http://localhost:%d/version_number' % port_server_port, + timeout=1).read()) + print 'detected port server running version %d' % version running = True - except Exception: + except Exception as e: print 'failed to detect port server: %s' % sys.exc_info()[0] + print e.strerror running = False if running: - with open('tools/run_tests/port_server.py') as f: - current_version = hashlib.sha1(f.read()).hexdigest() - running = (version == current_version) - if not running: - print 'port_server version mismatch: killing the old one' - urllib2.urlopen('http://localhost:%d/quit' % port_server_port).read() - time.sleep(1) + current_version = int(subprocess.check_output( + [sys.executable, 'tools/run_tests/port_server.py', 'dump_version'])) + print 'my port server is version %d' % current_version + running = (version >= current_version) + if not running: + print 'port_server version mismatch: killing the old one' + urllib2.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read() + time.sleep(1) if not running: print 'starting port_server' port_log = open('portlog.txt', 'w') @@ -773,7 +736,7 @@ def _build_and_run( # start antagonists antagonists = [subprocess.Popen(['tools/run_tests/antagonist.py']) for _ in range(0, args.antagonists)] - port_server_port = 9999 + port_server_port = 32767 _start_port_server(port_server_port) try: infinite_runs = runs_per_test == 0 |