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

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

    influxdb = { lib, ... }: with lib; {
      services.cadvisor.enable = true;
      services.cadvisor.storageDriver = "influxdb";
      services.influxdb.enable = true;
    };
  };

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

      $influxdb->waitForUnit("influxdb.service");

      # create influxdb database
      $influxdb->succeed(q~
        curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE root"
      ~);

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