Skip to content

Commit

Permalink
Add the test to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
a-masterov committed Jan 10, 2025
1 parent 2c34662 commit 0bbe722
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,18 @@ jobs:
TEST_VERSION_ONLY: ${{ matrix.pg_version }}
run: ./docker-compose/docker_compose_test.sh

- name: Get the prevous staging build tag
id: oldtag
run: echo oldtag=$(git rev-list --count main) >>$GITHUB_OUTPUT

- name: Test extension upgrade
timeout-minutes: 20
if: ${{ needs.tag.outputs.build-tag == github.run_id }}
env:
NEWTAG: ${{ needs.tag.outputs.build-tag }}
OLDTAG: ${{ steps.oldtag.outputs.oldtag }}
run: ./docker-compose/test_extensions_upgrade.sh

- name: Print logs and clean up
if: always()
run: |
Expand Down
1 change: 1 addition & 0 deletions compute/compute-node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ RUN case "${PG_VERSION}" in "v17") \
echo "postgresql_anonymizer does not yet support PG17" && exit 0;; \
esac && patch -p1 </ext-src/pg_anon.patch
RUN patch -p1 </ext-src/pg_cron.patch
COPY docker-compose/ext-src /
ENV PATH=/usr/local/pgsql/bin:$PATH
ENV PGHOST=compute
ENV PGPORT=55433
Expand Down
23 changes: 8 additions & 15 deletions docker-compose/test_extensions_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ generate_id() {
local -n resvar=$1
printf -v resvar '%08x%08x%08x%08x' $SRANDOM $SRANDOM $SRANDOM $SRANDOM
}
TENANT_ID_FILE="$(dirname ${0})/compute_wrapper/var/db/postgres/specs/tenant_id"
TIMELINE_ID_FILE="$(dirname ${0})/compute_wrapper/var/db/postgres/specs/timeline_id"
rm -f "${TENANT_ID_FILE}" "${TIMELINE_ID_FILE}"
if [ -z ${OLDTAG+x} ] || [ -z ${NEWTAG+x} ] || [ -z "${OLDTAG}" ] || [ -z "${NEWTAG}" ]; then
echo OLDTAG and NEWTAG must be defined
exit 1
Expand All @@ -18,11 +15,16 @@ export PGPASSWORD=cloud_admin
export PGHOST=127.0.0.1
export PGPORT=55433
export PGDATABASE=postgres
docker volume prune -f
function wait_for_ready {
while ! docker compose logs compute_is_ready | grep -q "accepting connections"; do
TIME=0
while ! docker compose logs compute_is_ready | grep -q "accepting connections" && [ ${TIME} -le 300 ] ; do
((TIME += 1 ))
sleep 1
done
if [ ${TIME} -gt 300 ]; then
echo Time is out.
exit 2
fi
}
function create_extensions() {
for ext in ${1}; do
Expand Down Expand Up @@ -50,7 +52,6 @@ wait_for_ready
create_extensions "${EXTNAMES}"
query="select json_object_agg(extname,extversion) from pg_extension where extname in ('${EXTNAMES// /\',\'}')"
new_vers=$(psql -Aqt -c "$query" )
echo $new_vers
docker compose down
TAG=${OLDTAG} docker compose --profile test-extensions up --build -d --force-recreate
wait_for_ready
Expand All @@ -66,8 +67,7 @@ if [ -z "${exts}" ]; then
else
tenant_id=$(psql -Aqt -c "SHOW neon.tenant_id")
timeline_id=$(psql -Aqt -c "SHOW neon.timeline_id")
#XXX for ext in ${exts}; do
for ext in ${EXTNAMES}; do
for ext in ${exts}; do
echo Testing ${ext}...
EXTDIR=$(echo ${EXTENSIONS} | jq -r '.[] | select(.extname=="'${ext}'") | .extdir')
generate_id new_timeline_id
Expand All @@ -88,13 +88,6 @@ else
echo Timeline mismatch
exit 1
fi
if [ ${ext} == "pg_hintplan" ]; then
TMPDIR=$(mktemp -d)
# The following block does the same for the pg_hintplan test
docker compose cp neon-test-extensions:/ext-src/pg_hint_plan-src/data $TMPDIR/data
docker compose cp $TMPDIR/data compute:/ext-src/pg_hint_plan-src/
rm -rf $TMPDIR
fi
psql -d contrib_regression -c "\dx ${ext}"
docker compose exec -e PGPASSWORD=cloud_admin neon-test-extensions sh -c /ext-src/${EXTDIR}/test-upgrade.sh
psql -d contrib_regression -c "alter extension ${ext} update"
Expand Down

0 comments on commit 0bbe722

Please sign in to comment.