Skip to content

Commit e26c812

Browse files
authored
Cleanup & improve bazel-based test jobs running under docker. (grpc#29402)
* use EXTRA_DOCKER_ARGS in grpc_bazel_privileged_docker.sh * docker_propagate_env.list: propagate all variables needed by workspace_status_kokoro.sh * simplify bazel invocations in docker * use respawn script for grpc_bazel.sh * cleanup grpc_flaky_network test * cleanup grpc_binder_transport_apk job * cleanup grpc_feature_example_tests * additional cleanup & improvements
1 parent 1bf8414 commit e26c812

17 files changed

+90
-92
lines changed

tools/internal_ci/linux/arm64/grpc_bazel.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515

1616
set -ex
1717

18+
# avoid slow finalization after the script has exited.
19+
source $(dirname $0)/../../../../tools/internal_ci/helper_scripts/move_src_tree_and_respawn_itself_rc
20+
1821
# change to grpc repo root
1922
cd $(dirname $0)/../../../..
2023

2124
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
2225

2326
export DOCKERFILE_DIR=tools/dockerfile/test/bazel_arm64
24-
export DOCKER_RUN_SCRIPT=$BAZEL_SCRIPT
25-
exec tools/run_tests/dockerize/build_and_run_docker.sh
27+
exec tools/run_tests/dockerize/build_and_run_docker.sh "${BAZEL_SCRIPT}"

tools/internal_ci/linux/arm64/grpc_bazel_test_c_cpp.cfg

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
# Location of the continuous shell script in repository.
1818
build_file: "grpc/tools/internal_ci/linux/arm64/grpc_bazel.sh"
1919
timeout_mins: 120
20+
action {
21+
define_artifacts {
22+
regex: "**/*sponge_log.*"
23+
regex: "github/grpc/reports/**"
24+
}
25+
}
26+
2027
env_vars {
2128
key: "BAZEL_SCRIPT"
2229
value: "tools/internal_ci/linux/arm64/grpc_bazel_test_c_cpp_in_docker.sh"

tools/internal_ci/linux/arm64/grpc_bazel_test_c_cpp_in_docker.sh

-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515

1616
set -ex
1717

18-
mkdir -p /var/local/git
19-
git clone /var/local/jenkins/grpc /var/local/git/grpc
20-
(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
21-
&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
22-
${name}')
23-
cd /var/local/git/grpc
24-
2518
# tests require port server to be running
2619
python3 tools/run_tests/start_port_server.py
2720

tools/internal_ci/linux/grpc_bazel.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515

1616
set -ex
1717

18+
# avoid slow finalization after the script has exited.
19+
source $(dirname $0)/../../../tools/internal_ci/helper_scripts/move_src_tree_and_respawn_itself_rc
20+
1821
# change to grpc repo root
1922
cd $(dirname $0)/../../..
2023

2124
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
2225

2326
export DOCKERFILE_DIR=tools/dockerfile/test/bazel
24-
export DOCKER_RUN_SCRIPT=$BAZEL_SCRIPT
25-
exec tools/run_tests/dockerize/build_and_run_docker.sh
27+
exec tools/run_tests/dockerize/build_and_run_docker.sh "${BAZEL_SCRIPT}"

tools/internal_ci/linux/grpc_bazel_build.cfg

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
# Location of the continuous shell script in repository.
1818
build_file: "grpc/tools/internal_ci/linux/grpc_bazel.sh"
1919
timeout_mins: 60
20+
action {
21+
define_artifacts {
22+
regex: "**/*sponge_log.*"
23+
regex: "github/grpc/reports/**"
24+
}
25+
}
26+
2027
env_vars {
2128
key: "BAZEL_SCRIPT"
2229
value: "tools/internal_ci/linux/grpc_bazel_build_in_docker.sh"

tools/internal_ci/linux/grpc_bazel_build_in_docker.sh

+23-27
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,34 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
#
16-
# Test basic Bazel features
17-
#
18-
# NOTE: No empty lines should appear in this file before igncr is set!
19-
set -ex -o igncr || set -ex
20-
21-
mkdir -p /var/local/git
22-
git clone /var/local/jenkins/grpc /var/local/git/grpc
23-
(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
24-
&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
25-
${name}')
26-
cd /var/local/git/grpc
2715

2816
# Build all basic targets using the strict warning option which leverages the
2917
# clang compiler to check if sources can pass a set of warning options.
3018
# For now //examples/android/binder/ are excluded because it needs Android
3119
# SDK/NDK to be installed to build
32-
bazel build --define=use_strict_warning=true \
33-
-- \
34-
:all \
35-
//src/core/... \
36-
//src/compiler/... \
37-
//test/... \
38-
//examples/... \
39-
-//examples/android/binder/...
20+
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path bazel_build_with_strict_warnings
21+
bazel_build_with_strict_warnings/bazel_wrapper \
22+
--bazelrc=tools/remote_build/include/test_locally_with_resultstore_results.bazelrc \
23+
build \
24+
--define=use_strict_warning=true \
25+
-- \
26+
:all \
27+
//src/core/... \
28+
//src/compiler/... \
29+
//test/... \
30+
//examples/... \
31+
-//examples/android/binder/...
4032

4133
# TODO(veblush): Remove this test after migration to abseil-status is done.
42-
bazel build --define=use_strict_warning=true --define=use_abseil_status=true \
43-
-- \
44-
//src/core/... \
45-
//src/compiler/... \
46-
//test/...
34+
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path bazel_build_with_abseil_status
35+
bazel_build_with_abseil_status/bazel_wrapper \
36+
--bazelrc=tools/remote_build/include/test_locally_with_resultstore_results.bazelrc \
37+
build \
38+
--define=use_strict_warning=true --define=use_abseil_status=true \
39+
-- \
40+
//src/core/... \
41+
//src/compiler/... \
42+
//test/...
4743

4844
# TODO(jtattersmusch): Adding a build here for --define=grpc_no_xds is not ideal
4945
# and we should find a better place for this. Refer
@@ -56,6 +52,6 @@ EXIT_CODE=0
5652
bazel build //test/cpp/end2end/xds:xds_end2end_test --define=grpc_no_xds=true || EXIT_CODE=$?
5753
if [ $EXIT_CODE -eq 0 ]
5854
then
59-
echo "Building xds_end2end_test succeeded even with --define=grpc_no_xds=true"
60-
exit 1
55+
echo "Building xds_end2end_test succeeded even with --define=grpc_no_xds=true"
56+
exit 1
6157
fi

tools/internal_ci/linux/grpc_binder_transport_apk.cfg

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
# Location of the continuous shell script in repository.
1818
build_file: "grpc/tools/internal_ci/linux/grpc_binder_transport_apk.sh"
1919
timeout_mins: 60
20+
action {
21+
define_artifacts {
22+
regex: "**/*sponge_log.*"
23+
regex: "github/grpc/reports/**"
24+
}
25+
}
26+
2027
env_vars {
2128
key: "BAZEL_SCRIPT"
2229
value: "tools/internal_ci/linux/grpc_binder_transport_apk_build_in_docker.sh"

tools/internal_ci/linux/grpc_binder_transport_apk.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515

1616
set -ex
1717

18+
# avoid slow finalization after the script has exited.
19+
source $(dirname $0)/../../../tools/internal_ci/helper_scripts/move_src_tree_and_respawn_itself_rc
20+
1821
# change to grpc repo root
1922
cd $(dirname $0)/../../..
2023

2124
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
2225

2326
export DOCKERFILE_DIR=tools/dockerfile/test/binder_transport_apk
24-
export DOCKER_RUN_SCRIPT=$BAZEL_SCRIPT
25-
exec tools/run_tests/dockerize/build_and_run_docker.sh
27+
exec tools/run_tests/dockerize/build_and_run_docker.sh "${BAZEL_SCRIPT}"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
# Copyright 2021 gRPC authors.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,17 +13,7 @@
1213
# See the License for the specific language governing permissions and
1314
# limitations under the License.
1415

15-
#!/usr/bin/env bash
16-
#
17-
# NOTE: No empty lines should appear in this file before igncr is set!
18-
set -ex -o igncr || set -ex
19-
20-
mkdir -p /var/local/git
21-
git clone /var/local/jenkins/grpc /var/local/git/grpc
22-
(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
23-
&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
24-
${name}')
25-
cd /var/local/git/grpc
16+
set -ex
2617

2718
echo $ANDROID_HOME
2819
echo $ANDROID_NDK_HOME
@@ -32,13 +23,21 @@ echo $ANDROID_NDK_HOME
3223
# CPU are specified because gRPC does not build with 32bit NDK (which has socklen_t
3324
# defined as int due to an accident).
3425
# The python option is for disabling python2 enforcement when packing APK
35-
bazel build --define=use_strict_warning=true \
26+
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path bazel_binder_example_app
27+
bazel_binder_example_app/bazel_wrapper \
28+
--bazelrc=tools/remote_build/include/test_locally_with_resultstore_results.bazelrc \
29+
build \
30+
--define=use_strict_warning=true \
3631
--fat_apk_cpu=x86_64,arm64-v8a \
3732
--extra_toolchains=@rules_python//python:autodetecting_toolchain_nonstrict \
3833
//examples/android/binder/java/io/grpc/binder/cpp/exampleclient:app \
3934
//examples/android/binder/java/io/grpc/binder/cpp/exampleserver:app
4035

4136
# Make sure the Java code that will be invoked by binder transport
4237
# implementation builds
43-
bazel build --define=use_strict_warning=true \
38+
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path bazel_binder_connection_helper
39+
bazel_binder_connection_helper/bazel_wrapper \
40+
--bazelrc=tools/remote_build/include/test_locally_with_resultstore_results.bazelrc \
41+
build \
42+
--define=use_strict_warning=true \
4443
@binder_transport_android_helper//io/grpc/binder/cpp:connection_helper

tools/internal_ci/linux/grpc_feature_example_tests.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ build_file: "grpc/tools/internal_ci/linux/grpc_bazel.sh"
1919
timeout_mins: 30
2020
env_vars {
2121
key: "BAZEL_SCRIPT"
22-
value: "tools/internal_ci/linux/grpc_feature_example_tests.sh"
22+
value: "tools/internal_ci/linux/grpc_feature_example_tests_in_docker.sh"
2323
}
2424
action {
2525
define_artifacts {

tools/internal_ci/linux/grpc_feature_example_tests.sh renamed to tools/internal_ci/linux/grpc_feature_example_tests_in_docker.sh

+1-10
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,8 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
#!/usr/bin/env bash
16-
#
17-
# NOTE: No empty lines should appear in this file before igncr is set!
18-
set -ex -o igncr || set -ex
1915

20-
mkdir -p /var/local/git
21-
git clone /var/local/jenkins/grpc /var/local/git/grpc
22-
(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
23-
&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
24-
${name}')
25-
cd /var/local/git/grpc
16+
set -ex
2617

2718
apt-get install -y lsof
2819

tools/internal_ci/linux/grpc_flaky_network.cfg

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
# Config file for the internal CI (in protobuf text format)
1616

1717
# Location of the continuous shell script in repository.
18-
build_file: "grpc/tools/internal_ci/linux/grpc_bazel_privileged_docker.sh"
18+
build_file: "grpc/tools/internal_ci/linux/grpc_flaky_network.sh"
1919
timeout_mins: 240
20-
env_vars {
21-
key: "BAZEL_SCRIPT"
22-
value: "tools/internal_ci/linux/grpc_flaky_network_in_docker.sh"
20+
action {
21+
define_artifacts {
22+
regex: "**/*sponge_log.*"
23+
regex: "github/grpc/reports/**"
24+
}
2325
}

tools/internal_ci/linux/grpc_bazel_privileged_docker.sh renamed to tools/internal_ci/linux/grpc_flaky_network.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515

1616
set -ex
1717

18+
# avoid slow finalization after the script has exited.
19+
source $(dirname $0)/../../../tools/internal_ci/helper_scripts/move_src_tree_and_respawn_itself_rc
20+
1821
# change to grpc repo root
1922
cd $(dirname $0)/../../..
2023

2124
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
2225

2326
export DOCKERFILE_DIR=tools/dockerfile/test/bazel
24-
export DOCKER_RUN_SCRIPT=$BAZEL_SCRIPT
2527
# NET_ADMIN capability allows tests to manipulate network interfaces
26-
exec tools/run_tests/dockerize/build_and_run_docker.sh --cap-add NET_ADMIN
28+
export EXTRA_DOCKER_ARGS="--cap-add NET_ADMIN"
29+
exec tools/run_tests/dockerize/build_and_run_docker.sh tools/internal_ci/linux/grpc_flaky_network_in_docker.sh

tools/internal_ci/linux/grpc_flaky_network_in_docker.sh

+3-10
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,10 @@
1515
#
1616
# Run the flaky network test
1717
#
18-
# NOTE: No empty lines should appear in this file before igncr is set!
19-
set -ex -o igncr || set -ex
20-
21-
mkdir -p /var/local/git
22-
git clone /var/local/jenkins/grpc /var/local/git/grpc
23-
(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
24-
&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
25-
${name}')
26-
cd /var/local/git/grpc/test/cpp/end2end
18+
set -ex
2719

2820
# iptables is used to drop traffic between client and server
2921
apt-get install -y iptables iproute2
3022

31-
bazel test --test_output=all --test_timeout=1200 :flaky_network_test --test_env=GRPC_TRACE=http --test_env=GRPC_VERBOSITY=DEBUG
23+
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path bazel_flaky_network_test
24+
bazel_flaky_network_test/bazel_wrapper test --test_output=all --test_timeout=1200 //test/cpp/end2end:flaky_network_test --test_env=GRPC_TRACE=http --test_env=GRPC_VERBOSITY=DEBUG

tools/internal_ci/linux/grpc_python_bazel_test_in_docker.sh

+4-11
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,18 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
#
16-
# Test full Bazel
1715

1816
set -ex
1917

20-
mkdir -p /var/local/git
21-
git clone /var/local/jenkins/grpc /var/local/git/grpc
22-
(cd /var/local/jenkins/grpc/ && git submodule foreach 'cd /var/local/git/grpc \
23-
&& git submodule update --init --reference /var/local/jenkins/grpc/${name} \
24-
${name}')
25-
cd /var/local/git/grpc
18+
RESULTSTORE_RESULTS_FLAG="--bazelrc=tools/remote_build/include/test_locally_with_resultstore_results.bazelrc"
2619
TEST_TARGETS="//src/python/... //tools/distrib/python/grpcio_tools/... //examples/python/..."
2720
BAZEL_FLAGS="--test_output=errors"
2821

2922
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path python_bazel_tests
30-
python_bazel_tests/bazel_wrapper test ${BAZEL_FLAGS} ${TEST_TARGETS}
23+
python_bazel_tests/bazel_wrapper ${RESULTSTORE_RESULTS_FLAG} test ${BAZEL_FLAGS} ${TEST_TARGETS}
3124

3225
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path python_bazel_tests_single_threaded_unary_streams
33-
python_bazel_tests_single_threaded_unary_streams/bazel_wrapper test --config=python_single_threaded_unary_stream ${BAZEL_FLAGS} ${TEST_TARGETS}
26+
python_bazel_tests_single_threaded_unary_streams/bazel_wrapper ${RESULTSTORE_RESULTS_FLAG} test --config=python_single_threaded_unary_stream ${BAZEL_FLAGS} ${TEST_TARGETS}
3427

3528
python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path python_bazel_tests_poller_engine
36-
python_bazel_tests_poller_engine/bazel_wrapper test --config=python_poller_engine ${BAZEL_FLAGS} ${TEST_TARGETS}
29+
python_bazel_tests_poller_engine/bazel_wrapper ${RESULTSTORE_RESULTS_FLAG} test --config=python_poller_engine ${BAZEL_FLAGS} ${TEST_TARGETS}

tools/internal_ci/linux/pull_request/grpc_feature_example_tests.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ build_file: "grpc/tools/internal_ci/linux/grpc_bazel.sh"
1919
timeout_mins: 30
2020
env_vars {
2121
key: "BAZEL_SCRIPT"
22-
value: "tools/internal_ci/linux/grpc_feature_example_tests.sh"
22+
value: "tools/internal_ci/linux/grpc_feature_example_tests_in_docker.sh"
2323
}
2424
action {
2525
define_artifacts {

tools/run_tests/dockerize/docker_propagate_env.list

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ KOKORO_BUILD_INITIATOR
1212
KOKORO_BUILD_NUMBER
1313
KOKORO_BUILD_URL
1414
KOKORO_GIT_COMMIT
15+
KOKORO_GITHUB_COMMIT
1516
KOKORO_JOB_NAME
1617
KOKORO_GITHUB_PULL_REQUEST_NUMBER
1718
KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH

0 commit comments

Comments
 (0)