tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nixosTests.promscale: add tests for promscale_extension
Pavel Anpin
2 years ago
08ddf6f0
4e6ddd0c
+61
2 changed files
expand all
collapse all
unified
split
nixos
tests
all-tests.nix
promscale.nix
+1
nixos/tests/all-tests.nix
···
712
tiddlywiki = handleTest ./tiddlywiki.nix {};
713
tigervnc = handleTest ./tigervnc.nix {};
714
timescaledb = handleTest ./timescaledb.nix {};
0
715
timezone = handleTest ./timezone.nix {};
716
tinc = handleTest ./tinc {};
717
tinydns = handleTest ./tinydns.nix {};
···
712
tiddlywiki = handleTest ./tiddlywiki.nix {};
713
tigervnc = handleTest ./tigervnc.nix {};
714
timescaledb = handleTest ./timescaledb.nix {};
715
+
promscale = handleTest ./promscale.nix {};
716
timezone = handleTest ./timezone.nix {};
717
tinc = handleTest ./tinc {};
718
tinydns = handleTest ./tinydns.nix {};
+60
nixos/tests/promscale.nix
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
# mostly copied from ./timescaledb.nix which was copied from ./postgresql.nix
2
+
# as it seemed unapproriate to test additional extensions for postgresql there.
3
+
4
+
{ system ? builtins.currentSystem
5
+
, config ? { }
6
+
, pkgs ? import ../.. { inherit system config; }
7
+
}:
8
+
9
+
with import ../lib/testing-python.nix { inherit system pkgs; };
10
+
with pkgs.lib;
11
+
12
+
let
13
+
postgresql-versions = import ../../pkgs/servers/sql/postgresql pkgs;
14
+
test-sql = pkgs.writeText "postgresql-test" ''
15
+
CREATE USER promscale SUPERUSER PASSWORD 'promscale';
16
+
CREATE DATABASE promscale OWNER promscale;
17
+
'';
18
+
19
+
make-postgresql-test = postgresql-name: postgresql-package: makeTest {
20
+
name = postgresql-name;
21
+
meta = with pkgs.lib.maintainers; {
22
+
maintainers = [ anpin ];
23
+
};
24
+
25
+
nodes.machine = { config, pkgs, ... }:
26
+
{
27
+
services.postgresql = {
28
+
enable = true;
29
+
package = postgresql-package;
30
+
extraPlugins = with postgresql-package.pkgs; [
31
+
timescaledb
32
+
promscale_extension
33
+
];
34
+
settings = { shared_preload_libraries = "timescaledb, promscale"; };
35
+
};
36
+
environment.systemPackages = with pkgs; [ promscale ];
37
+
};
38
+
39
+
testScript = ''
40
+
machine.start()
41
+
machine.wait_for_unit("postgresql")
42
+
with subtest("Postgresql with extensions timescaledb and promscale is available just after unit start"):
43
+
print(machine.succeed("sudo -u postgres psql -f ${test-sql}"))
44
+
machine.succeed("sudo -u postgres psql promscale -c 'SHOW shared_preload_libraries;' | grep promscale")
45
+
machine.succeed(
46
+
"promscale --db.name promscale --db.password promscale --db.user promscale --db.ssl-mode allow --startup.install-extensions --startup.only"
47
+
)
48
+
machine.succeed("sudo -u postgres psql promscale -c 'SELECT ps_trace.get_trace_retention_period();' | grep '(1 row)'")
49
+
machine.shutdown()
50
+
'';
51
+
};
52
+
#version 15 is not supported yet
53
+
applicablePostgresqlVersions = filterAttrs (_: value: versionAtLeast value.version "12" && !(versionAtLeast value.version "15")) postgresql-versions;
54
+
in
55
+
mapAttrs'
56
+
(name: package: {
57
+
inherit name;
58
+
value = make-postgresql-test name package;
59
+
})
60
+
applicablePostgresqlVersions