-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixos/postgresql/citus: fix syscall filter and add test
- Loading branch information
1 parent
9a9ab6b
commit 37372eb
Showing
3 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ | ||
pkgs, | ||
makeTest, | ||
genTests, | ||
}: | ||
|
||
let | ||
inherit (pkgs) lib; | ||
|
||
test-sql = pkgs.writeText "postgresql-test" '' | ||
CREATE EXTENSION citus; | ||
CREATE TABLE examples ( | ||
id bigserial, | ||
shard_key int, | ||
PRIMARY KEY (id, shard_key) | ||
); | ||
SELECT create_distributed_table('examples', 'shard_key'); | ||
INSERT INTO examples (shard_key) SELECT shard % 10 FROM generate_series(1,1000) shard; | ||
''; | ||
|
||
makeTestFor = | ||
package: | ||
makeTest { | ||
name = "citus-${package.name}"; | ||
meta = with lib.maintainers; { | ||
maintainers = [ typetetris ]; | ||
}; | ||
|
||
nodes.machine = | ||
{ ... }: | ||
{ | ||
services.postgresql = { | ||
inherit package; | ||
enable = true; | ||
enableJIT = lib.hasInfix "-jit-" package.name; | ||
extensions = | ||
ps: with ps; [ | ||
citus | ||
]; | ||
settings = { | ||
shared_preload_libraries = "citus"; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
def check_count(statement, lines): | ||
return 'test $(sudo -u postgres psql postgres -tAc "{}") -eq {}'.format( | ||
statement, lines | ||
) | ||
machine.start() | ||
machine.wait_for_unit("postgresql") | ||
with subtest("Postgresql with extension citus is available just after unit start"): | ||
machine.succeed( | ||
"sudo -u postgres psql -f ${test-sql}" | ||
) | ||
machine.succeed(check_count("SELECT count(*) FROM examples;", 1000)) | ||
machine.shutdown() | ||
''; | ||
}; | ||
in | ||
genTests { | ||
inherit makeTestFor; | ||
filter = _: p: !p.pkgs.citus.meta.broken; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters