-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoke-test.sh
executable file
·46 lines (38 loc) · 1.2 KB
/
smoke-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
#!/usr/bin/env bash
set -euo pipefail
docker compose down
docker compose up -d
RETRIES=30
MIN_POINT_COUNT=10
# shellcheck source=/dev/null
source .env
for i in $(seq 1 1 $RETRIES)
do
FLUX_QUERY="from(bucket:\"$INFLUXDB_BUCKET\")
|> range(start: -1m)
|> filter(fn: (r) => r[\"_measurement\"] == \"$INFLUXDB_MEASUREMENT\")
|> count()"
POINT_COUNT=$(docker compose exec influxdb \
influx query --raw \
--org "$INFLUXDB_ORG" \
--token "$INFLUXDB_TOKEN" \
"$FLUX_QUERY" | grep ',0,' | awk -F',' '{print $6}' || true)
echo "Measurement $INFLUXDB_MEASUREMENT contains $POINT_COUNT points."
if [[ $POINT_COUNT =~ ^[0-9]+$ && $POINT_COUNT -ge $MIN_POINT_COUNT ]];
then
echo "Simulator is successfully ingesting data into InfluxDB."
break
else
echo "Waiting for the Simulator.. Attempt [${i}/${RETRIES}]"
if [ "$i" = $RETRIES ];
then
echo "Found less than ${MIN_POINT_COUNT} points in measurement $INFLUXDB_MEASUREMENT"
docker compose logs telegraf
docker compose down
exit 1
else
sleep 1
fi
fi
done
docker compose down