Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix repair in update scripts #2920

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,18 @@ jobs:
script:
- ${RETRY_PREFIX} bash ./scripts/test_updates_pg96.sh

# This tests the ability to upgrade to the latest version on pg 9.6
- if: (type = cron) OR (branch = prerelease_test)
env: PG_VERSION=9.6.6
name: "Update tests PostgreSQL 9.6.6 (with repair test)"
before_install:
install:
after_failure:
after_script:
after_success:
script:
- ${RETRY_PREFIX} bash ./scripts/test_updates_pg96.sh -r

# This tests the ability to upgrade to the latest version on pg 10
- if: (type = cron) OR (branch = prerelease_test)
env: PG_VERSION=10.2
Expand All @@ -301,6 +313,18 @@ jobs:
script:
- ${RETRY_PREFIX} bash ./scripts/test_updates_pg10.sh

# This tests the ability to upgrade to the latest version on pg 10
- if: (type = cron) OR (branch = prerelease_test)
env: PG_VERSION=10.2
name: "Update tests PostgreSQL 10.2 (with repair test)"
before_install:
install:
after_failure:
after_script:
after_success:
script:
- ${RETRY_PREFIX} bash ./scripts/test_updates_pg10.sh -r

# This tests the ability to upgrade to the latest version on pg 11
- if: (type = pull_request) OR (type = cron) OR (branch = prerelease_test)
env: PG_VERSION=11.0
Expand All @@ -313,6 +337,17 @@ jobs:
script:
- ${RETRY_PREFIX} bash ./scripts/test_updates_pg11.sh

- if: (type = pull_request) OR (type = cron) OR (branch = prerelease_test)
env: PG_VERSION=11.0
name: "Update tests PostgreSQL 11.0 (with repair test)"
before_install:
install:
after_failure:
after_script:
after_success:
script:
- ${RETRY_PREFIX} bash ./scripts/test_updates_pg11.sh -r

# This tests the ability to upgrade to the latest version on pg 12
- if: (type = pull_request) OR (type = cron) OR (branch = prerelease_test)
env: PG_VERSION=12.0
Expand All @@ -325,6 +360,18 @@ jobs:
script:
- ${RETRY_PREFIX} bash ./scripts/test_updates_pg12.sh

# This tests the ability to upgrade to the latest version on pg 12
- if: (type = pull_request) OR (type = cron) OR (branch = prerelease_test)
env: PG_VERSION=12.0
name: "Update tests PostgreSQL 12.0 (with repair test)"
before_install:
install:
after_failure:
after_script:
after_success:
script:
- ${RETRY_PREFIX} bash ./scripts/test_updates_pg12.sh -r

- if: (type = cron) OR (branch = prerelease_test)
name: "ABI breakage smoketest 9.6"
before_install:
Expand Down
33 changes: 28 additions & 5 deletions scripts/test_update_from_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ docker_exec() {
}

docker_pgcmd() {
docker_exec $1 "psql -h localhost -U postgres -d single -c \"$2\""
docker_exec $1 "psql -h localhost -U postgres -d single -v TEST_REPAIR=${TEST_REPAIR} -c \"$2\""
}

docker_pgscript() {
docker_exec $1 "psql -h localhost -U postgres -v ON_ERROR_STOP=1 -f $2"
docker_exec $1 "psql -h localhost -U postgres -v TEST_REPAIR=${TEST_REPAIR} -v ON_ERROR_STOP=1 -f $2"
}

