Skip to content

Commit

Permalink
Add a concept for the test for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
a-masterov committed Jan 6, 2025
1 parent 0ea62c7 commit 70db6fe
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 55 deletions.
1 change: 1 addition & 0 deletions compute/compute-node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,7 @@ ENV PATH=/usr/local/pgsql/bin:$PATH
ENV PGHOST=compute
ENV PGPORT=55433
ENV PGUSER=cloud_admin
ENV PGPASSWORD=cloud_admin
ENV PGDATABASE=postgres
#########################################################################################
#
Expand Down
55 changes: 0 additions & 55 deletions docker-compose/collect_versions.sh

This file was deleted.

4 changes: 4 additions & 0 deletions docker-compose/ext-src/pgvector-src/test-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -ex
cd "$(dirname ${0})"
/usr/local/pgsql/lib/pgxs/src/makefiles/../../src/test/regress/pg_regress --inputdir=./ --bindir='/usr/local/pgsql/bin' --inputdir=test --use-existing --dbname=contrib_regression bit btree cast copy halfvec hnsw_bit hnsw_halfvec hnsw_sparsevec hnsw_vector ivfflat_bit ivfflat_halfvec ivfflat_vector sparsevec vector_type
4 changes: 4 additions & 0 deletions docker-compose/ext-src/plv8-src/test-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -ex
cd "$(dirname ${0})"
/usr/local/pgsql/lib/pgxs/src/makefiles/../../src/test/regress/pg_regress --inputdir=./ --bindir='/usr/local/pgsql/bin' --use-existing --dbname=contrib_regression plv8 plv8-errors scalar_args inline json startup_pre startup varparam json_conv jsonb_conv window guc es6 arraybuffer composites currentresource startup_perms bytea find_function_perms memory_limits reset show array_spread regression dialect bigint procedure
4 changes: 4 additions & 0 deletions docker-compose/ext-src/postgresql-unit-src/test-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -ex
cd "$(dirname ${0})"
/usr/local/pgsql/lib/pgxs/src/makefiles/../../src/test/regress/pg_regress --inputdir=./ --bindir='/usr/local/pgsql/bin' --use-existing --dbname=contrib_regression extension tables unit binary unicode prefix units time temperature functions language_functions round derived compare aggregate iec custom crosstab convert
64 changes: 64 additions & 0 deletions docker-compose/test_extensions_upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash
set -eux -o pipefail
if [ -z ${OLDTAG+x} ] || [ -z ${NEWTAG+x} ] || [ -z "${OLDTAG}" ] || [ -z "${NEWTAG}" ]; then
echo OLDTAG and NEWTAG must be defined
exit 1
fi
export PGUSER=cloud_admin
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
sleep 1
done
}
function create_extensions() {
for ext in ${1}; do
echo "CREATE EXTENSION IF NOT EXISTS ${ext};"
done | psql -X -v ON_ERROR_STOP=1
}
EXTENSIONS='[
{"extname": "plv8", "extdir": "plv8-src"},
{"extname": "vector", "extdir": "pgvector-src"},
{"extname": "unit", "extdir": "postgresql-unit-src"}
]'
EXTNAMES=$(echo ${EXTENSIONS} | jq -r '.[].extname' | paste -sd ' ' -)
TAG=${NEWTAG} docker compose up --build -d
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
# XXX this is about to be included into the image, for test only
docker compose cp ext-src neon-test-extensions:/
for ext in $EXTNAMES; do
echo "CREATE EXTENSION IF NOT EXISTS ${ext};"
done | psql -X -v ON_ERROR_STOP=1
query="select pge.extname from pg_extension pge join (select key as extname, value as extversion from json_each_text('${new_vers}')) x on pge.extname=x.extname and pge.extversion <> x.extversion"
echo $query
exts=$(psql -Aqt -c "$query")
if [ -z "${exts}" ]; then
echo "No extensions were upgraded"
else
psql -c "CREATE DATABASE contrib_regression"
export PGDATABASE=contrib_regression
create_extensions "${exts}"
TAG=${OLDTAG} docker compose down compute compute_is_ready
COMPUTE_TAG=${NEWTAG} TAG=${OLDTAG} docker compose up -d --build compute compute_is_ready
wait_for_ready
for ext in ${exts}; do
echo Testing ${ext}...
EXTDIR=$(echo ${EXTENSIONS} | jq -r '.[] | select(.extname=="'${ext}'") | .extdir')
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"
psql -d contrib_regression -c "\dx ${ext}"
done
fi
docker compose --profile test-extensions down

0 comments on commit 70db6fe

Please sign in to comment.