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