From b2918e58fefb52475a83af3fbcc8f56337e38c2d Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Tue, 5 Nov 2019 11:19:00 +0100 Subject: [PATCH] Fix permission issue in test_sanitizer The `test_sanitizer.sh` test failed because source code was being copied from the host to the container as user `postgres` and this user did not have read permissions on the mounted directory. This is fixed by copying the files as `root` and then changing the owner to `postgres`. The commit also removes `wait_for_pg` since PostgreSQL server status is not relevant for the tests since they start their own temporary instance. The commit also switches to use here-is documents for the execution for readability purposes. --- scripts/test_sanitizers.sh | 64 ++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/scripts/test_sanitizers.sh b/scripts/test_sanitizers.sh index 30604ee4a..ab2295863 100755 --- a/scripts/test_sanitizers.sh +++ b/scripts/test_sanitizers.sh @@ -60,51 +60,41 @@ docker_exec() { docker exec -it $1 /bin/bash -c "$2" } -wait_for_pg() { - set +e - for i in {1..30}; do - sleep 2 - - docker_exec $1 "pg_isready -U postgres" - - if [[ $? == 0 ]] ; then - # this makes the test less flaky, although not - # ideal. Apperently, pg_isready is not always a good - # indication of whether the DB is actually ready to accept - # queries - sleep 1 - set -e - return 0 - fi - done - exit 1 -} - - docker rm -f timescaledb-san 2>/dev/null || true docker run -d --privileged --name timescaledb-san -v ${TIMESCALE_DIR}:/timescaledb ${REMOTE_ORG}/${REMOTE_NAME}:${REMOTE_TAG} -docker exec timescaledb-san /bin/bash -c "mkdir /tsdb_build && chown postgres /tsdb_build" +# Run these commands as root to copy the source into the +# container. Make sure that all files in the copy is owned by user +# 'postgres', which we use to run tests below. +docker exec -i timescaledb-san /bin/bash -Oe <&2 echo -e "\033[1m$1\033[0m: $2" -docker exec -u postgres \ - timescaledb-san /bin/bash -c \ - "cd /tsdb_build/timescaledb/build \ - && PATH=\$PATH make -k regresscheck regresscheck-t \ - IGNORES='bgw_db_scheduler bgw_launcher continuous_aggs_ddl-11'" + +# Run tests as 'postgres' user +docker exec -i -u postgres -w /tsdb_build/timescaledb/build timescaledb-san /bin/bash <