Skip to content

Commit 2ad9fc5

Browse files
a-masterovwinter-loo
authored andcommitted
Add a test for GrapgQL (neondatabase#10156)
## Problem We currently don't run the tests shipped with `pg_graphql`. ## Summary of changes The tests for `pg_graphql` are added.
1 parent 21e9dce commit 2ad9fc5

File tree

5 files changed

+48
-10
lines changed

5 files changed

+48
-10
lines changed

compute/compute-node.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,8 @@ COPY --from=vector-pg-build /pgvector.patch /ext-src/
13301330
COPY --from=pgjwt-pg-build /pgjwt.tar.gz /ext-src
13311331
#COPY --from=pgrag-pg-build /usr/local/pgsql/ /usr/local/pgsql/
13321332
#COPY --from=pg-jsonschema-pg-build /home/nonroot/pg_jsonschema.tar.gz /ext-src
1333-
#COPY --from=pg-graphql-pg-build /home/nonroot/pg_graphql.tar.gz /ext-src
1333+
COPY --from=pg-graphql-pg-build /home/nonroot/pg_graphql.tar.gz /ext-src
1334+
COPY compute/patches/pg_graphql.patch /ext-src
13341335
#COPY --from=pg-tiktoken-pg-build /home/nonroot/pg_tiktoken.tar.gz /ext-src
13351336
COPY --from=hypopg-pg-build /hypopg.tar.gz /ext-src
13361337
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
13641365
RUN cd /ext-src/pg_hint_plan-src && patch -p1 < /ext-src/pg_hint_plan_${PG_VERSION}.patch
13651366
COPY --chmod=755 docker-compose/run-tests.sh /run-tests.sh
13661367
RUN patch -p1 </ext-src/pg_cron.patch
1368+
RUN cd /ext-src/pg_graphql-src && patch -p1 </ext-src/pg_graphql.patch
13671369
ENV PATH=/usr/local/pgsql/bin:$PATH
13681370
ENV PGHOST=compute
13691371
ENV PGPORT=55433

compute/patches/pg_graphql.patch

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
commit ec6a491d126882966a696f9ad5d3698935361d55
2+
Author: Alexey Masterov <[email protected]>
3+
Date: Tue Dec 17 10:25:00 2024 +0100
4+
5+
Changes required to run tests on Neon
6+
7+
diff --git a/test/expected/permissions_functions.out b/test/expected/permissions_functions.out
8+
index 1e9fbc2..94cbe25 100644
9+
--- a/test/expected/permissions_functions.out
10+
+++ b/test/expected/permissions_functions.out
11+
@@ -64,7 +64,7 @@ begin;
12+
select current_user;
13+
current_user
14+
--------------
15+
- postgres
16+
+ cloud_admin
17+
(1 row)
18+
19+
-- revoke default access from the public role for new functions

docker-compose/docker_compose_test.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ for pg_version in ${TEST_VERSION_ONLY-14 15 16 17}; do
3131
echo "clean up containers if exists"
3232
cleanup
3333
PG_TEST_VERSION=$((pg_version < 16 ? 16 : pg_version))
34-
PG_VERSION=$pg_version PG_TEST_VERSION=$PG_TEST_VERSION docker compose --profile test-extensions -f $COMPOSE_FILE up --build -d
34+
PG_VERSION=$pg_version PG_TEST_VERSION=$PG_TEST_VERSION docker compose --profile test-extensions -f $COMPOSE_FILE up --quiet-pull --build -d
3535

3636
echo "wait until the compute is ready. timeout after 60s. "
3737
cnt=0
@@ -51,6 +51,7 @@ for pg_version in ${TEST_VERSION_ONLY-14 15 16 17}; do
5151
done
5252

5353
if [ $pg_version -ge 16 ]; then
54+
docker cp ext-src $TEST_CONTAINER_NAME:/
5455
# This is required for the pg_hint_plan test, to prevent flaky log message causing the test to fail
5556
# It cannot be moved to Dockerfile now because the database directory is created after the start of the container
5657
echo Adding dummy config
@@ -61,7 +62,7 @@ for pg_version in ${TEST_VERSION_ONLY-14 15 16 17}; do
6162
docker cp $TMPDIR/data $COMPUTE_CONTAINER_NAME:/ext-src/pg_hint_plan-src/
6263
rm -rf $TMPDIR
6364
# We are running tests now
64-
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 \
65+
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 \
6566
$TEST_CONTAINER_NAME /run-tests.sh | tee testout.txt
6667
then
6768
FAILED=$(tail -1 testout.txt)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -ex
3+
cd "$(dirname "${0}")"
4+
dropdb --if-exists contrib_regression
5+
createdb contrib_regression
6+
PGXS="$(dirname "$(pg_config --pgxs)" )"
7+
REGRESS="${PGXS}/../test/regress/pg_regress"
8+
TESTDIR="test"
9+
TESTS=$(ls "${TESTDIR}/sql" | sort )
10+
TESTS=${TESTS//\.sql/}
11+
psql -v ON_ERROR_STOP=1 -f test/fixtures.sql -d contrib_regression
12+
${REGRESS} --use-existing --dbname=contrib_regression --inputdir=${TESTDIR} ${TESTS}
13+

docker-compose/run-tests.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ set -x
44
cd /ext-src || exit 2
55
FAILED=
66
LIST=$( (echo -e "${SKIP//","/"\n"}"; ls -d -- *-src) | sort | uniq -u)
7-
for d in ${LIST}
8-
do
9-
[ -d "${d}" ] || continue
10-
if ! psql -w -c "select 1" >/dev/null; then
11-
FAILED="${d} ${FAILED}"
12-
break
13-
fi
7+
for d in ${LIST}; do
8+
[ -d "${d}" ] || continue
9+
if ! psql -w -c "select 1" >/dev/null; then
10+
FAILED="${d} ${FAILED}"
11+
break
12+
fi
13+
if [ -f "${d}/neon-test.sh" ]; then
14+
"${d}/neon-test.sh" || FAILED="${d} ${FAILED}"
15+
else
1416
USE_PGXS=1 make -C "${d}" installcheck || FAILED="${d} ${FAILED}"
17+
fi
1518
done
1619
[ -z "${FAILED}" ] && exit 0
1720
echo "${FAILED}"

0 commit comments

Comments
 (0)