summaryrefslogtreecommitdiffstats
path: root/nixos/tests/postgresql/wal2json.nix
blob: 511b1a7a2e8c03f326949d2258001b258887557d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
  runTest,
  genTests,
  ...
}:

let
  makeTestFor =
    package:
    runTest (
      { lib, pkgs, ... }:
      {
        name = "wal2json-${package.name}";
        meta.maintainers = with pkgs.lib.maintainers; [ euank ];

        nodes.machine = {
          services.postgresql = {
            inherit package;
            enable = true;
            extensions = with package.pkgs; [ wal2json ];
            settings = {
              wal_level = "logical";
              max_replication_slots = "10";
              max_wal_senders = "10";
            };
          };
        };

        testScript = ''
          machine.wait_for_unit("postgresql.target")
          machine.succeed(
              "sudo -u postgres psql -qAt -f ${./wal2json/example2.sql} postgres > /tmp/example2.out"
          )
          machine.succeed(
              "diff ${./wal2json/example2.out} /tmp/example2.out"
          )
          machine.succeed(
              "sudo -u postgres psql -qAt -f ${./wal2json/example3.sql} postgres > /tmp/example3.out"
          )
          machine.succeed(
              "diff ${./wal2json/example3.out} /tmp/example3.out"
          )
        '';
      }
    );
in
genTests {
  inherit makeTestFor;
  filter = _: p: !p.pkgs.wal2json.meta.broken;
}