Skip to content

Commit 1f82f5b

Browse files
authored
Indata 152 run server (#1850)
* fix: refactor tests to work with include_dir approach and be more accurate with production conditions * tests: use distinct savepoint names in test
1 parent 9bba13d commit 1f82f5b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1390
-17223
lines changed

ansible/tasks/setup-postgres.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
with_items:
117117
- '/etc/postgresql'
118118
- '/etc/postgresql-custom'
119+
- '/etc/postgresql-custom/conf.d'
119120
when: debpkg_mode or nixpkg_mode
120121

121122
- name: create placeholder config files

ansible/tasks/setup-wal-g.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
- name: Move custom wal-g.conf file to /etc/postgresql-custom/conf.d/wal-g.conf
6464
copy:
65-
src: "files/postgresql_config/conf.d/walg.conf"
65+
src: "files/postgresql_config/conf.d/wal-g.conf"
6666
dest: /etc/postgresql-custom/conf.d/wal-g.conf
6767
mode: 0664
6868
owner: postgres

migrations/tests/extensions/01-postgis.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ begin;
22
do $_$
33
begin
44
if not exists (select 1 from pg_extension where extname = 'orioledb') then
5+
-- create address_standardizer and dependencies first to ensure correct schema placement
6+
create extension if not exists address_standardizer with schema extensions;
7+
create extension if not exists address_standardizer_data_us with schema extensions;
8+
59
-- create postgis tiger as supabase_admin
610
create extension if not exists postgis_tiger_geocoder cascade;
711

nix/checks.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295
fi
296296
done
297297
298-
if ! psql -p ${pgPort} -h ${self.supabase.defaults.host} --no-password --username=supabase_admin -d postgres -v ON_ERROR_STOP=1 -Xf ${./tests/prime.sql}; then
298+
if ! psql -p ${pgPort} -h ${self.supabase.defaults.host} --no-password --username=supabase_admin -d postgres -v ON_ERROR_STOP=1 -Xf ${./tests/prime-production.sql}; then
299299
echo "Error executing SQL file"
300300
exit 1
301301
fi

nix/packages/lib.nix

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,19 @@
6464
else
6565
"${pkgs.glibcLocales}/lib/locale/locale-archive";
6666

67+
postgresqlConfigBaseDir = builtins.path {
68+
name = "postgresql_config";
69+
path = ../../ansible/files/postgresql_config;
70+
};
71+
6772
substitutions = {
6873
SHELL_PATH = "${pkgs.bash}/bin/bash";
6974
PGSQL_DEFAULT_PORT = "${defaults.port}";
7075
PGSQL_SUPERUSER = "${defaults.superuser}";
7176
PSQL15_BINDIR = "${psql_15}";
7277
PSQL17_BINDIR = "${psql_17}";
7378
PSQL_CONF_FILE = "${paths.pgconfigFile}";
79+
POSTGRESQL_CONFIG_DIR = "${postgresqlConfigBaseDir}";
7480
PSQLORIOLEDB17_BINDIR = "${psql_orioledb-17}";
7581
PGSODIUM_GETKEY = "${paths.getkeyScript}";
7682
PG_HBA = "${paths.pgHbaConfigFile}";
@@ -96,17 +102,7 @@
96102
;
97103
}
98104
''
99-
mkdir -p $out/bin $out/etc/postgresql-custom $out/etc/postgresql $out/extension-custom-scripts
100-
101-
# Copy config files with error handling
102-
cp -r ${paths.configConfDir} $out/etc/postgresql-custom/|| { echo "Failed to copy conf.d"; exit 1; }
103-
cp ${paths.pgconfigFile} $out/etc/postgresql/postgresql.conf || { echo "Failed to copy postgresql.conf"; exit 1; }
104-
cp ${paths.pgHbaConfigFile} $out/etc/postgresql/pg_hba.conf || { echo "Failed to copy pg_hba.conf"; exit 1; }
105-
cp ${paths.pgIdentConfigFile} $out/etc/postgresql/pg_ident.conf || { echo "Failed to copy pg_ident.conf"; exit 1; }
106-
cp -r ${paths.postgresqlExtensionCustomScriptsPath}/* $out/extension-custom-scripts/ || { echo "Failed to copy custom scripts"; exit 1; }
107-
108-
echo "Copy operation completed"
109-
chmod 644 $out/etc/postgresql-custom/conf.d/supautils.conf $out/etc/postgresql/postgresql.conf $out/etc/postgresql-custom/conf.d/logging.conf $out/etc/postgresql/pg_hba.conf
105+
mkdir -p $out/bin
110106
111107
substitute ${../tools/run-server.sh.in} $out/bin/start-postgres-server \
112108
${

nix/tests/expected/evtrigs.out

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
BEGIN;
2+
set client_min_messages = warning;
13
select
24
e.evtname,
35
e.evtowner::regrole as evtowner,
@@ -10,19 +12,19 @@ join pg_proc p
1012
join pg_namespace n_func
1113
on p.pronamespace = n_func.oid
1214
where p.prorettype = 'event_trigger'::regtype;
13-
evtname | evtowner | evtfunction_schema | evtfunction | function_owner
14-
----------------------------------------+----------------+--------------------+------------------------------------+----------------
15-
issue_pg_graphql_access | supabase_admin | extensions | grant_pg_graphql_access | supabase_admin
16-
issue_graphql_placeholder | supabase_admin | extensions | set_graphql_placeholder | supabase_admin
17-
pgrst_ddl_watch | supabase_admin | extensions | pgrst_ddl_watch | supabase_admin
18-
pgrst_drop_watch | supabase_admin | extensions | pgrst_drop_watch | supabase_admin
19-
graphql_watch_ddl | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
20-
graphql_watch_drop | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
21-
issue_pg_cron_access | supabase_admin | extensions | grant_pg_cron_access | supabase_admin
22-
issue_pg_net_access | supabase_admin | extensions | grant_pg_net_access | supabase_admin
23-
pg_tle_event_trigger_for_drop_function | supabase_admin | pgtle | pgtle.pg_tle_feature_info_sql_drop | supabase_admin
24-
pgaudit_ddl_command_end | supabase_admin | public | pgaudit_ddl_command_end | supabase_admin
25-
pgaudit_sql_drop | supabase_admin | public | pgaudit_sql_drop | supabase_admin
26-
pgsodium_trg_mask_update | supabase_admin | pgsodium | pgsodium.trg_mask_update | supabase_admin
27-
(12 rows)
15+
evtname | evtowner | evtfunction_schema | evtfunction | function_owner
16+
---------------------------+----------------+--------------------+----------------------------------+----------------
17+
issue_pg_graphql_access | supabase_admin | extensions | grant_pg_graphql_access | supabase_admin
18+
issue_graphql_placeholder | supabase_admin | extensions | set_graphql_placeholder | supabase_admin
19+
pgrst_ddl_watch | supabase_admin | extensions | pgrst_ddl_watch | supabase_admin
20+
pgrst_drop_watch | supabase_admin | extensions | pgrst_drop_watch | supabase_admin
21+
graphql_watch_ddl | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
22+
graphql_watch_drop | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
23+
issue_pg_cron_access | supabase_admin | extensions | grant_pg_cron_access | supabase_admin
24+
issue_pg_net_access | supabase_admin | extensions | grant_pg_net_access | supabase_admin
25+
pgaudit_ddl_command_end | supabase_admin | extensions | pgaudit_ddl_command_end | supabase_admin
26+
pgaudit_sql_drop | supabase_admin | extensions | pgaudit_sql_drop | supabase_admin
27+
pgsodium_trg_mask_update | supabase_admin | pgsodium | pgsodium.trg_mask_update | supabase_admin
28+
(11 rows)
2829

30+
ROLLBACK;

nix/tests/expected/extensions_schema.out

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
BEGIN;
2+
set client_min_messages = warning;
13
-- all default extensions are installed in a schema "extensions"
24
-- we don't include the version as that will break often, we only care about
35
-- ensuring these extensions are present
@@ -15,8 +17,13 @@ order by
1517
e.extname;
1618
extension_name | schema_name | extension_owner
1719
--------------------+-------------+-----------------
20+
dblink | extensions | supabase_admin
21+
pg_repack | extensions | supabase_admin
1822
pg_stat_statements | extensions | supabase_admin
23+
pgaudit | extensions | supabase_admin
1924
pgcrypto | extensions | supabase_admin
25+
postgis | extensions | supabase_admin
2026
uuid-ossp | extensions | supabase_admin
21-
(3 rows)
27+
(7 rows)
2228

29+
ROLLBACK;

nix/tests/expected/http.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
-- Test for http extension
22
-- Basic HTTP functionality tests
3+
BEGIN;
4+
set client_min_messages = warning;
5+
create extension if not exists http with schema extensions;
36
-- Test basic HTTP GET request
47
SELECT status FROM http_get('http://localhost:' || (SELECT value FROM test_config WHERE key = 'http_mock_port') || '/get');
58
status
@@ -103,3 +106,4 @@ SELECT status FROM http_get('http://localhost:' || (SELECT value FROM test_confi
103106
200
104107
(1 row)
105108

109+
ROLLBACK;

nix/tests/expected/hypopg.out

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
BEGIN;
2+
set client_min_messages = warning;
3+
create extension if not exists hypopg with schema extensions;
14
create schema v;
25
create table v.samp(
36
id int
@@ -11,4 +14,4 @@ $$);
1114
(1 row)
1215

1316
drop schema v cascade;
14-
NOTICE: drop cascades to table v.samp
17+
ROLLBACK;

nix/tests/expected/index_advisor.out

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
BEGIN;
2+
set client_min_messages = warning;
3+
create extension if not exists hypopg with schema extensions;
4+
create extension if not exists index_advisor with schema extensions;
15
create schema v;
26
create table v.book(
37
id int primary key,
@@ -13,4 +17,4 @@ from
1317
(1 row)
1418

1519
drop schema v cascade;
16-
NOTICE: drop cascades to table v.book
20+
ROLLBACK;

0 commit comments

Comments
 (0)