Skip to content

Commit 3b2b18a

Browse files
jfrochesamrose
andauthored
feat: multiple versions for the vault extension (#1661)
* feat: multiple versions for the vault extension Build multiple versions of the vault extension on different PostgreSQL versions. Add test for the extensions and their upgrade on PostgreSQL 15 and 17. * fix: nixos tests for pg_repack, pgroonga, and plpgsql_check to use the supabase_admin user We switched to using the supabase_admin user for our Postgres tests instead of the default postgres user. This change updates the authentication methods and user management in the NixOS test configurations for the pg_repack, pgroonga, and plpgsql_check extensions. * fix: nixos test for plv8 extension to use the supabase_admin user We switched to using the supabase_admin user for our Postgres tests instead of the default postgres user. This change updates the authentication methods and user management in the NixOS test configurations for the plv8 extension. * chore: bump one more --------- Co-authored-by: Sam Rose <[email protected]>
1 parent f8c523c commit 3b2b18a

File tree

12 files changed

+399
-44
lines changed

12 files changed

+399
-44
lines changed

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ postgres_major:
1010

1111
# Full version strings for each major version
1212
postgres_release:
13-
postgresorioledb-17: "17.5.1.058-orioledb"
14-
postgres17: "17.6.1.037"
15-
postgres15: "15.14.1.037"
13+
postgresorioledb-17: "17.5.1.059-orioledb"
14+
postgres17: "17.6.1.038"
15+
postgres15: "15.14.1.038"
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.19.0

nix/ext/tests/default.nix

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,20 @@ let
6969
enable = true;
7070
package = psql_15;
7171
enableTCPIP = true;
72-
initialScript = pkgs.writeText "init-postgres-with-password" ''
73-
CREATE USER test WITH PASSWORD 'secret';
74-
'';
7572
authentication = ''
76-
host test postgres samenet scram-sha-256
73+
local all postgres peer map=postgres
74+
local all all peer map=root
75+
'';
76+
identMap = ''
77+
root root supabase_admin
78+
postgres postgres postgres
7779
'';
80+
ensureUsers = [
81+
{
82+
name = "supabase_admin";
83+
ensureClauses.superuser = true;
84+
}
85+
];
7886
settings = (installedExtension "15").defaultSettings or { };
7987
};
8088

