summaryrefslogtreecommitdiffstats
path: root/nixos/tests/cadvisor.nix
blob: 6f80d78f4f44598fef4d56366ede94b4996eaa01 (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
{ lib, ... }:
{
  name = "cadvisor";

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

    influxdb = {
      services.cadvisor.enable = true;
      services.cadvisor.storageDriver = "influxdb";
      services.influxdb.enable = true;
    };
  };

  testScript = ''
    start_all()
    machine.wait_for_unit("cadvisor.service")
    machine.succeed("curl -f http://localhost:8080/containers/")

    influxdb.wait_for_unit("influxdb.service")

    # create influxdb database
    influxdb.succeed(
        'curl -f -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE root"'
    )

    influxdb.wait_for_unit("cadvisor.service")
    influxdb.succeed("curl -f http://localhost:8080/containers/")
  '';
}