mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 00:43:20 +00:00
Merge pull request #74069 from flokli/nixos-test-port-influxdb
nixosTests.influxdb: port to python
This commit is contained in:
commit
4572821435
@ -1,6 +1,6 @@
|
|||||||
# This test runs influxdb and checks if influxdb is up and running
|
# This test runs influxdb and checks if influxdb is up and running
|
||||||
|
|
||||||
import ./make-test.nix ({ pkgs, ...} : {
|
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||||
name = "influxdb";
|
name = "influxdb";
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ offline ];
|
maintainers = [ offline ];
|
||||||
@ -9,25 +9,32 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
nodes = {
|
nodes = {
|
||||||
one = { ... }: {
|
one = { ... }: {
|
||||||
services.influxdb.enable = true;
|
services.influxdb.enable = true;
|
||||||
|
environment.systemPackages = [ pkgs.httpie ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
startAll;
|
import shlex
|
||||||
|
|
||||||
$one->waitForUnit("influxdb.service");
|
start_all()
|
||||||
|
|
||||||
|
one.wait_for_unit("influxdb.service")
|
||||||
|
|
||||||
# create database
|
# create database
|
||||||
$one->succeed(q~
|
one.succeed(
|
||||||
curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE test"
|
"curl -XPOST http://localhost:8086/query --data-urlencode 'q=CREATE DATABASE test'"
|
||||||
~);
|
)
|
||||||
|
|
||||||
# write some points and run simple query
|
# write some points and run simple query
|
||||||
$one->succeed(q~
|
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'
|
"curl -XPOST 'http://localhost:8086/write?db=test' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'"
|
||||||
~);
|
)
|
||||||
$one->succeed(q~
|
|
||||||
curl -GET 'http://localhost:8086/query' --data-urlencode "db=test" --data-urlencode "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region\"='us-west'" | grep "0\.64"
|
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
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user