1010 let
1111 pname = extension_name ;
1212 inherit ( pkgs ) lib ;
13+ # Special case for timescaledb-apache: only test with PostgreSQL 15
14+ isTimescaledb = extension_name == "timescaledb-apache" ;
1315 installedExtension =
1416 postgresMajorVersion : self . packages . ${ pkgs . system } . "psql_${ postgresMajorVersion } /exts/${ pname } -all" ;
1517 versions = postgresqlMajorVersion : ( installedExtension postgresqlMajorVersion ) . versions ;
4446 in
4547 pkg ;
4648 psql_15 = postgresqlWithExtension self . packages . ${ pkgs . system } . postgresql_15 ;
47- psql_17 = postgresqlWithExtension self . packages . ${ pkgs . system } . postgresql_17 ;
49+ psql_17 =
50+ if isTimescaledb then null else postgresqlWithExtension self . packages . ${ pkgs . system } . postgresql_17 ;
4851 in
4952 self . inputs . nixpkgs . lib . nixos . runTest {
5053 name = pname ;
8083
8184 networking . firewall . allowedTCPPorts = [ config . services . postgresql . settings . port ] ;
8285
83- specialisation . postgresql17 . configuration = {
84- services . postgresql = {
85- package = lib . mkForce psql_17 ;
86- } ;
86+ specialisation = lib . optionalAttrs ( ! isTimescaledb ) {
87+ postgresql17 . configuration = {
88+ services . postgresql = {
89+ package = lib . mkForce psql_17 ;
90+ } ;
8791
88- systemd . services . postgresql-migrate = {
89- serviceConfig = {
90- Type = "oneshot" ;
91- RemainAfterExit = true ;
92- User = "postgres" ;
93- Group = "postgres" ;
94- StateDirectory = "postgresql" ;
95- WorkingDirectory = "${ builtins . dirOf config . services . postgresql . dataDir } " ;
92+ systemd . services . postgresql-migrate = {
93+ serviceConfig = {
94+ Type = "oneshot" ;
95+ RemainAfterExit = true ;
96+ User = "postgres" ;
97+ Group = "postgres" ;
98+ StateDirectory = "postgresql" ;
99+ WorkingDirectory = "${ builtins . dirOf config . services . postgresql . dataDir } " ;
100+ } ;
101+ script =
102+ let
103+ oldPostgresql = psql_15 ;
104+ newPostgresql = psql_17 ;
105+ oldDataDir = "${ builtins . dirOf config . services . postgresql . dataDir } /${ oldPostgresql . psqlSchema } " ;
106+ newDataDir = "${ builtins . dirOf config . services . postgresql . dataDir } /${ newPostgresql . psqlSchema } " ;
107+ in
108+ ''
109+ if [[ ! -d ${ newDataDir } ]]; then
110+ install -d -m 0700 -o postgres -g postgres "${ newDataDir } "
111+ ${ newPostgresql } /bin/initdb -D "${ newDataDir } "
112+ ${ newPostgresql } /bin/pg_upgrade --old-datadir "${ oldDataDir } " --new-datadir "${ newDataDir } " \
113+ --old-bindir "${ oldPostgresql } /bin" --new-bindir "${ newPostgresql } /bin"
114+ else
115+ echo "${ newDataDir } already exists"
116+ fi
117+ '' ;
96118 } ;
97- script =
98- let
99- oldPostgresql = psql_15 ;
100- newPostgresql = psql_17 ;
101- oldDataDir = "${ builtins . dirOf config . services . postgresql . dataDir } /${ oldPostgresql . psqlSchema } " ;
102- newDataDir = "${ builtins . dirOf config . services . postgresql . dataDir } /${ newPostgresql . psqlSchema } " ;
103- in
104- ''
105- if [[ ! -d ${ newDataDir } ]]; then
106- install -d -m 0700 -o postgres -g postgres "${ newDataDir } "
107- ${ newPostgresql } /bin/initdb -D "${ newDataDir } "
108- ${ newPostgresql } /bin/pg_upgrade --old-datadir "${ oldDataDir } " --new-datadir "${ newDataDir } " \
109- --old-bindir "${ oldPostgresql } /bin" --new-bindir "${ newPostgresql } /bin"
110- else
111- echo "${ newDataDir } already exists"
112- fi
113- '' ;
114- } ;
115119
116- systemd . services . postgresql = {
117- after = [ "postgresql-migrate.service" ] ;
118- requires = [ "postgresql-migrate.service" ] ;
120+ systemd . services . postgresql = {
121+ after = [ "postgresql-migrate.service" ] ;
122+ requires = [ "postgresql-migrate.service" ] ;
123+ } ;
119124 } ;
120125 } ;
121126 } ;
127132 ''
128133 versions = {
129134 "15": [${ lib . concatStringsSep ", " ( map ( s : ''"${ s } "'' ) ( versions "15" ) ) } ],
130- "17": [${ lib . concatStringsSep ", " ( map ( s : ''"${ s } "'' ) ( versions "17" ) ) } ],
135+ ${
136+ if isTimescaledb then
137+ ""
138+ else
139+ ''"17": [${ lib . concatStringsSep ", " ( map ( s : ''"${ s } "'' ) ( versions "17" ) ) } ],''
140+ }
131141 }
132142 extension_name = "${ pname } "
133143 support_upgrade = True
@@ -156,16 +166,22 @@ let
156166 with subtest("Test switch_${ pname } _version"):
157167 test.check_switch_extension_with_background_worker(Path("${ psql_15 } /lib/${ pname } .so"), "15")
158168
159- with subtest("switch to postgresql 17"):
160- server.succeed(
161- f"{pg17_configuration}/bin/switch-to-configuration test >&2"
162- )
169+ ${
170+ if isTimescaledb then
171+ ""
172+ else
173+ ''
174+ with subtest("switch to postgresql 17"):
175+ server.succeed(
176+ f"{pg17_configuration}/bin/switch-to-configuration test >&2"
177+ )
163178
164- with subtest("Check last version of the extension after upgrade"):
165- test.assert_version_matches(last_version)
179+ with subtest("Check last version of the extension after upgrade"):
180+ test.assert_version_matches(last_version)
166181
167- with subtest("Check upgrade path with postgresql 17"):
168- test.check_upgrade_path("17")
182+ with subtest("Check upgrade path with postgresql 17"):
183+ test.check_upgrade_path("17")''
184+ }
169185 '' ;
170186 } ;
171187in
@@ -186,7 +202,7 @@ builtins.listToAttrs (
186202 "index_advisor"
187203 "pg_cron"
188204 "pg_net"
189- "timescaledb"
205+ "timescaledb-apache "
190206 "vector"
191207 "wrappers"
192208 ]
0 commit comments