forked from Intevation/intelmq-cb-mailgen-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestall.sh
executable file
·53 lines (41 loc) · 1.43 KB
/
testall.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
#!/bin/bash
set -eu -o pipefail
test -n "${DEBUG-}" && set -x
set -o allexport
source .env
set +o allexport
function end_test {
read line file <<<$(caller)
echo "Test failed at $file:$line."
}
trap end_test ERR
if [ "$USE_CERTBUND" == "true" ]; then
# clean the database for mailgen tests
# TRUNCATE would try to acquire an exclusive lock, which is blocked by fody, so delete all entries from the tables
docker exec --env-file=.env -e DEBUG=${DEBUG-} -ti intelmq-database psql eventdb -c "DELETE FROM directives; DELETE FROM events;"
# The database takes several minutes after its first start to complete initialization. Check it's availability in the beginning to avoid errors later
set +e
echo | nc -vw 0 localhost 1338
if [ $? -ne 0 ]; then
echo "Database is not yet ready. Exiting."
exit 1
fi
set -e
# Suspend mailgen. Lock will be removed after successful fun of mailgen tests
docker exec -ti intelmq-mailgen touch /tmp/intelmqcbmail_disabled
fi
# clear deduplicator cache
docker exec -ti intelmq-redis redis-cli -n 6 flushdb
# Run IntelMQ tests
docker exec --env-file=.env -e DEBUG=${DEBUG-} -ti intelmq /opt/test.sh
# Prerequisites
sudo apt install -y wget uuid-runtime jq
# Run fody tests
./fody/test.sh
# Run webinput csv tests
./webinput-csv/test.sh
if [ "$USE_CERTBUND" == "true" ]; then
# Run mailgen tests
./mailgen/test.sh
fi
echo "All tests completed successfully!"