diff --git a/tools/jenkins/grpc_artifact_linux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile similarity index 100% rename from tools/jenkins/grpc_artifact_linux_x64/Dockerfile rename to tools/dockerfile/grpc_artifact_linux_x64/Dockerfile diff --git a/tools/jenkins/grpc_artifact_linux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile similarity index 100% rename from tools/jenkins/grpc_artifact_linux_x86/Dockerfile rename to tools/dockerfile/grpc_artifact_linux_x86/Dockerfile diff --git a/tools/jenkins/grpc_interop_csharp/Dockerfile b/tools/dockerfile/grpc_interop_csharp/Dockerfile similarity index 98% rename from tools/jenkins/grpc_interop_csharp/Dockerfile rename to tools/dockerfile/grpc_interop_csharp/Dockerfile index 3789cd32038..c3c79487f7a 100644 --- a/tools/jenkins/grpc_interop_csharp/Dockerfile +++ b/tools/dockerfile/grpc_interop_csharp/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_csharp/build_interop.sh b/tools/dockerfile/grpc_interop_csharp/build_interop.sh similarity index 100% rename from tools/jenkins/grpc_interop_csharp/build_interop.sh rename to tools/dockerfile/grpc_interop_csharp/build_interop.sh diff --git a/tools/jenkins/grpc_interop_stress_cxx/Dockerfile b/tools/dockerfile/grpc_interop_cxx/Dockerfile similarity index 100% rename from tools/jenkins/grpc_interop_stress_cxx/Dockerfile rename to tools/dockerfile/grpc_interop_cxx/Dockerfile diff --git a/tools/jenkins/grpc_interop_cxx/build_interop.sh b/tools/dockerfile/grpc_interop_cxx/build_interop.sh similarity index 98% rename from tools/jenkins/grpc_interop_cxx/build_interop.sh rename to tools/dockerfile/grpc_interop_cxx/build_interop.sh index 1c0828d23a6..903c31b3e78 100755 --- a/tools/jenkins/grpc_interop_cxx/build_interop.sh +++ b/tools/dockerfile/grpc_interop_cxx/build_interop.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_http2/Dockerfile b/tools/dockerfile/grpc_interop_go/Dockerfile similarity index 97% rename from tools/jenkins/grpc_interop_http2/Dockerfile rename to tools/dockerfile/grpc_interop_go/Dockerfile index bb60f09f247..f83e18c8a31 100644 --- a/tools/jenkins/grpc_interop_http2/Dockerfile +++ b/tools/dockerfile/grpc_interop_go/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_go/build_interop.sh b/tools/dockerfile/grpc_interop_go/build_interop.sh similarity index 98% rename from tools/jenkins/grpc_interop_go/build_interop.sh rename to tools/dockerfile/grpc_interop_go/build_interop.sh index e8915493422..224b0040c04 100755 --- a/tools/jenkins/grpc_interop_go/build_interop.sh +++ b/tools/dockerfile/grpc_interop_go/build_interop.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_go/Dockerfile b/tools/dockerfile/grpc_interop_http2/Dockerfile similarity index 97% rename from tools/jenkins/grpc_interop_go/Dockerfile rename to tools/dockerfile/grpc_interop_http2/Dockerfile index bb60f09f247..f83e18c8a31 100644 --- a/tools/jenkins/grpc_interop_go/Dockerfile +++ b/tools/dockerfile/grpc_interop_http2/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_http2/build_interop.sh b/tools/dockerfile/grpc_interop_http2/build_interop.sh similarity index 98% rename from tools/jenkins/grpc_interop_http2/build_interop.sh rename to tools/dockerfile/grpc_interop_http2/build_interop.sh index 46ddaf929a8..5f701e34c0d 100755 --- a/tools/jenkins/grpc_interop_http2/build_interop.sh +++ b/tools/dockerfile/grpc_interop_http2/build_interop.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_java/Dockerfile b/tools/dockerfile/grpc_interop_java/Dockerfile similarity index 98% rename from tools/jenkins/grpc_interop_java/Dockerfile rename to tools/dockerfile/grpc_interop_java/Dockerfile index 1ec24a95e38..5ba53246319 100644 --- a/tools/jenkins/grpc_interop_java/Dockerfile +++ b/tools/dockerfile/grpc_interop_java/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_java/build_interop.sh b/tools/dockerfile/grpc_interop_java/build_interop.sh similarity index 98% rename from tools/jenkins/grpc_interop_java/build_interop.sh rename to tools/dockerfile/grpc_interop_java/build_interop.sh index 9997c63308b..9c9591abd87 100755 --- a/tools/jenkins/grpc_interop_java/build_interop.sh +++ b/tools/dockerfile/grpc_interop_java/build_interop.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_node/Dockerfile b/tools/dockerfile/grpc_interop_node/Dockerfile similarity index 98% rename from tools/jenkins/grpc_interop_node/Dockerfile rename to tools/dockerfile/grpc_interop_node/Dockerfile index db5aff844de..3f0f918ad9e 100644 --- a/tools/jenkins/grpc_interop_node/Dockerfile +++ b/tools/dockerfile/grpc_interop_node/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_node/build_interop.sh b/tools/dockerfile/grpc_interop_node/build_interop.sh similarity index 100% rename from tools/jenkins/grpc_interop_node/build_interop.sh rename to tools/dockerfile/grpc_interop_node/build_interop.sh diff --git a/tools/jenkins/grpc_interop_php/Dockerfile b/tools/dockerfile/grpc_interop_php/Dockerfile similarity index 99% rename from tools/jenkins/grpc_interop_php/Dockerfile rename to tools/dockerfile/grpc_interop_php/Dockerfile index cf3e79176a5..4f5b3fcb777 100644 --- a/tools/jenkins/grpc_interop_php/Dockerfile +++ b/tools/dockerfile/grpc_interop_php/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_php/build_interop.sh b/tools/dockerfile/grpc_interop_php/build_interop.sh similarity index 98% rename from tools/jenkins/grpc_interop_php/build_interop.sh rename to tools/dockerfile/grpc_interop_php/build_interop.sh index 87262f1d629..2bffbd89384 100755 --- a/tools/jenkins/grpc_interop_php/build_interop.sh +++ b/tools/dockerfile/grpc_interop_php/build_interop.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_python/Dockerfile b/tools/dockerfile/grpc_interop_python/Dockerfile similarity index 98% rename from tools/jenkins/grpc_interop_python/Dockerfile rename to tools/dockerfile/grpc_interop_python/Dockerfile index 047604b1b79..ef4432d2604 100644 --- a/tools/jenkins/grpc_interop_python/Dockerfile +++ b/tools/dockerfile/grpc_interop_python/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_python/build_interop.sh b/tools/dockerfile/grpc_interop_python/build_interop.sh similarity index 98% rename from tools/jenkins/grpc_interop_python/build_interop.sh rename to tools/dockerfile/grpc_interop_python/build_interop.sh index 39c93677d8b..203b012aed4 100755 --- a/tools/jenkins/grpc_interop_python/build_interop.sh +++ b/tools/dockerfile/grpc_interop_python/build_interop.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_ruby/Dockerfile b/tools/dockerfile/grpc_interop_ruby/Dockerfile similarity index 98% rename from tools/jenkins/grpc_interop_ruby/Dockerfile rename to tools/dockerfile/grpc_interop_ruby/Dockerfile index ff201fa291e..b3383afe79e 100644 --- a/tools/jenkins/grpc_interop_ruby/Dockerfile +++ b/tools/dockerfile/grpc_interop_ruby/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_ruby/build_interop.sh b/tools/dockerfile/grpc_interop_ruby/build_interop.sh similarity index 98% rename from tools/jenkins/grpc_interop_ruby/build_interop.sh rename to tools/dockerfile/grpc_interop_ruby/build_interop.sh index c5023f5c1d4..04288bf1aaf 100755 --- a/tools/jenkins/grpc_interop_ruby/build_interop.sh +++ b/tools/dockerfile/grpc_interop_ruby/build_interop.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_cxx/Dockerfile b/tools/dockerfile/grpc_interop_stress_cxx/Dockerfile similarity index 98% rename from tools/jenkins/grpc_interop_cxx/Dockerfile rename to tools/dockerfile/grpc_interop_stress_cxx/Dockerfile index 1fa19075330..58a8c32e344 100644 --- a/tools/jenkins/grpc_interop_cxx/Dockerfile +++ b/tools/dockerfile/grpc_interop_stress_cxx/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/grpc_interop_stress_cxx/build_interop_stress.sh b/tools/dockerfile/grpc_interop_stress_cxx/build_interop_stress.sh similarity index 100% rename from tools/jenkins/grpc_interop_stress_cxx/build_interop_stress.sh rename to tools/dockerfile/grpc_interop_stress_cxx/build_interop_stress.sh diff --git a/tools/jenkins/grpc_jenkins_slave/Dockerfile b/tools/dockerfile/grpc_jenkins_slave_x64/Dockerfile similarity index 100% rename from tools/jenkins/grpc_jenkins_slave/Dockerfile rename to tools/dockerfile/grpc_jenkins_slave_x64/Dockerfile diff --git a/tools/jenkins/grpc_jenkins_slave_32bits/Dockerfile b/tools/dockerfile/grpc_jenkins_slave_x86/Dockerfile similarity index 100% rename from tools/jenkins/grpc_jenkins_slave_32bits/Dockerfile rename to tools/dockerfile/grpc_jenkins_slave_x86/Dockerfile diff --git a/tools/jenkins/grpc_linuxbrew/Dockerfile b/tools/dockerfile/grpc_linuxbrew/Dockerfile similarity index 98% rename from tools/jenkins/grpc_linuxbrew/Dockerfile rename to tools/dockerfile/grpc_linuxbrew/Dockerfile index 848489e091c..8c179da6c86 100644 --- a/tools/jenkins/grpc_linuxbrew/Dockerfile +++ b/tools/dockerfile/grpc_linuxbrew/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/tools/jenkins/build_docker_and_run_tests.sh b/tools/jenkins/build_docker_and_run_tests.sh index 562cfcb6a6e..58163bb5835 100755 --- a/tools/jenkins/build_docker_and_run_tests.sh +++ b/tools/jenkins/build_docker_and_run_tests.sh @@ -47,11 +47,15 @@ mkdir -p /tmp/xdg-cache-home # Create a local branch so the child Docker script won't complain git branch -f jenkins-docker -# Use image name based on Dockerfile checksum -DOCKER_IMAGE_NAME=grpc_jenkins_slave${docker_suffix}_`sha1sum tools/jenkins/grpc_jenkins_slave/Dockerfile | cut -f1 -d\ ` +# Inputs +# DOCKERFILE_DIR - Directory in which Dockerfile file is located. +# DOCKER_RUN_SCRIPT - Script to run under docker (relative to grpc repo root) + +# Use image name based on Dockerfile location checksum +DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ ) # Make sure docker image has been built. Should be instantaneous if so. -docker build -t $DOCKER_IMAGE_NAME tools/jenkins/grpc_jenkins_slave$docker_suffix +docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR # Choose random name for docker container CONTAINER_NAME="run_tests_$(uuidgen)" @@ -76,7 +80,7 @@ docker run \ -w /var/local/git/grpc \ --name=$CONTAINER_NAME \ $DOCKER_IMAGE_NAME \ - bash -l /var/local/jenkins/grpc/tools/jenkins/docker_run_tests.sh || DOCKER_FAILED="true" + bash -l "/var/local/jenkins/grpc/$DOCKER_RUN_SCRIPT" || DOCKER_FAILED="true" if [ "$XML_REPORT" != "" ] then diff --git a/tools/jenkins/build_interop_image.sh b/tools/jenkins/build_interop_image.sh index 73937068a4f..28d5f31d4f2 100755 --- a/tools/jenkins/build_interop_image.sh +++ b/tools/jenkins/build_interop_image.sh @@ -71,10 +71,10 @@ then fi # Use image name based on Dockerfile checksum -BASE_IMAGE=${BASE_NAME}_base:`sha1sum tools/jenkins/$BASE_NAME/Dockerfile | cut -f1 -d\ ` +BASE_IMAGE=${BASE_NAME}_base:`sha1sum tools/dockerfile/$BASE_NAME/Dockerfile | cut -f1 -d\ ` # Make sure base docker image has been built. Should be instantaneous if so. -docker build -t $BASE_IMAGE --force-rm=true tools/jenkins/$BASE_NAME || exit $? +docker build -t $BASE_IMAGE --force-rm=true tools/dockerfile/$BASE_NAME || exit $? # Create a local branch so the child Docker script won't complain git branch -f jenkins-docker @@ -92,7 +92,7 @@ CONTAINER_NAME="build_${BASE_NAME}_$(uuidgen)" -v /tmp/ccache:/tmp/ccache \ --name=$CONTAINER_NAME \ $BASE_IMAGE \ - bash -l /var/local/jenkins/grpc/tools/jenkins/$BASE_NAME/build_interop.sh \ + bash -l /var/local/jenkins/grpc/tools/dockerfile/$BASE_NAME/build_interop.sh \ && docker commit $CONTAINER_NAME $INTEROP_IMAGE \ && echo "Successfully built image $INTEROP_IMAGE") EXITCODE=$? diff --git a/tools/jenkins/build_interop_stress_image.sh b/tools/jenkins/build_interop_stress_image.sh index 395eaa32d9b..92f2dab5e34 100755 --- a/tools/jenkins/build_interop_stress_image.sh +++ b/tools/jenkins/build_interop_stress_image.sh @@ -55,10 +55,10 @@ then fi # Use image name based on Dockerfile checksum -BASE_IMAGE=${BASE_NAME}_base:`sha1sum tools/jenkins/$BASE_NAME/Dockerfile | cut -f1 -d\ ` +BASE_IMAGE=${BASE_NAME}_base:`sha1sum tools/dockerfile/$BASE_NAME/Dockerfile | cut -f1 -d\ ` # Make sure base docker image has been built. Should be instantaneous if so. -docker build -t $BASE_IMAGE --force-rm=true tools/jenkins/$BASE_NAME || exit $? +docker build -t $BASE_IMAGE --force-rm=true tools/dockerfile/$BASE_NAME || exit $? # Create a local branch so the child Docker script won't complain git branch -f jenkins-docker @@ -75,7 +75,7 @@ CONTAINER_NAME="build_${BASE_NAME}_$(uuidgen)" -v /tmp/ccache:/tmp/ccache \ --name=$CONTAINER_NAME \ $BASE_IMAGE \ - bash -l /var/local/jenkins/grpc/tools/jenkins/$BASE_NAME/build_interop_stress.sh \ + bash -l /var/local/jenkins/grpc/tools/dockerfile/$BASE_NAME/build_interop_stress.sh \ && docker commit $CONTAINER_NAME $INTEROP_IMAGE \ && echo "Successfully built image $INTEROP_IMAGE") EXITCODE=$? diff --git a/tools/jenkins/run_distribution.sh b/tools/jenkins/run_distribution.sh index 64c60f15027..446ce16703e 100755 --- a/tools/jenkins/run_distribution.sh +++ b/tools/jenkins/run_distribution.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -47,11 +47,11 @@ if [ "$platform" == "linux" ]; then if [ "$dist_channel" == "homebrew" ]; then - sha1=$(sha1sum tools/jenkins/grpc_linuxbrew/Dockerfile | cut -f1 -d\ ) + sha1=$(sha1sum tools/dockerfile/grpc_linuxbrew/Dockerfile | cut -f1 -d\ ) DOCKER_IMAGE_NAME=grpc_linuxbrew_$sha1 # build docker image, contains all pre-requisites - docker build -t $DOCKER_IMAGE_NAME tools/jenkins/grpc_linuxbrew + docker build -t $DOCKER_IMAGE_NAME tools/dockerfile/grpc_linuxbrew # run per-language homebrew installation script docker run --rm=true $DOCKER_IMAGE_NAME bash -l \ diff --git a/tools/jenkins/run_jenkins.sh b/tools/jenkins/run_jenkins.sh index 49b2fa55c2d..123b252719a 100755 --- a/tools/jenkins/run_jenkins.sh +++ b/tools/jenkins/run_jenkins.sh @@ -39,51 +39,17 @@ # NOTE: No empty lines should appear in this file before igncr is set! set -ex -o igncr || set -ex -# Grabbing the machine's architecture -arch=`uname -m` - -case $platform in - i386) - arch="i386" - platform="linux" - docker_suffix=_32bits - ;; -esac - if [ "$platform" == "linux" ] then - echo "building $language on Linux" - - ./tools/run_tests/run_tests.py --use_docker -t -l $language -c $config -x report.xml -j 3 $@ || TESTS_FAILED="true" - -elif [ "$platform" == "windows" ] -then - echo "building $language on Windows" - - # Prevent msbuild from picking up "platform" env variable, which would break the build - unset platform - - python tools/run_tests/run_tests.py -t -l $language -c $config -x report.xml -j 3 $@ || TESTS_FAILED="true" - -elif [ "$platform" == "macos" ] -then - echo "building $language on MacOS" - - # Prevent msbuild from picking up "platform" env variable, which would break the build - unset platform - - ./tools/run_tests/run_tests.py -t -l $language -c $config -x report.xml -j 3 $@ || TESTS_FAILED="true" - + USE_DOCKER_MAYBE="--use_docker" elif [ "$platform" == "freebsd" ] then - echo "building $language on FreeBSD" + export MAKE=gmake +fi - MAKE=gmake ./tools/run_tests/run_tests.py -t -l $language -c $config -x report.xml -j 3 $@ || TESTS_FAILED="true" +unset platform # variable named 'platform' breaks the windows build -else - echo "Unknown platform $platform" - exit 1 -fi +python tools/run_tests/run_tests.py $USE_DOCKER_MAYBE -t -l $language -c $config -x report.xml -j 3 $@ || TESTS_FAILED="true" if [ ! -e reports/index.html ] then diff --git a/tools/jenkins/run_portability.sh b/tools/jenkins/run_portability.sh index afce4ad7438..f76dbd3144c 100755 --- a/tools/jenkins/run_portability.sh +++ b/tools/jenkins/run_portability.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -52,8 +52,7 @@ maybe_build_only='--build_only' if [ "$curr_platform" == "windows" ] then - win_arch="windows_${curr_arch}" - python tools/run_tests/run_tests.py -t -l $language -c $config --arch ${win_arch} --compiler ${curr_compiler} ${maybe_build_only} -x report.xml $@ + python tools/run_tests/run_tests.py -t -l $language -c $config --arch ${curr_arch} --compiler ${curr_compiler} ${maybe_build_only} -x report.xml $@ else echo "Unsupported scenario." exit 1 diff --git a/tools/run_tests/build_artifacts.py b/tools/run_tests/build_artifacts.py index ff9dd4735ac..0337f1b3d77 100755 --- a/tools/run_tests/build_artifacts.py +++ b/tools/run_tests/build_artifacts.py @@ -135,7 +135,7 @@ class CSharpExtArtifact: 'EMBED_ZLIB': 'true'} if self.platform == 'linux': return create_docker_jobspec(self.name, - 'tools/jenkins/grpc_artifact_linux_%s' % self.arch, + 'tools/dockerfile/grpc_artifact_linux_%s' % self.arch, 'tools/run_tests/build_artifact_csharp.sh') else: environ.update(macos_arch_env(self.arch)) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 6ea274b31d7..488af3b4da7 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -538,15 +538,37 @@ _WINDOWS_CONFIG = { def _windows_arch_option(arch): """Returns msbuild cmdline option for selected architecture.""" - if arch == 'default' or arch == 'windows_x86': + if arch == 'default' or arch == 'x86': return '/p:Platform=Win32' - elif arch == 'windows_x64': + elif arch == 'x64': return '/p:Platform=x64' else: - print 'Architecture %s not supported on current platform.' % arch + print 'Architecture %s not supported.' % arch sys.exit(1) - + +def _check_arch_option(arch): + """Checks that architecture option is valid.""" + if platform_string() == 'windows': + _windows_arch_option(arch) + elif platform_string() == 'linux': + # On linux, we need to be running under docker with the right architecture. + runtime_arch = platform.architecture()[0] + if arch == 'default': + return + elif runtime_arch == '64bit' and arch == 'x64': + return + elif runtime_arch == '32bit' and arch == 'x86': + return + else: + print 'Architecture %s does not match current runtime architecture.' % arch + sys.exit(1) + else: + if args.arch != 'default': + print 'Architecture %s not supported on current platform.' % args.arch + sys.exit(1) + + def _windows_build_bat(compiler): """Returns name of build.bat for selected compiler.""" if compiler == 'default' or compiler == 'vs2013': @@ -558,8 +580,8 @@ def _windows_build_bat(compiler): else: print 'Compiler %s not supported.' % compiler sys.exit(1) - - + + def _windows_toolset_option(compiler): """Returns msbuild PlatformToolset for selected compiler.""" if compiler == 'default' or compiler == 'vs2013': @@ -571,7 +593,17 @@ def _windows_toolset_option(compiler): else: print 'Compiler %s not supported.' % compiler sys.exit(1) - + + +def _get_dockerfile_dir(arch): + """Returns dockerfile to use""" + if arch == 'default' or arch == 'x64': + return 'tools/dockerfile/grpc_jenkins_slave_x64' + elif arch == 'x86': + return 'tools/dockerfile/grpc_jenkins_slave_x86' + else: + print 'Architecture %s not supported with current settings.' % arch + sys.exit(1) def runs_per_test_type(arg_str): """Auxilary function to parse the "runs_per_test" flag. @@ -638,7 +670,7 @@ argp.add_argument('--allow_flakes', const=True, help='Allow flaky tests to show as passing (re-runs failed tests up to five times)') argp.add_argument('--arch', - choices=['default', 'windows_x86', 'windows_x64'], + choices=['default', 'x86', 'x64'], default='default', help='Selects architecture to target. For some platforms "default" is the only supported choice.') argp.add_argument('--compiler', @@ -662,36 +694,6 @@ args = argp.parse_args() jobset.measure_cpu_costs = args.measure_cpu_costs -if args.use_docker: - if not args.travis: - print 'Seen --use_docker flag, will run tests under docker.' - print - print 'IMPORTANT: The changes you are testing need to be locally committed' - print 'because only the committed changes in the current branch will be' - print 'copied to the docker environment.' - time.sleep(5) - - child_argv = [ arg for arg in sys.argv if not arg == '--use_docker' ] - run_tests_cmd = 'tools/run_tests/run_tests.py %s' % ' '.join(child_argv[1:]) - - # TODO(jtattermusch): revisit if we need special handling for arch here - # set arch command prefix in case we are working with different arch. - arch_env = os.getenv('arch') - if arch_env: - run_test_cmd = 'arch %s %s' % (arch_env, run_test_cmd) - - env = os.environ.copy() - env['RUN_TESTS_COMMAND'] = run_tests_cmd - if args.xml_report: - env['XML_REPORT'] = args.xml_report - if not args.travis: - env['TTY_FLAG'] = '-t' # enables Ctrl-C when not on Jenkins. - - subprocess.check_call(['tools/jenkins/build_docker_and_run_tests.sh'], - shell=True, - env=env) - sys.exit(0) - # update submodules if necessary need_to_regenerate_projects = False for spec in args.update_submodules: @@ -755,16 +757,44 @@ if any(language.make_options() for language in languages): else: language_make_options = next(iter(languages)).make_options() -if platform_string() != 'windows': - if args.arch != 'default': - print 'Architecture %s not supported on current platform.' % args.arch - sys.exit(1) - if args.compiler != 'default': +if len(languages) != 1 or len(build_configs) != 1: + print 'Multi-language and multi-config testing is not supported.' + sys.exit(1) + +if args.use_docker: + if not args.travis: + print 'Seen --use_docker flag, will run tests under docker.' + print + print 'IMPORTANT: The changes you are testing need to be locally committed' + print 'because only the committed changes in the current branch will be' + print 'copied to the docker environment.' + time.sleep(5) + + child_argv = [ arg for arg in sys.argv if not arg == '--use_docker' ] + run_tests_cmd = 'tools/run_tests/run_tests.py %s' % ' '.join(child_argv[1:]) + + env = os.environ.copy() + env['RUN_TESTS_COMMAND'] = run_tests_cmd + env['DOCKERFILE_DIR'] = _get_dockerfile_dir(args.arch) + env['DOCKER_RUN_SCRIPT'] = 'tools/jenkins/docker_run_tests.sh' + if args.xml_report: + env['XML_REPORT'] = args.xml_report + if not args.travis: + env['TTY_FLAG'] = '-t' # enables Ctrl-C when not on Jenkins. + + subprocess.check_call(['tools/jenkins/build_docker_and_run_tests.sh'], + shell=True, + env=env) + sys.exit(0) + +if platform_string() != 'windows' and args.compiler != 'default': print 'Compiler %s not supported on current platform.' % args.compiler sys.exit(1) -if platform_string() == 'windows': - def make_jobspec(cfg, targets, makefile='Makefile'): +_check_arch_option(args.arch) + +def make_jobspec(cfg, targets, makefile='Makefile'): + if platform_string() == 'windows': extra_args = [] # better do parallel compilation # empirically /m:2 gives the best performance/price and should prevent @@ -782,8 +812,7 @@ if platform_string() == 'windows': language_make_options, shell=True, timeout_seconds=None) for target in targets] -else: - def make_jobspec(cfg, targets, makefile='Makefile'): + else: if targets: return [jobset.JobSpec([os.getenv('MAKE', 'make'), '-f', makefile, @@ -796,6 +825,7 @@ else: timeout_seconds=None)] else: return [] + make_targets = {} for l in languages: makefile = l.makefile_name()