forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bazel-test-docker.sh
executable file
·52 lines (44 loc) · 1.7 KB
/
bazel-test-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Run a single Bazel test target under a privileged docker. Usage:
#
# tools/bazel-test-docker //test/foo:bar --some_other --bazel_args
# By default, this will run in a local docker container, mounting the local shared library paths
# into the counter. To run remotely, use RUN_REMOTE=yes. If the test was compiled with a different
# toolchain than the envoy-build container, passing in LOCAL_MOUNT=yes will force it to copy the
# local libraries into the container.
if [[ -z "$1" ]]; then
echo "First argument to $0 must be a [@repo]//test/foo:bar label identifying a set of test to run"
echo "\"$1\" does not match this pattern"
exit 1
fi
SCRIPT_DIR="$(realpath "$(dirname "$0")")"
[[ -z "${BAZEL}" ]] && BAZEL=bazel
[[ -z "${DOCKER}" ]] && DOCKER=docker
if [[ -z "${RUN_REMOTE}" ]]; then
LOCAL_MOUNT="${LOCAL_MOUNT:-yes}"
RUN_REMOTE=no
else
LOCAL_MOUNT="${LOCAL_MOUNT:-no}"
RUN_REMOTE=yes
fi
# Pass through the docker environment
DOCKER_ENV=$(mktemp -t docker_env.XXXXXX)
function cleanup() {
rm -f "${DOCKER_ENV}"
}
trap cleanup EXIT
cat > "${DOCKER_ENV}" <<EOF
#!/bin/bash
export DOCKER_CERT_PATH="${DOCKER_CERT_PATH}"
export DOCKER_HOST="${DOCKER_HOST}"
export DOCKER_MACHINE_NAME="${DOCKER_MACHINE_NAME}"
export DOCKER_TLS_VERIFY="${DOCKER_TLS_VERIFY}"
export NO_PROXY="${NO_PROXY}"
EOF
. ./ci/envoy_build_sha.sh
IMAGE=envoyproxy/envoy-build:${ENVOY_BUILD_SHA}
# Note docker_wrapper.sh is tightly coupled to the order of arguments here due to where the test
# name is passed in.
"${BAZEL}" test "$@" --strategy=TestRunner=standalone --cache_test_results=no \
--test_output=summary --run_under="${SCRIPT_DIR}/docker_wrapper.sh ${IMAGE} ${RUN_REMOTE} \
${LOCAL_MOUNT} ${DOCKER_ENV}"