summaryrefslogtreecommitdiffstats
path: root/nixos/tests/autopush-rs.nix
blob: a77702ff35051ccb6303c36d893da05028efcb43 (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
51
52
53
54
55
56
57
58
59
60
61
{ lib, ... }:
{
  _class = "nixosTest";
  name = "autopush-rs";

  nodes = {
    machine =
      { pkgs, config, ... }:
      {
        environment.systemPackages = [
          pkgs.curl
        ];

        services.redis.servers.autopush-rs = {
          enable = true;
          port = 6000;
        };
        system.services.autopush-autoconnect = {
          imports = [
            pkgs.autopush-rs.services.autoconnect
          ];
          autoconnect.settings = {
            #do not use this key in production!!!
            crypto_key = "[fZQX8jgdESUYFTYfWw3Dv5RRMuwYJPPaaPcbUgHM69Q=]";
            db_dsn = "redis://localhost:${toString config.services.redis.servers.autopush-rs.port}";
            port = 8000;
          };
        };
        system.services.autopush-autoendpoint = {
          imports = [
            pkgs.autopush-rs.services.autoendpoint
          ];
          autoendpoint.settings = {
            #do not use this key in production!!!
            crypto_key = "[fZQX8jgdESUYFTYfWw3Dv5RRMuwYJPPaaPcbUgHM69Q=]";
            auth_keys = "[fZQX8jgdESUYFTYfWw3Dv5RRMuwYJPPaaPcbUgHM69Q=]";
            db_dsn = "redis://localhost:${toString config.services.redis.servers.autopush-rs.port}";
            port = 8080;
          };
        };

        networking.firewall.allowedTCPPorts = [
          8080
          8000
        ];
      };
  };

  testScript = ''
    start_all()
    machine.wait_for_unit("multi-user.target")
    machine.wait_for_unit("autopush-autoconnect.service")
    machine.wait_for_unit("autopush-autoendpoint.service")
    machine.wait_for_open_port(8080)
    machine.wait_for_open_port(8000)
    machine.succeed("curl -s -f http://localhost:8080/health")
    machine.succeed("curl -s -f http://localhost:8000/health")
  '';

  meta.maintainers = with lib.maintainers; [ zimward ];
}