summary refs log tree commit diff
path: root/nixos/tests/influxdb.nix
blob: 0408d8983ade42c65bdf6334bc73021313377ae4 (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
# This test runs influxdb and checks if influxdb is up and running

import ./make-test.nix ({ pkgs, ...} : {
  name = "influxdb";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ chaoflow offline ];
  };

  nodes = {
    one = { config, pkgs, ... }: {
      services.influxdb.enable = true;
    };
  };

  testScript = ''
    startAll;
  
    $one->waitForUnit("influxdb.service");

    # Check if admin interface is avalible
    $one->waitUntilSucceeds("curl -f 127.0.0.1:8083");

    # create database
    $one->succeed(q~
      curl -X POST 'http://localhost:8086/db?u=root&p=root' \
        -d '{"name": "test"}'
    ~);

    # write some points and run simple query
    $one->succeed(q~
      curl -X POST 'http://localhost:8086/db/test/series?u=root&p=root' \
        -d '[{"name":"foo","columns":["val"],"points":[[6666]]}]'
    ~);
    $one->succeed(q~
      curl -G 'http://localhost:8086/db/test/series?u=root&p=root' \
        --data-urlencode 'q=select * from foo limit 1' | grep 6666
    ~);
  '';
})