-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·79 lines (67 loc) · 2.15 KB
/
run_tests.sh
File metadata and controls
executable file
·79 lines (67 loc) · 2.15 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -ex
function cleanup {
PYTHON_VERSION=${1} REGISTRY=${REGISTRY} IMAGE_NAME=${IMAGE_NAME} docker compose down -v
if [[ $CODECOV_TOKEN ]]; then
cd ..
bash <(curl -s https://codecov.io/bash) -e PYTHON_VERSION,FRAMEWORK || true
fi
}
trap cleanup EXIT
if [ $# -lt 2 ]; then
echo "Arguments missing"
exit 2
fi
pip_cache="$HOME/.cache"
docker_pip_cache="/tmp/cache/pip"
TEST="${1}/${2}"
LOCAL_USER_ID=${LOCAL_USER_ID:=$(id -u)}
LOCAL_GROUP_ID=${LOCAL_GROUP_ID:=$(id -g)}
IMAGE_NAME=${IMAGE_NAME:-"apm-agent-python-testing"}
REGISTRY=${REGISTRY:-"elasticobservability"}
cd tests
# check if the full FRAMEWORK name is in scripts/envs
if [[ -e "./scripts/envs/${2}.sh" ]]
then
source ./scripts/envs/${2}.sh
else
# check if only the first part of the FRAMEWORK is in scripts/envs
IFS='-'; frameworkParts=($2); unset IFS;
if [[ -e "./scripts/envs/${frameworkParts[0]}.sh" ]]
then
source ./scripts/envs/${frameworkParts[0]}.sh
fi
fi
echo "Running tests for ${TEST}"
if [[ -n $DOCKER_DEPS ]]
then
PYTHON_VERSION=${1} REGISTRY=${REGISTRY} IMAGE_NAME=${IMAGE_NAME} docker compose up --quiet-pull -d ${DOCKER_DEPS}
fi
# CASS_DRIVER_NO_EXTENSIONS is set so we don't build the Cassandra C-extensions,
# as this can take several minutes
if ! ${CI}; then
full_image_name="${REGISTRY}/${IMAGE_NAME}:${1}"
DOCKER_BUILDKIT=1 docker build \
--progress=plain \
--cache-from="${full_image_name}" \
--build-arg PYTHON_IMAGE="${1/-/:}" \
--tag "${full_image_name}" \
.
fi
PYTHON_VERSION=${1} docker compose run --quiet-pull \
-e PYTHON_FULL_VERSION=${1} \
-e LOCAL_USER_ID=$LOCAL_USER_ID \
-e LOCAL_GROUP_ID=$LOCAL_GROUP_ID \
-e PYTHONDONTWRITEBYTECODE=1 \
-e FRAMEWORK=${2} \
-e PIP_CACHE=${docker_pip_cache} \
-e WITH_COVERAGE=true \
-e CASS_DRIVER_NO_EXTENSIONS=1 \
-e PYTEST_JUNIT="--junitxml=/app/tests/docker-${1}-${2}-python-agent-junit.xml" \
-e REGISTRY=${REGISTRY} \
-e IMAGE_NAME=${IMAGE_NAME} \
-v ${pip_cache}:$(dirname ${docker_pip_cache}) \
-v "$(dirname $(pwd))":/app \
--rm run_tests \
/bin/bash \
-c "timeout 5m /bin/bash ./tests/scripts/run_tests.sh"