aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/tests/influxdb.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/tests/influxdb.nix')
-rw-r--r--nixpkgs/nixos/tests/influxdb.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/nixpkgs/nixos/tests/influxdb.nix b/nixpkgs/nixos/tests/influxdb.nix
new file mode 100644
index 00000000000..04ef8046101
--- /dev/null
+++ b/nixpkgs/nixos/tests/influxdb.nix
@@ -0,0 +1,40 @@
+# This test runs influxdb and checks if influxdb is up and running
+
+import ./make-test-python.nix ({ pkgs, ...} : {
+ name = "influxdb";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ offline ];
+ };
+
+ nodes = {
+ one = { ... }: {
+ services.influxdb.enable = true;
+ environment.systemPackages = [ pkgs.httpie ];
+ };
+ };
+
+ testScript = ''
+ import shlex
+
+ start_all()
+
+ one.wait_for_unit("influxdb.service")
+
+ # create database
+ one.succeed(
+ "curl -XPOST http://localhost:8086/query --data-urlencode 'q=CREATE DATABASE test'"
+ )
+
+ # write some points and run simple query
+ 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
+ '';
+})