forked from pgautoupgrade/docker-pgautoupgrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·62 lines (51 loc) · 1.79 KB
/
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
#!/usr/bin/env bash
# Stop any existing containers from previous test runs
test_down() {
docker-compose -f test/docker-compose-pgauto.yml down
}
test_run() {
V=$1
# Delete any existing test PostgreSQL data
if [ -d postgres-data ]; then
echo "Removing old PostgreSQL data from test directory"
sudo rm -rf postgres-data
fi
# Create the PostgreSQL database using PG 9.5
docker-compose -f docker-compose-pg${V}.yml run --rm server create_db
# Start Redash normally, using the "autoupdate" version of PostgreSQL
docker-compose -f docker-compose-pgauto.yml up -d
# Verify the PostgreSQL data files are now version 15
PGVER=$(sudo cat postgres-data/PG_VERSION)
if [ "$PGVER" != "15" ]; then
echo
echo "***************************************************************"
echo "Automatic upgrade of PostgreSQL from version ${V} to 15 FAILED!"
echo "***************************************************************"
echo
else
echo
echo "******************************************************************"
echo "Automatic upgrade of PostgreSQL from version ${V} to 15 SUCCEEDED!"
echo "******************************************************************"
echo
fi
# Shut down containers from previous test runs
docker-compose -f docker-compose-pgauto.yml down
}
# Shut down containers from previous test runs
test_down
# If the user gives a first argument of "down", then we exit
# after shutting down any running containers from previous test runs
if [ "$1" = "down" ]; then
exit 0
fi
# Change into the test directory
cd test
# Testing upgrading from each major PG version directly to PG 15
test_run 9.5
test_run 9.6
test_run 10
test_run 11
test_run 12
test_run 13
test_run 14