nix/ext/tests/lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ def __init__(
3838

3939
def run_sql(self, query: str) -> str:
4040
return self.vm.succeed(
41-
f"""sudo -u postgres psql -t -A -F\",\" -c \"{query}\" """
41+
f"""psql -U supabase_admin -d postgres -t -A -F\",\" -c \"{query}\" """
4242
).strip()
4343

4444
def run_sql_file(self, file: str) -> str:
4545
return self.vm.succeed(
46-
f"""sudo -u postgres psql -v ON_ERROR_STOP=1 -f \"{file}\""""
46+
f"""psql -U supabase_admin -d postgres -v ON_ERROR_STOP=1 -f \"{file}\""""
4747
).strip()
4848

4949
def drop_extension(self):

nix/ext/tests/pg_repack.nix

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@ self.inputs.nixpkgs.lib.nixos.runTest {
5959
enable = true;
6060
package = postgresqlWithExtension self.packages.${pkgs.system}.postgresql_15;
6161
enableTCPIP = true;
62-
initialScript = pkgs.writeText "init-postgres-with-password" ''
63-
CREATE USER test WITH PASSWORD 'secret';
64-
'';
6562
authentication = ''
66-
host test postgres samenet scram-sha-256
63+
local all postgres peer map=postgres
64+
local all all peer map=root
65+
'';
66+
identMap = ''
67+
root root supabase_admin
68+
postgres postgres postgres
6769
'';
70+
ensureUsers = [
71+
{
72+
name = "supabase_admin";
73+
ensureClauses.superuser = true;
74+
}
75+
];
6876
};
6977

7078
networking.firewall.allowedTCPPorts = [ config.services.postgresql.settings.port ];

nix/ext/tests/pgmq.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ self.inputs.nixpkgs.lib.nixos.runTest {
4747
services.postgresql = {
4848
enable = true;
4949
package = (postgresqlWithExtension psql_15);
50+
authentication = ''
51+
local all postgres peer map=postgres
52+
local all all peer map=root
53+
'';
54+
identMap = ''
55+
root root supabase_admin
56+
postgres postgres postgres
57+
'';
58+
ensureUsers = [
59+
{
60+
name = "supabase_admin";
61+
ensureClauses.superuser = true;
62+
}
63+
];
5064
settings = (installedExtension "15").defaultSettings or { };
5165
};
5266

nix/ext/tests/pgroonga.nix

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ self.inputs.nixpkgs.lib.nixos.runTest {
6060
services.postgresql = {
6161
enable = true;
6262
package = psql_15;
63+
enableTCPIP = true;
64+
authentication = ''
65+
local all postgres peer map=postgres
66+
local all all peer map=root
67+
'';
68+
identMap = ''
69+
root root supabase_admin
70+
postgres postgres postgres
71+
'';
72+
ensureUsers = [
73+
{
74+
name = "supabase_admin";
75+
ensureClauses.superuser = true;
76+
}
77+
];
6378
};
6479
systemd.services.postgresql.environment.MECAB_DICDIR = "${
6580
self.packages.${pkgs.system}.mecab-naist-jdic
@@ -120,7 +135,6 @@ self.inputs.nixpkgs.lib.nixos.runTest {
120135
"17": [${lib.concatStringsSep ", " (map (s: ''"${s}"'') (versions "17"))}],
121136
}
122137
extension_name = "${pname}"
123-
support_upgrade = False
124138
pg17_configuration = "${pg17-configuration}"
125139
ext_has_background_worker = ${
126140
if (installedExtension "15") ? hasBackgroundWorker then "True" else "False"
@@ -135,7 +149,7 @@ self.inputs.nixpkgs.lib.nixos.runTest {
135149
server.wait_for_unit("multi-user.target")
136150
server.wait_for_unit("postgresql.service")
137151
138-
test = PostgresExtensionTest(server, extension_name, versions, sql_test_directory, support_upgrade)
152+
test = PostgresExtensionTest(server, extension_name, versions, sql_test_directory)
139153
140154
with subtest("Check upgrade path with postgresql 15"):
141155
test.check_upgrade_path("15")

nix/ext/tests/plpgsql_check.nix

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,20 @@ self.inputs.nixpkgs.lib.nixos.runTest {
6161
enable = true;
6262
package = psql_15;
6363
enableTCPIP = true;
64-
initialScript = pkgs.writeText "init-postgres-with-password" ''
65-
CREATE USER test WITH PASSWORD 'secret';
66-
'';
6764
authentication = ''
68-
host test postgres samenet scram-sha-256
65+
local all postgres peer map=postgres
66+
local all all peer map=root
67+
'';
68+
identMap = ''
69+
root root supabase_admin
70+
postgres postgres postgres
6971
'';
72+
ensureUsers = [
73+
{
74+
name = "supabase_admin";
75+
ensureClauses.superuser = true;
76+
}
77+
];
7078
settings = (installedExtension "15").defaultSettings or { };
7179
};
7280

nix/ext/tests/plv8.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ self.inputs.nixpkgs.lib.nixos.runTest {
6060
services.postgresql = {
6161
enable = true;
6262
package = postgresqlWithExtension self.packages.${pkgs.system}.postgresql_15;
63+
authentication = ''
64+
local all postgres peer map=postgres
65+
local all all peer map=root
66+
'';
67+
identMap = ''
68+
root root supabase_admin
69+
postgres postgres postgres
70+
'';
71+
ensureUsers = [
72+
{
73+
name = "supabase_admin";
74+
ensureClauses.superuser = true;
75+
}
76+
];
6377
};
6478
};
6579
testScript =

nix/ext/tests/timescaledb.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ self.inputs.nixpkgs.lib.nixos.runTest {
4646
services.postgresql = {
4747
enable = true;
4848
package = (postgresqlWithExtension psql_15);
49+
authentication = ''
50+
local all postgres peer map=postgres
51+
local all all peer map=root
52+
'';
53+
identMap = ''
54+
root root supabase_admin
55+
postgres postgres postgres
56+
'';
57+
ensureUsers = [
58+
{
59+
name = "supabase_admin";
60+
ensureClauses.superuser = true;
61+
}
62+
{ name = "service_role"; }
63+
];
64+
4965
settings = {
5066
shared_preload_libraries = "timescaledb";
5167
};

0 commit comments

Comments
 (0)