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