mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-16 02:23:49 +08:00
In order to implement repair tests, changes are made to the `constraint_check` table to simulate a broken dependency, which requires the constraints on that table to be dropped. This means that the repair runs without constraints, and a bug in the update test could potentially not get caught. This commit fixes this by factoring out the repair tests from the update tests and run them as a separate pass. This means that the contraints are not dropped in the update tests and bugs there will be caught. In addition, some bash functions are factored out into a separate file to avoid duplication.
48 lines
1.5 KiB
Bash
48 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
set -o pipefail
|
|
|
|
SCRIPT_DIR=$(dirname $0)
|
|
GIT_ID=$(git -C ${BASE_DIR} describe --dirty --always | sed -e "s|/|_|g")
|
|
TEST_TMPDIR=${TEST_TMPDIR:-$(mktemp -d 2>/dev/null || mktemp -d -t 'timescaledb_repair_test' || mkdir -p /tmp/${RANDOM})}
|
|
UPDATE_TO_IMAGE=${UPDATE_TO_IMAGE:-repair_test}
|
|
UPDATE_TO_TAG=${UPDATE_TO_TAG:-${GIT_ID}}
|
|
|
|
# Build the docker image with current source here so that the parallel
|
|
# tests don't all compete in trying to build it first
|
|
IMAGE_NAME=${UPDATE_TO_IMAGE} TAG_NAME=${UPDATE_TO_TAG} PG_VERSION=${PG_VERSION} bash ${SCRIPT_DIR}/docker-build.sh
|
|
|
|
# Run repair tests in parallel
|
|
declare -A tests
|
|
for tag in ${TAGS}; do
|
|
UPDATE_FROM_TAG=${tag} TEST_VERSION=${TEST_VERSION} bash $SCRIPT_DIR/test_repair_from_tag.sh ${TEST_UPDATE_FROM_TAGS_EXTRA_ARGS} > ${TEST_TMPDIR}/${tag}.log 2>&1 &
|
|
|
|
tests[$!]=${tag}
|
|
echo "Launched test ${tag} with pid $!"
|
|
done
|
|
|
|
# Need to wait on each pid in a loop to return the exit status of each
|
|
for pid in ${!tests[@]}; do
|
|
echo "Waiting for test pid $pid"
|
|
wait $pid
|
|
exit_code=$?
|
|
echo "Test ${tests[$pid]} (pid $pid) exited with code $exit_code"
|
|
|
|
if [ $exit_code -ne 0 ]; then
|
|
FAIL_COUNT=$((FAIL_COUNT + 1))
|
|
FAILED_TEST=${tests[$pid]}
|
|
if [ -f ${TEST_TMPDIR}/${FAILED_TEST}.log ]; then
|
|
echo "###### Failed test log below #####"
|
|
cat ${TEST_TMPDIR}/${FAILED_TEST}.log
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [ "$KEEP_TEMP_DIRS" = "false" ]; then
|
|
echo "Cleaning up temporary directory"
|
|
rm -rf ${TEST_TMPDIR}
|
|
fi
|
|
|
|
exit $FAIL_COUNT
|
|
|