nixpkgs/nixos/tests/influxdb.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
Nix
Raw Normal View History

2014-05-28 00:54:43 +04:00
# This test runs influxdb and checks if influxdb is up and running
2019-11-24 22:21:06 +03:00
import ./make-test-python.nix ({ pkgs, ...} : {
2014-06-28 18:04:49 +04:00
name = "influxdb";
meta = with pkgs.lib.maintainers; {
maintainers = [ offline ];
};
2014-06-28 18:04:49 +04:00
2014-05-28 00:54:43 +04:00
nodes = {
one = { ... }: {
2014-05-28 00:54:43 +04:00
services.influxdb.enable = true;
2019-11-24 22:21:06 +03:00
environment.systemPackages = [ pkgs.httpie ];
2014-05-28 00:54:43 +04:00
};
};
testScript = ''
2019-11-24 22:21:06 +03:00
import shlex
start_all()
one.wait_for_unit("influxdb.service")
2014-05-28 00:54:43 +04:00
# create database
2019-11-24 22:21:06 +03:00
one.succeed(
"curl -XPOST http://localhost:8086/query --data-urlencode 'q=CREATE DATABASE test'"
)
2014-05-28 00:54:43 +04:00
# write some points and run simple query
2019-11-24 22:21:06 +03:00
out = one.succeed(
"curl -XPOST 'http://localhost:8086/write?db=test' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'"
)
qv = "SELECT value FROM cpu_load_short WHERE region='us-west'"
cmd = f'curl -GET "http://localhost:8086/query?db=test" --data-urlencode {shlex.quote("q="+ qv)}'
out = one.succeed(cmd)
assert "2015-06-11T20:46:02Z" in out
assert "0.64" in out
2014-05-28 00:54:43 +04:00
'';
})