Skip to content

Commit

Permalink
Better bazel C++ iOS tests (with structured test results) (grpc#29354)
Browse files Browse the repository at this point in the history
* introduce bazelrc for tests with resultstore-uploaded results

* modernize bazel cpp ios tests

* simplify bazel invocation in bazel_cpp_ios_tests

* remove unused bazel core ios tests
  • Loading branch information
jtattermusch authored Apr 12, 2022
1 parent 07a7542 commit c64d6f3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 62 deletions.
19 changes: 0 additions & 19 deletions tools/internal_ci/macos/grpc_bazel_core_ios_tests.cfg

This file was deleted.

21 changes: 21 additions & 0 deletions tools/internal_ci/macos/grpc_bazel_cpp_ios_tests.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,24 @@
# Location of the continuous shell script in repository.
build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_cpp_ios_tests.sh"

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"
}

env_vars {
key: "UPLOAD_TEST_RESULTS"
value: "true"
}
34 changes: 0 additions & 34 deletions tools/internal_ci/macos/grpc_run_bazel_core_ios_tests.sh

This file was deleted.

29 changes: 20 additions & 9 deletions tools/internal_ci/macos/grpc_run_bazel_cpp_ios_tests.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,25 @@ source $(dirname $0)/../../../tools/internal_ci/helper_scripts/move_src_tree_and
# change to grpc repo root
cd $(dirname $0)/../../..

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

dirs=(end2end server client common codegen util grpclb test)
for dir in ${dirs[*]}; do
echo $dir
out=`tools/bazel query "kind(ios_unit_test, tests(//test/cpp/$dir/...))" 2>/dev/null | grep '^//'`
for test in $out; do
echo "Running: $test"
tools/bazel test --test_summary=detailed --test_output=all $test
done
done
# only select ObjC test from the following subdirs
# TODO(jtattermusch): start running selected tests from //test/core too.
test_pattern="//test/cpp/end2end/... + //test/cpp/server/... + //test/cpp/client/... + //test/cpp/common/... + //test/cpp/codegen/... + //test/cpp/util/... + //test/cpp/grpclb/... + //test/cpp/test/..."

# iOS tests are marked as "manual" to prevent them from running by default. To run them, we need to use "bazel query" to list them first.
ios_tests=$(tools/bazel query "kind(ios_unit_test, tests($test_pattern))" | grep '^//')

python3 tools/run_tests/python_utils/bazel_report_helper.py --report_path bazel_cpp_ios_tests

bazel_cpp_ios_tests/bazel_wrapper \
--bazelrc=tools/remote_build/include/test_locally_with_resultstore_results.bazelrc \
test \
--google_credentials="${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json" \
$BAZEL_FLAGS \
-- ${ios_tests}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Run tests locally, but configure bazel to upload
# the results to resultstore UI.
# Also easily extended to use remote cache for
# locally run builds and tests (but not on by default for safety)

import %workspace%/tools/remote_build/include/rbe_base_config.bazelrc

# Disable uploading to build cache by default. This is to prevent
# polluting the build cache with local build and test results.
# When running on CI, we will override this setting along
# with cache silo keys that prevent the build from being broken
# by unintentional cache hits.
build --remote_upload_local_results=false

import %workspace%/tools/remote_build/include/test_config_common.bazelrc

0 comments on commit c64d6f3

Please sign in to comment.