1# This test runs influxdb and checks if influxdb is up and running
2
3import ./make-test-python.nix (
4 { pkgs, ... }:
5 {
6 name = "influxdb";
7 meta = with pkgs.lib.maintainers; {
8 maintainers = [ offline ];
9 };
10
11 nodes = {
12 one =
13 { ... }:
14 {
15 services.influxdb.enable = true;
16 environment.systemPackages = [ pkgs.httpie ];
17 };
18 };
19
20 testScript = ''
21 import shlex
22
23 start_all()
24
25 one.wait_for_unit("influxdb.service")
26
27 # create database
28 one.succeed(
29 "curl -XPOST http://localhost:8086/query --data-urlencode 'q=CREATE DATABASE test'"
30 )
31
32 # write some points and run simple query
33 out = one.succeed(
34 "curl -XPOST 'http://localhost:8086/write?db=test' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'"
35 )
36
37 qv = "SELECT value FROM cpu_load_short WHERE region='us-west'"
38 cmd = f'curl -GET "http://localhost:8086/query?db=test" --data-urlencode {shlex.quote("q="+ qv)}'
39 out = one.succeed(cmd)
40
41 assert "2015-06-11T20:46:02Z" in out
42 assert "0.64" in out
43 '';
44 }
45)