summary refs log tree commit diff
path: root/nixos/tests/cadvisor.nix
blob: 1644cb856cece4e6e53ef5f569d1ad0ca8103d4e (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
import ./make-test.nix ({ pkgs, ... } : {
  name = "cadvisor";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ offline ];
  };

  nodes = {
    machine = { config, pkgs, ... }: {
      services.cadvisor.enable = true;
    };

    influxdb = { config, pkgs, lib, ... }: with lib; {
      services.cadvisor.enable = true;
      services.cadvisor.storageDriver = "influxdb";
      services.influxdb.enable = true;
      systemd.services.influxdb.postStart = mkAfter ''
        ${pkgs.curl}/bin/curl -X POST 'http://localhost:8086/db?u=root&p=root' \
          -d '{"name": "root"}'
      '';
    };
  };

  testScript =
    ''
      startAll;
      $machine->waitForUnit("cadvisor.service");
      $machine->succeed("curl http://localhost:8080/containers/");

      $influxdb->waitForUnit("influxdb.service");
      $influxdb->waitForUnit("cadvisor.service");
      $influxdb->succeed("curl http://localhost:8080/containers/");
    '';
})