docker_pgtest() {
Expand Down Expand Up @@ -150,14 +150,37 @@ docker rm -f ${CONTAINER_ORIG}
echo "Running update container"
docker_run_vol ${CONTAINER_UPDATED} ${UPDATE_VOLUME}:/var/lib/postgresql/data ${UPDATE_TO_IMAGE}:${UPDATE_TO_TAG}

echo "Executing ALTER EXTENSION timescaledb UPDATE"
echo "Executing ALTER EXTENSION timescaledb UPDATE ($UPDATE_FROM_TAG -> $UPDATE_TO_TAG)"
docker_pgcmd ${CONTAINER_UPDATED} "ALTER EXTENSION timescaledb UPDATE"

# Post update script. Need to run it to restore the constraints that
# was dropped to be able to remove dimension slices in the repair
# test.
if [[ "${TEST_VERSION}" > "v6" ]] || [[ "${TEST_VERSION}" = "v6" ]]; then
if [[ "${TEST_REPAIR}" = "true" ]]; then
echo "Executing post update repair script"
docker_pgscript ${CONTAINER_UPDATED} /src/test/sql/updates/post.repair.sql
fi
fi

docker_exec ${CONTAINER_UPDATED} "pg_dump -h localhost -U postgres -Fc single > /tmp/single.sql"
docker cp ${CONTAINER_UPDATED}:/tmp/single.sql ${TEST_TMPDIR}/single.sql

# Check that there is nothing wrong before taking a backup
echo "Checking that there are no missing dimension slices"
docker_pgscript ${CONTAINER_UPDATED} /src/test/sql/updates/setup.check.sql

echo "Executing setup script on clean"
docker_pgscript ${CONTAINER_CLEAN_RERUN} /src/test/sql/updates/setup.${TEST_VERSION}.sql
if [[ "${TEST_VERSION}" > "v6" ]] || [[ "${TEST_VERSION}" = "v6" ]]; then
if [[ "${TEST_REPAIR}" = "true" ]]; then
# We need to run the post repair script to make sure that the
# constraint is on the clean rerun as well since the setup
# script can remove it.
echo "Executing post update repair script on clean"
docker_pgscript ${CONTAINER_CLEAN_RERUN} /src/test/sql/updates/post.repair.sql
fi
fi

echo "Testing updated vs clean"
docker_pgdiff ${CONTAINER_UPDATED} ${CONTAINER_CLEAN_RERUN} /src/test/sql/updates/test-rerun.sql
Expand All @@ -167,7 +190,7 @@ docker cp ${TEST_TMPDIR}/single.sql ${CONTAINER_CLEAN_RESTORE}:/tmp/single.sql
docker_exec ${CONTAINER_CLEAN_RESTORE} "createdb -h localhost -U postgres single"
docker_pgcmd ${CONTAINER_CLEAN_RESTORE} "ALTER DATABASE single SET timescaledb.restoring='on'"
docker_exec ${CONTAINER_CLEAN_RESTORE} "pg_restore -h localhost -U postgres -d single /tmp/single.sql"
docker_pgcmd ${CONTAINER_CLEAN_RESTORE} "ALTER DATABASE single SET timescaledb.restoring='off'"
docker_pgcmd ${CONTAINER_CLEAN_RESTORE} "ALTER DATABASE single RESET timescaledb.restoring"

echo "Testing restored"
echo "Comparing upgraded ($UPDATE_FROM_TAG -> $UPDATE_TO_TAG) with clean install ($UPDATE_TO_TAG)"
docker_pgdiff ${CONTAINER_UPDATED} ${CONTAINER_CLEAN_RESTORE} /src/test/sql/updates/post.${TEST_VERSION}.sql
11 changes: 9 additions & 2 deletions scripts/test_updates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ PG_VERSION=${PG_VERSION:-9.6.5} # Need 9.6.x version since we are
# upgrading the extension from
# versions that didn't support PG10.

# This will propagate to the test_update_from_tags.sh script
export TEST_REPAIR

FAILED_TEST=
KEEP_TEMP_DIRS=false
TEST_UPDATE_FROM_TAGS_EXTRA_ARGS=

TEST_REPAIR=false
FAIL_COUNT=0

# Declare a hash table to keep test names keyed by pid
declare -A tests

while getopts "cd" opt;
while getopts "cdr" opt;
do
case $opt in
c)
Expand All @@ -36,6 +39,10 @@ do
KEEP_TEMP_DIRS=true
TEST_UPDATE_FROM_TAGS_EXTRA_ARGS="-d"
;;
r)
echo "Breaking dimension slices to test repair part"
TEST_REPAIR=true
;;
esac
done

