mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
postgresqlPackages.citus: move test from VM to postgresqlTestExtension
This commit is contained in:
parent
debf86e09e
commit
6cc89cd16e
3 changed files with 28 additions and 74 deletions
|
@ -1,73 +0,0 @@
|
|||
{
|
||||
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;
|
||||
}
|
|
@ -36,7 +36,6 @@ in
|
|||
|
||||
# extensions
|
||||
anonymizer = importWithArgs ./anonymizer.nix;
|
||||
citus = importWithArgs ./citus.nix;
|
||||
pgjwt = importWithArgs ./pgjwt.nix;
|
||||
pgvecto-rs = importWithArgs ./pgvecto-rs.nix;
|
||||
timescaledb = importWithArgs ./timescaledb.nix;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue