1#!/usr/bin/env bash
2# Copyright 2017 gRPC authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16set -ex
17
18# A temporary solution to give Kokoro credentials.
19# The file name 4321_grpc-testing-service needs to match auth_credential in
20# the build config.
21mkdir -p ${KOKORO_KEYSTORE_DIR}
22cp ${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json ${KOKORO_KEYSTORE_DIR}/4321_grpc-testing-service
23
24temp_dir=$(mktemp -d)
25ln -f "${KOKORO_GFILE_DIR}/bazel-latest-release" ${temp_dir}/bazel
26chmod 755 "${KOKORO_GFILE_DIR}/bazel-latest-release"
27export PATH="${temp_dir}:${PATH}"
28# This should show ${temp_dir}/bazel
29which bazel
30chmod +x "${KOKORO_GFILE_DIR}/bazel_wrapper.py"
31
32# change to grpc repo root
33cd $(dirname $0)/../../..
34
35source tools/internal_ci/helper_scripts/prepare_build_linux_rc
36
37export KOKORO_FOUNDRY_PROJECT_ID="projects/grpc-testing/instances/default_instance"
38
39# TODO(adelez): implement size for test targets and change test_timeout back
40"${KOKORO_GFILE_DIR}/bazel_wrapper.py" \
41  --host_jvm_args=-Dbazel.DigestFunction=SHA256 \
42  test --jobs="200" \
43  --test_output=errors  \
44  --verbose_failures=true  \
45  --keep_going  \
46  --remote_accept_cached=true  \
47  --spawn_strategy=remote  \
48  --remote_local_fallback=false  \
49  --remote_timeout=3600  \
50  --strategy=Javac=remote  \
51  --strategy=Closure=remote  \
52  --genrule_strategy=remote  \
53  --experimental_strict_action_env=true \
54  --crosstool_top=@com_github_bazelbuild_bazeltoolchains//configs/ubuntu16_04_clang/1.0/bazel_0.16.1/default:toolchain \
55  --define GRPC_PORT_ISOLATED_RUNTIME=1 \
56  --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 \
57  --extra_toolchains=@com_github_bazelbuild_bazeltoolchains//configs/ubuntu16_04_clang/1.0/bazel_0.16.1/cpp:cc-toolchain-clang-x86_64-default \
58  --extra_execution_platforms=//third_party/toolchains:rbe_ubuntu1604 \
59  --host_platform=//third_party/toolchains:rbe_ubuntu1604 \
60  --platforms=//third_party/toolchains:rbe_ubuntu1604 \
61  --test_env=GRPC_VERBOSITY=debug \
62  --remote_instance_name=projects/grpc-testing/instances/default_instance \
63  $@ \
64  -- //test/... || FAILED="true"
65
66if [ "$UPLOAD_TEST_RESULTS" != "" ]
67then
68  # Sleep to let ResultStore finish writing results before querying
69  sleep 60
70  python ./tools/run_tests/python_utils/upload_rbe_results.py
71fi
72
73if [ "$FAILED" != "" ]
74then
75  exit 1
76fi
77