summary refs log tree commit diff
path: root/nixos/tests/graphite.nix
blob: 137be2d89c8b31aad88c7a6f05f0fa7a4d9d4531 (plain) (blame)
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
import ./make-test-python.nix ({ pkgs, ... } :
{
  name = "graphite";
  nodes = {
    one =
      { ... }: {
        virtualisation.memorySize = 1024;
        time.timeZone = "UTC";
        services.graphite = {
          web = {
            enable = true;
            extraConfig = ''
              SECRET_KEY = "abcd";
            '';
          };
          api = {
            enable = true;
            port = 8082;
            finders = [ ];
          };
          carbon.enableCache = true;
          seyren.enable = false;  # Implicitely requires openssl-1.0.2u which is marked insecure
          beacon.enable = true;
        };
      };
  };

  testScript = ''
    start_all()
    one.wait_for_unit("default.target")
    one.wait_for_unit("graphiteWeb.service")
    one.wait_for_unit("graphiteApi.service")
    one.wait_for_unit("graphite-beacon.service")
    one.wait_for_unit("carbonCache.service")
    # The services above are of type "simple". systemd considers them active immediately
    # even if they're still in preStart (which takes quite long for graphiteWeb).
    # Wait for ports to open so we're sure the services are up and listening.
    one.wait_for_open_port(8080)
    one.wait_for_open_port(8082)
    one.wait_for_open_port(2003)
    one.succeed('echo "foo 1 `date +%s`" | nc -N localhost 2003')
    one.wait_until_succeeds(
        "curl 'http://localhost:8080/metrics/find/?query=foo&format=treejson' --silent | grep foo >&2"
    )
    one.wait_until_succeeds(
        "curl 'http://localhost:8082/metrics/find/?query=foo&format=treejson' --silent | grep foo >&2"
    )
  '';
})