-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·45 lines (34 loc) · 1.13 KB
/
test.sh
File metadata and controls
executable file
·45 lines (34 loc) · 1.13 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
#!/bin/bash
# Test script for metagration TLE
# NOTE: This script requires install-tle.sql - run 'make test' instead of './test.sh' directly
DB_HOST="metagration-test-db"
DB_NAME="postgres"
SU="postgres"
EXEC="docker exec $DB_HOST"
echo "Destroying test container"
docker rm --force "$DB_HOST" 2>/dev/null || true
set -e
echo "Building test image"
docker build . -t metagration/test
echo "Running test container"
docker run -e POSTGRES_HOST_AUTH_METHOD=trust -d \
-v "$(pwd)":/metagration \
--name "$DB_HOST" \
metagration/test
echo "Waiting for database to accept connections"
until
$EXEC \
psql -o /dev/null -t -q -U "$SU" \
-c 'select pg_sleep(1)' \
2>/dev/null;
do sleep 1;
done
echo "Installing pg_tle extension"
$EXEC psql -U "$SU" -d "$DB_NAME" -c "CREATE EXTENSION pg_tle;"
echo "Installing metagration TLE"
$EXEC psql -U "$SU" -d "$DB_NAME" -f /metagration/install-tle.sql
echo "Creating metagration extension"
$EXEC psql -U "$SU" -d "$DB_NAME" -c "CREATE EXTENSION metagration;"
echo "Running tests"
$EXEC psql -U "$SU" -d "$DB_NAME" -f /metagration/test/test.sql
echo "All tests passed!"