Skip to content

Commit 93e9272

Browse files
committed
fix: restore tap tests
1 parent c151370 commit 93e9272

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed

nix/checks.nix

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -168,80 +168,80 @@
168168
''
169169
set -e
170170
171-
# #First we need to create a generic pg cluster for pgtap tests and run those
172-
# export GRN_PLUGINS_DIR=${pkgs.supabase-groonga}/lib/groonga/plugins
173-
# PGTAP_CLUSTER=$(mktemp -d)
174-
# initdb --locale=C --username=supabase_admin -D "$PGTAP_CLUSTER"
175-
# substitute ${./tests/postgresql.conf.in} "$PGTAP_CLUSTER"/postgresql.conf \
176-
# --subst-var-by PGSODIUM_GETKEY_SCRIPT "${getkey-script}/bin/pgsodium-getkey"
177-
# echo "listen_addresses = '*'" >> "$PGTAP_CLUSTER"/postgresql.conf
178-
# echo "port = ${pgPort}" >> "$PGTAP_CLUSTER"/postgresql.conf
179-
# echo "host all all 127.0.0.1/32 trust" >> $PGTAP_CLUSTER/pg_hba.conf
180-
# echo "Checking shared_preload_libraries setting:"
181-
# grep -rn "shared_preload_libraries" "$PGTAP_CLUSTER"/postgresql.conf
182-
# # Remove timescaledb if running orioledb-17 check
183-
# echo "I AM ${pgpkg.version}===================================================="
184-
# if [[ "${pgpkg.version}" == *"17"* ]]; then
185-
# perl -pi -e 's/ timescaledb,//g' "$PGTAP_CLUSTER/postgresql.conf"
186-
# fi
187-
# #NOTE in the future we may also need to add the orioledb extension to the cluster when cluster is oriole
188-
# echo "PGTAP_CLUSTER directory contents:"
189-
# ls -la "$PGTAP_CLUSTER"
171+
#First we need to create a generic pg cluster for pgtap tests and run those
172+
export GRN_PLUGINS_DIR=${pkgs.supabase-groonga}/lib/groonga/plugins
173+
PGTAP_CLUSTER=$(mktemp -d)
174+
initdb --locale=C --username=supabase_admin -D "$PGTAP_CLUSTER"
175+
substitute ${./tests/postgresql.conf.in} "$PGTAP_CLUSTER"/postgresql.conf \
176+
--subst-var-by PGSODIUM_GETKEY_SCRIPT "${getkey-script}/bin/pgsodium-getkey"
177+
echo "listen_addresses = '*'" >> "$PGTAP_CLUSTER"/postgresql.conf
178+
echo "port = ${pgPort}" >> "$PGTAP_CLUSTER"/postgresql.conf
179+
echo "host all all 127.0.0.1/32 trust" >> $PGTAP_CLUSTER/pg_hba.conf
180+
echo "Checking shared_preload_libraries setting:"
181+
grep -rn "shared_preload_libraries" "$PGTAP_CLUSTER"/postgresql.conf
182+
# Remove timescaledb if running orioledb-17 check
183+
echo "I AM ${pgpkg.version}===================================================="
184+
if [[ "${pgpkg.version}" == *"17"* ]]; then
185+
perl -pi -e 's/ timescaledb,//g' "$PGTAP_CLUSTER/postgresql.conf"
186+
fi
187+
#NOTE in the future we may also need to add the orioledb extension to the cluster when cluster is oriole
188+
echo "PGTAP_CLUSTER directory contents:"
189+
ls -la "$PGTAP_CLUSTER"
190190
191-
# # Check if postgresql.conf exists
192-
# if [ ! -f "$PGTAP_CLUSTER/postgresql.conf" ]; then
193-
# echo "postgresql.conf is missing!"
194-
# exit 1
195-
# fi
191+
# Check if postgresql.conf exists
192+
if [ ! -f "$PGTAP_CLUSTER/postgresql.conf" ]; then
193+
echo "postgresql.conf is missing!"
194+
exit 1
195+
fi
196196
197-
# # PostgreSQL startup
198-
# if [[ "$(uname)" == "Darwin" ]]; then
199-
# pg_ctl -D "$PGTAP_CLUSTER" -l "$PGTAP_CLUSTER"/postgresql.log -o "-k "$PGTAP_CLUSTER" -p ${pgPort} -d 5" start 2>&1
200-
# else
201-
# mkdir -p "$PGTAP_CLUSTER/sockets"
202-
# pg_ctl -D "$PGTAP_CLUSTER" -l "$PGTAP_CLUSTER"/postgresql.log -o "-k $PGTAP_CLUSTER/sockets -p ${pgPort} -d 5" start 2>&1
203-
# fi || {
204-
# echo "pg_ctl failed to start PostgreSQL"
205-
# echo "Contents of postgresql.log:"
206-
# cat "$PGTAP_CLUSTER"/postgresql.log
207-
# exit 1
208-
# }
209-
# for i in {1..60}; do
210-
# if pg_isready -h ${self.supabase.defaults.host} -p ${pgPort}; then
211-
# echo "PostgreSQL is ready"
212-
# break
213-
# fi
214-
# sleep 1
215-
# if [ $i -eq 60 ]; then
216-
# echo "PostgreSQL is not ready after 60 seconds"
217-
# echo "PostgreSQL status:"
218-
# pg_ctl -D "$PGTAP_CLUSTER" status
219-
# echo "PostgreSQL log content:"
220-
# cat "$PGTAP_CLUSTER"/postgresql.log
221-
# exit 1
222-
# fi
223-
# done
224-
# createdb -p ${pgPort} -h ${self.supabase.defaults.host} --username=supabase_admin testing
225-
# if ! psql -p ${pgPort} -h ${self.supabase.defaults.host} --username=supabase_admin -d testing -v ON_ERROR_STOP=1 -Xf ${./tests/prime.sql}; then
226-
# echo "Error executing SQL file. PostgreSQL log content:"
227-
# cat "$PGTAP_CLUSTER"/postgresql.log
228-
# pg_ctl -D "$PGTAP_CLUSTER" stop
229-
# exit 1
230-
# fi
231-
# SORTED_DIR=$(mktemp -d)
232-
# for t in $(printf "%s\n" ${builtins.concatStringsSep " " sortedTestList}); do
233-
# psql -p ${pgPort} -h ${self.supabase.defaults.host} --username=supabase_admin -d testing -f "${./tests/sql}/$t.sql" || true
234-
# done
235-
# rm -rf "$SORTED_DIR"
236-
# pg_ctl -D "$PGTAP_CLUSTER" stop
237-
# rm -rf $PGTAP_CLUSTER
197+
# PostgreSQL startup
198+
if [[ "$(uname)" == "Darwin" ]]; then
199+
pg_ctl -D "$PGTAP_CLUSTER" -l "$PGTAP_CLUSTER"/postgresql.log -o "-k "$PGTAP_CLUSTER" -p ${pgPort} -d 5" start 2>&1
200+
else
201+
mkdir -p "$PGTAP_CLUSTER/sockets"
202+
pg_ctl -D "$PGTAP_CLUSTER" -l "$PGTAP_CLUSTER"/postgresql.log -o "-k $PGTAP_CLUSTER/sockets -p ${pgPort} -d 5" start 2>&1
203+
fi || {
204+
echo "pg_ctl failed to start PostgreSQL"
205+
echo "Contents of postgresql.log:"
206+
cat "$PGTAP_CLUSTER"/postgresql.log
207+
exit 1
208+
}
209+
for i in {1..60}; do
210+
if pg_isready -h ${self.supabase.defaults.host} -p ${pgPort}; then
211+
echo "PostgreSQL is ready"
212+
break
213+
fi
214+
sleep 1
215+
if [ $i -eq 60 ]; then
216+
echo "PostgreSQL is not ready after 60 seconds"
217+
echo "PostgreSQL status:"
218+
pg_ctl -D "$PGTAP_CLUSTER" status
219+
echo "PostgreSQL log content:"
220+
cat "$PGTAP_CLUSTER"/postgresql.log
221+
exit 1
222+
fi
223+
done
224+
createdb -p ${pgPort} -h ${self.supabase.defaults.host} --username=supabase_admin testing
225+
if ! psql -p ${pgPort} -h ${self.supabase.defaults.host} --username=supabase_admin -d testing -v ON_ERROR_STOP=1 -Xf ${./tests/prime.sql}; then
226+
echo "Error executing SQL file. PostgreSQL log content:"
227+
cat "$PGTAP_CLUSTER"/postgresql.log
228+
pg_ctl -D "$PGTAP_CLUSTER" stop
229+
exit 1
230+
fi
231+
SORTED_DIR=$(mktemp -d)
232+
for t in $(printf "%s\n" ${builtins.concatStringsSep " " sortedTestList}); do
233+
psql -p ${pgPort} -h ${self.supabase.defaults.host} --username=supabase_admin -d testing -f "${./tests/sql}/$t.sql" || true
234+
done
235+
rm -rf "$SORTED_DIR"
236+
pg_ctl -D "$PGTAP_CLUSTER" stop
237+
rm -rf $PGTAP_CLUSTER
238238
239-
# # End of pgtap tests
240-
# # from here on out we are running pg_regress tests, we use a different cluster for this
241-
# # which is start by the start-postgres-server-bin script
242-
# # start-postgres-server-bin script closely matches our AMI setup, configurations and migrations
239+
# End of pgtap tests
240+
# from here on out we are running pg_regress tests, we use a different cluster for this
241+
# which is start by the start-postgres-server-bin script
242+
# start-postgres-server-bin script closely matches our AMI setup, configurations and migrations
243243
244-
# unset GRN_PLUGINS_DIR
244+
unset GRN_PLUGINS_DIR
245245
${start-postgres-server-bin}/bin/start-postgres-server ${getVersionArg pgpkg} --daemonize
246246
247247
for i in {1..60}; do

0 commit comments

Comments
 (0)