Expand Down
8 changes: 4 additions & 4 deletions scripts/test_updates_pg10.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SCRIPT_DIR=$(dirname $0)
TAGS="0.7.0-pg10 0.7.1-pg10 0.8.0-pg10 0.9.0-pg10 0.9.1-pg10 0.9.2-pg10 0.10.0-pg10 0.10.1-pg10 0.11.0-pg10 0.12.0-pg10 1.0.0-pg10 1.0.1-pg10 1.1.0-pg10 1.1.1-pg10 1.2.0-pg10 1.2.1-pg10 1.2.2-pg10"
TEST_VERSION="v2"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -18,7 +18,7 @@ fi
TAGS="1.3.0-pg10 1.3.1-pg10 1.3.2-pg10 1.4.0-pg10 1.4.1-pg10 1.4.2-pg10"
TEST_VERSION="v3"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -27,7 +27,7 @@ fi
TAGS="1.5.0-pg10 1.5.1-pg10 1.6.0-pg10 1.6.1-pg10"
TEST_VERSION="v5-pg10"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -36,7 +36,7 @@ fi
TAGS="1.7.0-pg10 1.7.1-pg10 1.7.2-pg10"
TEST_VERSION="v6-pg10"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand Down
8 changes: 4 additions & 4 deletions scripts/test_updates_pg11.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SCRIPT_DIR=$(dirname $0)
TAGS="1.1.0-pg11 1.1.1-pg11 1.2.0-pg11 1.2.1-pg11 1.2.2-pg11"
TEST_VERSION="v2"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -18,7 +18,7 @@ fi
TAGS="1.3.0-pg11 1.3.1-pg11 1.3.2-pg11 1.4.0-pg11 1.4.1-pg11 1.4.2-pg11"
TEST_VERSION="v4"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -27,7 +27,7 @@ fi
TAGS="1.5.0-pg11 1.5.1-pg11 1.6.0-pg11 1.6.1-pg11"
TEST_VERSION="v5-pg11"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -36,7 +36,7 @@ fi
TAGS="1.7.0-pg11 1.7.1-pg11 1.7.2-pg11 1.7.3-pg11 1.7.4-pg11"
TEST_VERSION="v6-pg11"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_updates_pg12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SCRIPT_DIR=$(dirname $0)
TAGS="1.7.0-pg12 1.7.1-pg12 1.7.2-pg12 1.7.3-pg12 1.7.4-pg12"
TEST_VERSION="v6-pg12"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand Down
8 changes: 4 additions & 4 deletions scripts/test_updates_pg96.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SCRIPT_DIR=$(dirname $0)
TAGS="0.1.0 0.2.0 0.3.0 0.4.0 0.4.1 0.4.2"
TEST_VERSION="v1"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -26,7 +26,7 @@ fi
TAGS="0.5.0 0.6.0 0.6.1 0.7.0-pg9.6 0.7.1-pg9.6 0.8.0-pg9.6 0.9.0-pg9.6 0.9.1-pg9.6 0.9.2-pg9.6 0.10.0-pg9.6 0.10.1-pg9.6 0.11.0-pg9.6 0.12.0-pg9.6 1.0.0-pg9.6 1.0.1-pg9.6 1.1.0-pg9.6 1.1.1-pg9.6 1.2.0-pg9.6 1.2.1-pg9.6 1.2.2-pg9.6"
TEST_VERSION="v2"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -35,7 +35,7 @@ fi
TAGS="1.3.0-pg9.6 1.3.1-pg9.6 1.3.2-pg9.6 1.4.0-pg9.6 1.4.1-pg9.6 1.4.2-pg9.6 1.5.0-pg9.6 1.5.1-pg9.6 1.6.0-pg9.6 1.6.1-pg9.6"
TEST_VERSION="v3"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand All @@ -44,7 +44,7 @@ fi
TAGS="1.7.0-pg9.6 1.7.1-pg9.6 1.7.2-pg9.6"
TEST_VERSION="v6-pg96"

TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh
TAGS=$TAGS TEST_VERSION=$TEST_VERSION bash ${SCRIPT_DIR}/test_updates.sh "$@"
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
exit $EXIT_CODE
Expand Down
Loading