master
sh 49 lines 1.2 KB
Raw
1 #!/usr/bin/env bash
2 set -euo pipefail
3
4 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5 # shellcheck disable=SC1091
6 . "$SCRIPT_DIR/lib.sh"
7
8 run_top_queries_retry() {
9 local module="$1"
10 local attempts="${2:-20}"
11 local delay="${3:-0.5}"
12 local output="$WORKDIR/${module}-top-queries.json"
13 local i=1
14
15 while [ "$i" -le "$attempts" ]; do
16 run "$WORKDIR/go.d.plugin" \
17 --config-dir "$WORKDIR/config" \
18 --function "${module}:top-queries" \
19 --function-args __job:local \
20 > "$output"
21 validate "$output"
22 if has_min_rows "$output" 1; then
23 return 0
24 fi
25 sleep "$delay"
26 i=$((i + 1))
27 done
28
29 echo "top-queries returned 0 rows after ${attempts} attempts" >&2
30 return 1
31 }
32
33 init_workspace "elasticsearch"
34 trap cleanup EXIT
35
36 ELASTICSEARCH_PORT="$(reserve_port)"
37 write_env "ELASTICSEARCH_PORT" "$ELASTICSEARCH_PORT"
38 replace_in_file "$WORKDIR/config/go.d/elasticsearch.conf" "127.0.0.1:9200" "127.0.0.1:${ELASTICSEARCH_PORT}"
39
40 compose_up elasticsearch
41 wait_healthy elasticsearch 120
42 compose_run elasticsearch-init
43 compose_up elasticsearch-searcher
44
45 build_plugin
46 run_info elasticsearch
47 run_top_queries_retry elasticsearch
48
49 echo "E2E checks passed for elasticsearch." >&2