From 34d9e2d8e33ba9afe1a7f68241fe84a9055a4754 Mon Sep 17 00:00:00 2001 From: a-masterov <72613290+a-masterov@users.noreply.github.com> Date: Wed, 29 Jan 2025 16:01:56 +0100 Subject: [PATCH] Add a test for GrapgQL (#10156) ## Problem We currently don't run the tests shipped with `pg_graphql`. ## Summary of changes The tests for `pg_graphql` are added. --- compute/compute-node.Dockerfile | 4 +++- compute/patches/pg_graphql.patch | 19 +++++++++++++++++++ docker-compose/docker_compose_test.sh | 5 +++-- .../ext-src/pg_graphql-src/neon-test.sh | 13 +++++++++++++ docker-compose/run-tests.sh | 17 ++++++++++------- 5 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 compute/patches/pg_graphql.patch create mode 100755 docker-compose/ext-src/pg_graphql-src/neon-test.sh diff --git a/compute/compute-node.Dockerfile b/compute/compute-node.Dockerfile index 539135470e..9d7aeda590 100644 --- a/compute/compute-node.Dockerfile +++ b/compute/compute-node.Dockerfile @@ -1330,7 +1330,8 @@ COPY --from=vector-pg-build /pgvector.patch /ext-src/ COPY --from=pgjwt-pg-build /pgjwt.tar.gz /ext-src #COPY --from=pgrag-pg-build /usr/local/pgsql/ /usr/local/pgsql/ #COPY --from=pg-jsonschema-pg-build /home/nonroot/pg_jsonschema.tar.gz /ext-src -#COPY --from=pg-graphql-pg-build /home/nonroot/pg_graphql.tar.gz /ext-src +COPY --from=pg-graphql-pg-build /home/nonroot/pg_graphql.tar.gz /ext-src +COPY compute/patches/pg_graphql.patch /ext-src #COPY --from=pg-tiktoken-pg-build /home/nonroot/pg_tiktoken.tar.gz /ext-src COPY --from=hypopg-pg-build /hypopg.tar.gz /ext-src COPY --from=pg-hashids-pg-build /pg_hashids.tar.gz /ext-src @@ -1364,6 +1365,7 @@ RUN cd /ext-src/pgvector-src && patch -p1 <../pgvector.patch RUN cd /ext-src/pg_hint_plan-src && patch -p1 < /ext-src/pg_hint_plan_${PG_VERSION}.patch COPY --chmod=755 docker-compose/run-tests.sh /run-tests.sh RUN patch -p1 +Date: Tue Dec 17 10:25:00 2024 +0100 + + Changes required to run tests on Neon + +diff --git a/test/expected/permissions_functions.out b/test/expected/permissions_functions.out +index 1e9fbc2..94cbe25 100644 +--- a/test/expected/permissions_functions.out ++++ b/test/expected/permissions_functions.out +@@ -64,7 +64,7 @@ begin; + select current_user; + current_user + -------------- +- postgres ++ cloud_admin + (1 row) + + -- revoke default access from the public role for new functions diff --git a/docker-compose/docker_compose_test.sh b/docker-compose/docker_compose_test.sh index f42aca673b..a05d6c043d 100755 --- a/docker-compose/docker_compose_test.sh +++ b/docker-compose/docker_compose_test.sh @@ -31,7 +31,7 @@ for pg_version in ${TEST_VERSION_ONLY-14 15 16 17}; do echo "clean up containers if exists" cleanup PG_TEST_VERSION=$((pg_version < 16 ? 16 : pg_version)) - PG_VERSION=$pg_version PG_TEST_VERSION=$PG_TEST_VERSION docker compose --profile test-extensions -f $COMPOSE_FILE up --build -d + PG_VERSION=$pg_version PG_TEST_VERSION=$PG_TEST_VERSION docker compose --profile test-extensions -f $COMPOSE_FILE up --quiet-pull --build -d echo "wait until the compute is ready. timeout after 60s. " cnt=0 @@ -51,6 +51,7 @@ for pg_version in ${TEST_VERSION_ONLY-14 15 16 17}; do done if [ $pg_version -ge 16 ]; then + docker cp ext-src $TEST_CONTAINER_NAME:/ # This is required for the pg_hint_plan test, to prevent flaky log message causing the test to fail # It cannot be moved to Dockerfile now because the database directory is created after the start of the container echo Adding dummy config @@ -61,7 +62,7 @@ for pg_version in ${TEST_VERSION_ONLY-14 15 16 17}; do docker cp $TMPDIR/data $COMPUTE_CONTAINER_NAME:/ext-src/pg_hint_plan-src/ rm -rf $TMPDIR # We are running tests now - if ! docker exec -e SKIP=timescaledb-src,rdkit-src,postgis-src,pgx_ulid-src,pgtap-src,pg_tiktoken-src,pg_jsonschema-src,pg_graphql-src,kq_imcx-src,wal2json_2_5-src \ + if ! docker exec -e SKIP=timescaledb-src,rdkit-src,postgis-src,pgx_ulid-src,pgtap-src,pg_tiktoken-src,pg_jsonschema-src,kq_imcx-src,wal2json_2_5-src \ $TEST_CONTAINER_NAME /run-tests.sh | tee testout.txt then FAILED=$(tail -1 testout.txt) diff --git a/docker-compose/ext-src/pg_graphql-src/neon-test.sh b/docker-compose/ext-src/pg_graphql-src/neon-test.sh new file mode 100755 index 0000000000..38bcb4bfb6 --- /dev/null +++ b/docker-compose/ext-src/pg_graphql-src/neon-test.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -ex +cd "$(dirname "${0}")" +dropdb --if-exists contrib_regression +createdb contrib_regression +PGXS="$(dirname "$(pg_config --pgxs)" )" +REGRESS="${PGXS}/../test/regress/pg_regress" +TESTDIR="test" +TESTS=$(ls "${TESTDIR}/sql" | sort ) +TESTS=${TESTS//\.sql/} +psql -v ON_ERROR_STOP=1 -f test/fixtures.sql -d contrib_regression +${REGRESS} --use-existing --dbname=contrib_regression --inputdir=${TESTDIR} ${TESTS} + diff --git a/docker-compose/run-tests.sh b/docker-compose/run-tests.sh index 9873187b62..1e794a42a1 100644 --- a/docker-compose/run-tests.sh +++ b/docker-compose/run-tests.sh @@ -4,14 +4,17 @@ set -x cd /ext-src || exit 2 FAILED= LIST=$( (echo -e "${SKIP//","/"\n"}"; ls -d -- *-src) | sort | uniq -u) -for d in ${LIST} -do - [ -d "${d}" ] || continue - if ! psql -w -c "select 1" >/dev/null; then - FAILED="${d} ${FAILED}" - break - fi +for d in ${LIST}; do + [ -d "${d}" ] || continue + if ! psql -w -c "select 1" >/dev/null; then + FAILED="${d} ${FAILED}" + break + fi + if [ -f "${d}/neon-test.sh" ]; then + "${d}/neon-test.sh" || FAILED="${d} ${FAILED}" + else USE_PGXS=1 make -C "${d}" installcheck || FAILED="${d} ${FAILED}" + fi done [ -z "${FAILED}" ] && exit 0 echo "${FAILED}"