forked from jaegertracing/jaeger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes-integration-test.sh
executable file
·124 lines (109 loc) · 3.17 KB
/
es-integration-test.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
PS4='T$(date "+%H:%M:%S") '
set -euf -o pipefail
# use global variables to reflect status of db
db_is_up=
usage() {
echo "Usage: $0 <backend> <backend_version> <jaeger_version>"
echo " backend: elasticsearch | opensearch"
echo " backend_version: major version, e.g. 7.x"
echo " jaeger_version: major version, e.g. v1 | v2"
exit 1
}
check_arg() {
if [ ! $# -eq 3 ]; then
echo "ERROR: need exactly three arguments"
usage
fi
}
# start the elasticsearch/opensearch container
setup_db() {
local compose_file=$1
docker compose -f "${compose_file}" up -d
echo "docker_compose_file=${compose_file}" >> "${GITHUB_OUTPUT:-/dev/null}"
}
# check if the storage is up and running
wait_for_storage() {
local distro=$1
local url=$2
local compose_file=$3
local params=(
--silent
--output
/dev/null
--write-out
"%{http_code}"
)
local max_attempts=60
local attempt=0
echo "Waiting for ${distro} to be available at ${url}..."
until [[ "$(curl "${params[@]}" "${url}")" == "200" ]] || (( attempt >= max_attempts )); do
attempt=$(( attempt + 1 ))
echo "Attempt: ${attempt} ${distro} is not yet available at ${url}..."
sleep 10
done
# if after all the attempts the storage is not accessible, terminate it and exit
if [[ "$(curl "${params[@]}" "${url}")" != "200" ]]; then
echo "ERROR: ${distro} is not ready at ${url} after $(( attempt * 10 )) seconds"
echo "::group::${distro} logs"
docker compose -f "${compose_file}" logs
echo "::endgroup::"
docker compose -f "${compose_file}" down
db_is_up=0
else
echo "SUCCESS: ${distro} is available at ${url}"
db_is_up=1
fi
}
bring_up_storage() {
local distro=$1
local version=$2
local major_version=${version%%.*}
local compose_file="docker-compose/${distro}/v${major_version}/docker-compose.yml"
echo "starting ${distro} ${major_version}"
for retry in 1 2 3
do
echo "attempt $retry"
if [ "${distro}" = "elasticsearch" ] || [ "${distro}" = "opensearch" ]; then
setup_db "${compose_file}"
else
echo "Unknown distribution $distro. Valid options are opensearch or elasticsearch"
usage
fi
wait_for_storage "${distro}" "http://localhost:9200" "${compose_file}"
if [ ${db_is_up} = "1" ]; then
break
fi
done
if [ ${db_is_up} = "1" ]; then
# shellcheck disable=SC2064
trap "teardown_storage ${compose_file}" EXIT
else
echo "ERROR: unable to start ${distro}"
exit 1
fi
}
# terminate the elasticsearch/opensearch container
teardown_storage() {
local compose_file=$1
docker compose -f "${compose_file}" down
}
main() {
check_arg "$@"
local distro=$1
local es_version=$2
local j_version=$3
set -x
bring_up_storage "${distro}" "${es_version}"
if [[ "${j_version}" == "v2" ]]; then
STORAGE=${distro} SPAN_STORAGE_TYPE=${distro} make jaeger-v2-storage-integration-test
elif [[ "${j_version}" == "v1" ]]; then
STORAGE=${distro} make storage-integration-test
make index-cleaner-integration-test
make index-rollover-integration-test
else
echo "ERROR: Invalid argument value jaeger_version=${j_version}, expecing v1/v2".
exit 1
fi
}
main "$@"