From b9cb3379d541a5d7c43f3b4e999d2b4a87bca695 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Fri, 17 Nov 2017 10:40:39 -0800 Subject: [PATCH 1/8] Add bazel_toolchains --- WORKSPACE | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WORKSPACE b/WORKSPACE index cead0bc877b..43cf87e5a02 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -115,3 +115,13 @@ http_archive( strip_prefix = "abseil-cpp-cc4bed2d74f7c8717e31f9579214ab52a9c9c610", url = "https://github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz", ) + +http_archive( + name = "bazel_toolchains", + urls = [ + "http://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz", + "https://github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz", + ], + strip_prefix = "bazel-toolchains-af4681c3d19f063f090222ec3d04108c4e0ca255", + sha256 = "d58bb2d6c8603f600d522b6104d6192a65339aa26cbba9f11ff5c4b36dedb928", +) From 6c38fbe4be96e6071f23e86802f618af790d0459 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Fri, 17 Nov 2017 15:45:11 -0800 Subject: [PATCH 2/8] Experimental build script to use Foundry. --- .../linux/grpc_bazel_on_foundry.sh | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tools/internal_ci/linux/grpc_bazel_on_foundry.sh diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh new file mode 100644 index 00000000000..fc8727f5a0c --- /dev/null +++ b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -ex -o igncr || set -ex + +which bazel +chmod +x "${KOKORO_GFILE_DIR}/bazel_wrapper.py" + +# change to grpc repo root +cd $(dirname $0)/../../.. + +source tools/internal_ci/helper_scripts/prepare_build_linux_rc + +"${KOKORO_GFILE_DIR}/bazel_wrapper.py" \ + --host_jvm_args=-Dbazel.DigestFunction=SHA1 \ + test --jobs="50" \ + --test_timeout="300,450,1200,3600" \ + --test_output=errors \ + --verbose_failures=true \ + --keep_going \ + --remote_accept_cached=true \ + --spawn_strategy=remote \ + --remote_local_fallback=false \ + --remote_timeout=3600 \ + --strategy=Javac=remote \ + --strategy=Closure=remote \ + --genrule_strategy=remote \ + --experimental_strict_action_env=true \ + --experimental_remote_platform_override='properties:{ name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:b80da64e2a6f75af122bbb70021ebaab98b073f144ab04653c0de49bd943d8e9" }' \ + --crosstool_top=@bazel_toolchains//configs/debian8_clang/0.1.0/bazel_0.6.0:toolchain \ + -- //test/... From 020603d1cfd42e5c3fcecea028163ec372ed492d Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Tue, 21 Nov 2017 11:21:11 -0800 Subject: [PATCH 3/8] Use canary bazel --- tools/internal_ci/linux/grpc_bazel_on_foundry.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh index fc8727f5a0c..58055bb37a2 100644 --- a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh +++ b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh @@ -13,8 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -ex -o igncr || set -ex +set -ex +mkdir -p /tmpfs/tmp/bazel-canary +ln -f "${KOKORO_GFILE_DIR}/bazel-canary" /tmpfs/tmp/bazel-canary/bazel +chmod 755 "${KOKORO_GFILE_DIR}/bazel-canary" +export PATH="/tmpfs/tmp/bazel-canary:${PATH}" +# This should show /tmpfs/tmp/bazel-canary/bazel which bazel chmod +x "${KOKORO_GFILE_DIR}/bazel_wrapper.py" From 0384127aa8bb4a0f244826c434b623299157e891 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Tue, 21 Nov 2017 15:24:37 -0800 Subject: [PATCH 4/8] Copy key data --- WORKSPACE | 2 +- tools/internal_ci/linux/grpc_bazel_on_foundry.sh | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 43cf87e5a02..bf09aa7cc93 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -119,7 +119,7 @@ http_archive( http_archive( name = "bazel_toolchains", urls = [ - "http://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz", "https://github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz", ], strip_prefix = "bazel-toolchains-af4681c3d19f063f090222ec3d04108c4e0ca255", diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh index 58055bb37a2..3ad0fa6c6bf 100644 --- a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh +++ b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh @@ -15,6 +15,9 @@ set -ex +mkdir -p ${KOKORO_KEYSTORE_DIR} +cp ${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json ${KOKORO_KEYSTORE_DIR}/4321_grpc-testing-service + mkdir -p /tmpfs/tmp/bazel-canary ln -f "${KOKORO_GFILE_DIR}/bazel-canary" /tmpfs/tmp/bazel-canary/bazel chmod 755 "${KOKORO_GFILE_DIR}/bazel-canary" @@ -44,5 +47,5 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_rc --genrule_strategy=remote \ --experimental_strict_action_env=true \ --experimental_remote_platform_override='properties:{ name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:b80da64e2a6f75af122bbb70021ebaab98b073f144ab04653c0de49bd943d8e9" }' \ - --crosstool_top=@bazel_toolchains//configs/debian8_clang/0.1.0/bazel_0.6.0:toolchain \ - -- //test/... + --crosstool_top=@bazel_toolchains//configs/debian8_clang/0.2.0/bazel_0.7.0:toolchain \ + -- //test/core/iomgr/... From 379105d4f0a07cec0a708ce3b0ad9ed686d05457 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Tue, 28 Nov 2017 16:06:09 -0800 Subject: [PATCH 5/8] Update toolchain version. --- tools/internal_ci/linux/grpc_bazel_on_foundry.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh index 3ad0fa6c6bf..c45d43a386b 100644 --- a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh +++ b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh @@ -46,6 +46,6 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_rc --strategy=Closure=remote \ --genrule_strategy=remote \ --experimental_strict_action_env=true \ - --experimental_remote_platform_override='properties:{ name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:b80da64e2a6f75af122bbb70021ebaab98b073f144ab04653c0de49bd943d8e9" }' \ + --experimental_remote_platform_override='properties:{name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:aa20628a902f06a11a015caa94b0432eb60690de2d2525bd046b9eea046f5d8a" }' \ --crosstool_top=@bazel_toolchains//configs/debian8_clang/0.2.0/bazel_0.7.0:toolchain \ - -- //test/core/iomgr/... + -- //test/... From c8bf2da1e0f36fe3a6f271140153fad8e9df8dbd Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Wed, 29 Nov 2017 09:59:34 -0800 Subject: [PATCH 6/8] Enabling hermetic testing for running tests on Foundry. --- CMakeLists.txt | 2 + Makefile | 2 + bazel/grpc_build_system.bzl | 4 +- build.yaml | 1 + grpc.gyp | 2 + test/core/util/BUILD | 4 ++ test/core/util/port_hermetic.cc | 41 +++++++++++++++++++ test/core/util/test_config.h | 2 +- third_party/zlib.BUILD | 2 +- .../generated/sources_and_headers.json | 3 +- 10 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 test/core/util/port_hermetic.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 760e4fa5852..3bb627aa7de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1622,6 +1622,7 @@ add_library(grpc_test_util test/core/util/parse_hexstring.cc test/core/util/passthru_endpoint.cc test/core/util/port.cc + test/core/util/port_hermetic.cc test/core/util/port_server_client.cc test/core/util/slice_splitter.cc test/core/util/tracer_util.cc @@ -1890,6 +1891,7 @@ add_library(grpc_test_util_unsecure test/core/util/parse_hexstring.cc test/core/util/passthru_endpoint.cc test/core/util/port.cc + test/core/util/port_hermetic.cc test/core/util/port_server_client.cc test/core/util/slice_splitter.cc test/core/util/tracer_util.cc diff --git a/Makefile b/Makefile index 3ce30059241..f5106cb2654 100644 --- a/Makefile +++ b/Makefile @@ -3628,6 +3628,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/parse_hexstring.cc \ test/core/util/passthru_endpoint.cc \ test/core/util/port.cc \ + test/core/util/port_hermetic.cc \ test/core/util/port_server_client.cc \ test/core/util/slice_splitter.cc \ test/core/util/tracer_util.cc \ @@ -3887,6 +3888,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/util/parse_hexstring.cc \ test/core/util/passthru_endpoint.cc \ test/core/util/port.cc \ + test/core/util/port_hermetic.cc \ test/core/util/port_server_client.cc \ test/core/util/slice_splitter.cc \ test/core/util/tracer_util.cc \ diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index b35ca73745f..591fdb5936a 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -26,7 +26,7 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language = "C++", testonly = False, visibility = None, - alwayslink = 0): + alwayslink = 0, defines = []): copts = [] if language.upper() == "C": copts = ["-std=c99"] @@ -35,7 +35,7 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], srcs = srcs, defines = select({ "//:grpc_no_ares": ["GRPC_ARES=0"], - "//conditions:default": [], + "//conditions:default": defines, }), hdrs = hdrs + public_hdrs, deps = deps + ["//external:" + dep for dep in external_deps], diff --git a/build.yaml b/build.yaml index 0908f7efd23..0f6ac5631c5 100644 --- a/build.yaml +++ b/build.yaml @@ -736,6 +736,7 @@ filegroups: - test/core/util/parse_hexstring.cc - test/core/util/passthru_endpoint.cc - test/core/util/port.cc + - test/core/util/port_hermetic.cc - test/core/util/port_server_client.cc - test/core/util/slice_splitter.cc - test/core/util/tracer_util.cc diff --git a/grpc.gyp b/grpc.gyp index f2033b47b0b..7e6a06c8761 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -511,6 +511,7 @@ 'test/core/util/parse_hexstring.cc', 'test/core/util/passthru_endpoint.cc', 'test/core/util/port.cc', + 'test/core/util/port_hermetic.cc', 'test/core/util/port_server_client.cc', 'test/core/util/slice_splitter.cc', 'test/core/util/tracer_util.cc', @@ -721,6 +722,7 @@ 'test/core/util/parse_hexstring.cc', 'test/core/util/passthru_endpoint.cc', 'test/core/util/port.cc', + 'test/core/util/port_hermetic.cc', 'test/core/util/port_server_client.cc', 'test/core/util/slice_splitter.cc', 'test/core/util/tracer_util.cc', diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 6443553466f..9884e04627a 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -53,6 +53,7 @@ grpc_cc_library( "parse_hexstring.cc", "passthru_endpoint.cc", "port.cc", + "port_hermetic.cc", "port_server_client.cc", "reconnect_server.cc", "slice_splitter.cc", @@ -73,6 +74,9 @@ grpc_cc_library( "tracer_util.h", "trickle_endpoint.h", ], + defines = [ + "GRPC_HERMETIC_TESTS=1", + ], language = "C++", deps = [ ":gpr_test_util", diff --git a/test/core/util/port_hermetic.cc b/test/core/util/port_hermetic.cc new file mode 100644 index 00000000000..36508167637 --- /dev/null +++ b/test/core/util/port_hermetic.cc @@ -0,0 +1,41 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "src/core/lib/iomgr/port.h" +#include "test/core/util/test_config.h" +#if defined(GRPC_HERMETIC_TESTS) + +#include "test/core/util/port.h" + +#define LOWER_PORT 49152 +static int s_allocated_port = LOWER_PORT; + +int grpc_pick_unused_port_or_die(void) { + int allocated_port = s_allocated_port++; + if (s_allocated_port == 65536) { + s_allocated_port = LOWER_PORT; + } + + return allocated_port; +} + +void grpc_recycle_unused_port(int port) { + (void) port; +} + +#endif /* GRPC_HERMETIC_TESTS */ diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 775ffac9497..ee60441653a 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -33,7 +33,7 @@ gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s); /* Converts a given timeout (in milliseconds) to a deadline. */ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms); -#ifndef GRPC_TEST_CUSTOM_PICK_PORT +#if !defined(GRPC_TEST_CUSTOM_PICK_PORT) && !defined(GRPC_HERMETIC_TESTS) #define GRPC_TEST_PICK_PORT #endif diff --git a/third_party/zlib.BUILD b/third_party/zlib.BUILD index 7879a81c680..a71c85fa98d 100644 --- a/third_party/zlib.BUILD +++ b/third_party/zlib.BUILD @@ -27,7 +27,7 @@ cc_library( "zutil.h", ], includes = [ - "include", + ".", ], linkstatic = 1, visibility = [ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c868acf8d30..c957638181f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8932,7 +8932,8 @@ "test/core/util/mock_endpoint.h", "test/core/util/parse_hexstring.h", "test/core/util/passthru_endpoint.h", - "test/core/util/port.h", + "test/core/util/port.h", + "test/core/util/port_hermetic.cc", "test/core/util/port_server_client.h", "test/core/util/slice_splitter.h", "test/core/util/tracer_util.h", From e5df91f477a27ce71a39bca928677b2f08649615 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Wed, 29 Nov 2017 14:37:18 -0800 Subject: [PATCH 7/8] Use select to decide the test is hermetic or not --- BUILD | 5 +++++ bazel/grpc_build_system.bzl | 10 +++++----- test/core/util/BUILD | 3 --- test/core/util/port_hermetic.cc | 4 ++++ tools/internal_ci/linux/grpc_bazel_on_foundry.sh | 1 + 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/BUILD b/BUILD index 30b410a2bd1..d997dc253c4 100644 --- a/BUILD +++ b/BUILD @@ -38,6 +38,11 @@ config_setting( values = {"define": "grpc_no_ares=true"}, ) +config_setting( + name = "remote_execution", + values = {"define": "GRPC_HERMETIC_TESTS=1"}, +) + # This should be updated along with build.yaml g_stands_for = "generous" diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 591fdb5936a..a6da3772481 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -26,17 +26,17 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language = "C++", testonly = False, visibility = None, - alwayslink = 0, defines = []): + alwayslink = 0): copts = [] if language.upper() == "C": copts = ["-std=c99"] native.cc_library( name = name, srcs = srcs, - defines = select({ - "//:grpc_no_ares": ["GRPC_ARES=0"], - "//conditions:default": defines, - }), + defines = select({"//:grpc_no_ares": ["GRPC_ARES=0"], + "//conditions:default": [],}) + + select({"//:remote_execution": ["GRPC_HERMETIC_TESTS=1"], + "//conditions:default": [],}), hdrs = hdrs + public_hdrs, deps = deps + ["//external:" + dep for dep in external_deps], copts = copts, diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 9884e04627a..f92c0ff5489 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -74,9 +74,6 @@ grpc_cc_library( "tracer_util.h", "trickle_endpoint.h", ], - defines = [ - "GRPC_HERMETIC_TESTS=1", - ], language = "C++", deps = [ ":gpr_test_util", diff --git a/test/core/util/port_hermetic.cc b/test/core/util/port_hermetic.cc index 36508167637..b4d097f650d 100644 --- a/test/core/util/port_hermetic.cc +++ b/test/core/util/port_hermetic.cc @@ -16,6 +16,10 @@ * */ +/* When running tests hermeticly, i.e. running on remote machines, + * the framework takes a round-robin pick of a port within certain range. + * There is no need to recycle ports. + */ #include "src/core/lib/iomgr/port.h" #include "test/core/util/test_config.h" #if defined(GRPC_HERMETIC_TESTS) diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh index c45d43a386b..dc6df47ac81 100644 --- a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh +++ b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh @@ -48,4 +48,5 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_rc --experimental_strict_action_env=true \ --experimental_remote_platform_override='properties:{name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:aa20628a902f06a11a015caa94b0432eb60690de2d2525bd046b9eea046f5d8a" }' \ --crosstool_top=@bazel_toolchains//configs/debian8_clang/0.2.0/bazel_0.7.0:toolchain \ + --define GRPC_HERMETIC_TESTS=1 \ -- //test/... From 5b7cdefb681977357573d9eac866520610d19fa5 Mon Sep 17 00:00:00 2001 From: Adele Zhou Date: Wed, 29 Nov 2017 16:25:17 -0800 Subject: [PATCH 8/8] Rename port_hermetic to port_isolated_runtime_environment --- BUILD | 2 +- CMakeLists.txt | 4 ++-- Makefile | 4 ++-- bazel/grpc_build_system.bzl | 2 +- build.yaml | 2 +- grpc.gyp | 4 ++-- test/core/util/BUILD | 2 +- ...etic.cc => port_isolated_runtime_environment.cc} | 13 +++++-------- test/core/util/test_config.h | 2 +- tools/internal_ci/linux/grpc_bazel_on_foundry.sh | 5 ++++- tools/run_tests/generated/sources_and_headers.json | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) rename test/core/util/{port_hermetic.cc => port_isolated_runtime_environment.cc} (76%) diff --git a/BUILD b/BUILD index d997dc253c4..2dd8db06994 100644 --- a/BUILD +++ b/BUILD @@ -40,7 +40,7 @@ config_setting( config_setting( name = "remote_execution", - values = {"define": "GRPC_HERMETIC_TESTS=1"}, + values = {"define": "GRPC_PORT_ISOLATED_RUNTIME=1"}, ) # This should be updated along with build.yaml diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bb627aa7de..975c2975050 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1622,7 +1622,7 @@ add_library(grpc_test_util test/core/util/parse_hexstring.cc test/core/util/passthru_endpoint.cc test/core/util/port.cc - test/core/util/port_hermetic.cc + test/core/util/port_isolated_runtime_environment.cc test/core/util/port_server_client.cc test/core/util/slice_splitter.cc test/core/util/tracer_util.cc @@ -1891,7 +1891,7 @@ add_library(grpc_test_util_unsecure test/core/util/parse_hexstring.cc test/core/util/passthru_endpoint.cc test/core/util/port.cc - test/core/util/port_hermetic.cc + test/core/util/port_isolated_runtime_environment.cc test/core/util/port_server_client.cc test/core/util/slice_splitter.cc test/core/util/tracer_util.cc diff --git a/Makefile b/Makefile index f5106cb2654..6b8116dda91 100644 --- a/Makefile +++ b/Makefile @@ -3628,7 +3628,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/parse_hexstring.cc \ test/core/util/passthru_endpoint.cc \ test/core/util/port.cc \ - test/core/util/port_hermetic.cc \ + test/core/util/port_isolated_runtime_environment.cc \ test/core/util/port_server_client.cc \ test/core/util/slice_splitter.cc \ test/core/util/tracer_util.cc \ @@ -3888,7 +3888,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/util/parse_hexstring.cc \ test/core/util/passthru_endpoint.cc \ test/core/util/port.cc \ - test/core/util/port_hermetic.cc \ + test/core/util/port_isolated_runtime_environment.cc \ test/core/util/port_server_client.cc \ test/core/util/slice_splitter.cc \ test/core/util/tracer_util.cc \ diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index a6da3772481..2ee8c297da1 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -35,7 +35,7 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], srcs = srcs, defines = select({"//:grpc_no_ares": ["GRPC_ARES=0"], "//conditions:default": [],}) + - select({"//:remote_execution": ["GRPC_HERMETIC_TESTS=1"], + select({"//:remote_execution": ["GRPC_PORT_ISOLATED_RUNTIME=1"], "//conditions:default": [],}), hdrs = hdrs + public_hdrs, deps = deps + ["//external:" + dep for dep in external_deps], diff --git a/build.yaml b/build.yaml index 0f6ac5631c5..df2975fcc20 100644 --- a/build.yaml +++ b/build.yaml @@ -736,7 +736,7 @@ filegroups: - test/core/util/parse_hexstring.cc - test/core/util/passthru_endpoint.cc - test/core/util/port.cc - - test/core/util/port_hermetic.cc + - test/core/util/port_isolated_runtime_environment.cc - test/core/util/port_server_client.cc - test/core/util/slice_splitter.cc - test/core/util/tracer_util.cc diff --git a/grpc.gyp b/grpc.gyp index 7e6a06c8761..b07696d3168 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -511,7 +511,7 @@ 'test/core/util/parse_hexstring.cc', 'test/core/util/passthru_endpoint.cc', 'test/core/util/port.cc', - 'test/core/util/port_hermetic.cc', + 'test/core/util/port_isolated_runtime_environment.cc', 'test/core/util/port_server_client.cc', 'test/core/util/slice_splitter.cc', 'test/core/util/tracer_util.cc', @@ -722,7 +722,7 @@ 'test/core/util/parse_hexstring.cc', 'test/core/util/passthru_endpoint.cc', 'test/core/util/port.cc', - 'test/core/util/port_hermetic.cc', + 'test/core/util/port_isolated_runtime_environment.cc', 'test/core/util/port_server_client.cc', 'test/core/util/slice_splitter.cc', 'test/core/util/tracer_util.cc', diff --git a/test/core/util/BUILD b/test/core/util/BUILD index f92c0ff5489..89e07c83c78 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -53,7 +53,7 @@ grpc_cc_library( "parse_hexstring.cc", "passthru_endpoint.cc", "port.cc", - "port_hermetic.cc", + "port_isolated_runtime_environment.cc", "port_server_client.cc", "reconnect_server.cc", "slice_splitter.cc", diff --git a/test/core/util/port_hermetic.cc b/test/core/util/port_isolated_runtime_environment.cc similarity index 76% rename from test/core/util/port_hermetic.cc rename to test/core/util/port_isolated_runtime_environment.cc index b4d097f650d..5f0585e9fb4 100644 --- a/test/core/util/port_hermetic.cc +++ b/test/core/util/port_isolated_runtime_environment.cc @@ -16,13 +16,12 @@ * */ -/* When running tests hermeticly, i.e. running on remote machines, - * the framework takes a round-robin pick of a port within certain range. - * There is no need to recycle ports. +/* When running tests on remote machines, the framework takes a round-robin pick + * of a port within certain range. There is no need to recycle ports. */ #include "src/core/lib/iomgr/port.h" #include "test/core/util/test_config.h" -#if defined(GRPC_HERMETIC_TESTS) +#if defined(GRPC_PORT_ISOLATED_RUNTIME) #include "test/core/util/port.h" @@ -38,8 +37,6 @@ int grpc_pick_unused_port_or_die(void) { return allocated_port; } -void grpc_recycle_unused_port(int port) { - (void) port; -} +void grpc_recycle_unused_port(int port) { (void)port; } -#endif /* GRPC_HERMETIC_TESTS */ +#endif /* GRPC_PORT_ISOLATED_RUNTIME */ diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index ee60441653a..5b3d34799ee 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -33,7 +33,7 @@ gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s); /* Converts a given timeout (in milliseconds) to a deadline. */ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms); -#if !defined(GRPC_TEST_CUSTOM_PICK_PORT) && !defined(GRPC_HERMETIC_TESTS) +#if !defined(GRPC_TEST_CUSTOM_PICK_PORT) && !defined(GRPC_PORT_ISOLATED_RUNTIME) #define GRPC_TEST_PICK_PORT #endif diff --git a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh index dc6df47ac81..e328be8aaba 100644 --- a/tools/internal_ci/linux/grpc_bazel_on_foundry.sh +++ b/tools/internal_ci/linux/grpc_bazel_on_foundry.sh @@ -15,6 +15,9 @@ set -ex +# A temporary solution to give Kokoro credentials. +# The file name 4321_grpc-testing-service needs to match auth_credential in +# the build config. mkdir -p ${KOKORO_KEYSTORE_DIR} cp ${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json ${KOKORO_KEYSTORE_DIR}/4321_grpc-testing-service @@ -48,5 +51,5 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_rc --experimental_strict_action_env=true \ --experimental_remote_platform_override='properties:{name:"container-image" value:"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:aa20628a902f06a11a015caa94b0432eb60690de2d2525bd046b9eea046f5d8a" }' \ --crosstool_top=@bazel_toolchains//configs/debian8_clang/0.2.0/bazel_0.7.0:toolchain \ - --define GRPC_HERMETIC_TESTS=1 \ + --define GRPC_PORT_ISOLATED_RUNTIME=1 \ -- //test/... diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c957638181f..025077449fc 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8932,8 +8932,7 @@ "test/core/util/mock_endpoint.h", "test/core/util/parse_hexstring.h", "test/core/util/passthru_endpoint.h", - "test/core/util/port.h", - "test/core/util/port_hermetic.cc", + "test/core/util/port.h", "test/core/util/port_server_client.h", "test/core/util/slice_splitter.h", "test/core/util/tracer_util.h", @@ -8967,6 +8966,7 @@ "test/core/util/passthru_endpoint.h", "test/core/util/port.cc", "test/core/util/port.h", + "test/core/util/port_isolated_runtime_environment.cc", "test/core/util/port_server_client.cc", "test/core/util/port_server_client.h", "test/core/util/slice_splitter.cc",