From 7bdfac26a57b454e4726fed76c26bd59a179ba6c Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 22 Nov 2019 13:46:44 +0100 Subject: [PATCH] improve cfg files and sh script --- .../macos/grpc_bazel_c_cpp_dbg.cfg | 23 +++++++++++- .../macos/grpc_bazel_c_cpp_opt.cfg | 23 +++++++++++- .../macos/grpc_run_bazel_c_cpp_tests.sh | 37 ++++++++++++++++--- 3 files changed, 74 insertions(+), 9 deletions(-) diff --git a/tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg b/tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg index bc9b671e1fb..7c4c17142c3 100644 --- a/tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg +++ b/tools/internal_ci/macos/grpc_bazel_c_cpp_dbg.cfg @@ -16,7 +16,26 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh" +timeout_mins: 90 + +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/resultstore_api_key" + +bazel_setting { + # In order for Kokoro to recognize this as a bazel build and publish the bazel resultstore link, + # the bazel_setting section needs to be present and "upsalite_frontend_address" needs to be + # set. The rest of configuration from bazel_setting is unused (we configure everything when bazel + # command is invoked). + upsalite_frontend_address: "https://source.cloud.google.com" +} + +env_vars { + # flags will be passed to bazel invocation + key: "BAZEL_FLAGS" + value: "--cache_test_results=no --config=dbg" +} + env_vars { - key: "RUN_TESTS_FLAGS" - value: "--config=dbg" + key: "UPLOAD_TEST_RESULTS" + value: "true" } diff --git a/tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg b/tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg index 62fc5fc1b38..e7447398713 100644 --- a/tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg +++ b/tools/internal_ci/macos/grpc_bazel_c_cpp_opt.cfg @@ -16,7 +16,26 @@ # Location of the continuous shell script in repository. build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh" +timeout_mins: 90 + +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json" +gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/resultstore_api_key" + +bazel_setting { + # In order for Kokoro to recognize this as a bazel build and publish the bazel resultstore link, + # the bazel_setting section needs to be present and "upsalite_frontend_address" needs to be + # set. The rest of configuration from bazel_setting is unused (we configure everything when bazel + # command is invoked). + upsalite_frontend_address: "https://source.cloud.google.com" +} + +env_vars { + # flags will be passed to bazel invocation + key: "BAZEL_FLAGS" + value: "--cache_test_results=no --config=opt" +} + env_vars { - key: "RUN_TESTS_FLAGS" - value: "--config=opt" + key: "UPLOAD_TEST_RESULTS" + value: "true" } diff --git a/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh b/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh index d798912dd5d..ed9c97211c4 100644 --- a/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh +++ b/tools/internal_ci/macos/grpc_run_bazel_c_cpp_tests.sh @@ -18,13 +18,40 @@ set -ex # change to grpc repo root cd $(dirname $0)/../../.. +# TODO(jtattermusch): most of the prepare steps should not be needed for bazel +source tools/internal_ci/helper_scripts/prepare_build_macos_rc + +# make sure bazel is available +tools/bazel version + ./tools/run_tests/start_port_server.py +# to get "bazel" link for kokoro build, we need to generate +# invocation UUID, set a flag for bazel to use it +# and upload "bazel_invocation_ids" file as artifact. +# NOTE: UUID needs to be in lowercase for the result link to work +# (on mac "uuidgen" outputs uppercase UUID) +BAZEL_INVOCATION_ID="$(uuidgen | tr '[:upper:]' '[:lower:]')" +echo "${BAZEL_INVOCATION_ID}" >"${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids" + # run all C/C++ tests -# TODO(jtattermusch): try using Bazel RBE remote cache -# TODO(jtattermusch): upload bazel test results to resultstore -tools/bazel --bazelrc=tools/remote_build/mac.bazelrc test $RUN_TESTS_FLAGS //test/... +tools/bazel \ + --bazelrc=tools/remote_build/mac.bazelrc \ + test \ + --invocation_id="${BAZEL_INVOCATION_ID}" \ + --workspace_status_command=tools/remote_build/workspace_status_kokoro.sh \ + --google_credentials="${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json" \ + $BAZEL_FLAGS \ + -- //test/... || FAILED="true" -# kill port_server.py to prevent the build from hanging -ps aux | grep port_server\\.py | awk '{print $2}' | xargs kill -9 +if [ "$UPLOAD_TEST_RESULTS" != "" ] +then + # Sleep to let ResultStore finish writing results before querying + sleep 60 + python ./tools/run_tests/python_utils/upload_rbe_results.py +fi +if [ "$FAILED" != "" ] +then + exit 1 +fi