summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2019-11-24 20:21:06 +0100
committerFlorian Klink <flokli@flokli.de>2019-11-24 20:21:06 +0100
commitaa5f701e880510f1663f484d391408de377b8c17 (patch)
treef873f85385c859131b753661a9c17ecd374a0a2f /nixos
parent2d49ee8727920dcc7c863e75a8f37dc531ac7033 (diff)
downloadnixpkgs-aa5f701e880510f1663f484d391408de377b8c17.tar
nixpkgs-aa5f701e880510f1663f484d391408de377b8c17.tar.gz
nixpkgs-aa5f701e880510f1663f484d391408de377b8c17.tar.bz2
nixpkgs-aa5f701e880510f1663f484d391408de377b8c17.tar.lz
nixpkgs-aa5f701e880510f1663f484d391408de377b8c17.tar.xz
nixpkgs-aa5f701e880510f1663f484d391408de377b8c17.tar.zst
nixpkgs-aa5f701e880510f1663f484d391408de377b8c17.zip
nixosTests.influxdb: port to python
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/influxdb.nix33
1 files changed, 20 insertions, 13 deletions
diff --git a/nixos/tests/influxdb.nix b/nixos/tests/influxdb.nix
index 61201202204..04ef8046101 100644
--- a/nixos/tests/influxdb.nix
+++ b/nixos/tests/influxdb.nix
@@ -1,6 +1,6 @@
 # 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";
   meta = with pkgs.stdenv.lib.maintainers; {
     maintainers = [ offline ];
@@ -9,25 +9,32 @@ import ./make-test.nix ({ pkgs, ...} : {
   nodes = {
     one = { ... }: {
       services.influxdb.enable = true;
+      environment.systemPackages = [ pkgs.httpie ];
     };
   };
 
   testScript = ''
-    startAll;
-  
-    $one->waitForUnit("influxdb.service");
+    import shlex
+
+    start_all()
+
+    one.wait_for_unit("influxdb.service")
 
     # create database
-    $one->succeed(q~
-      curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE test"
-    ~);
+    one.succeed(
+        "curl -XPOST http://localhost:8086/query --data-urlencode 'q=CREATE DATABASE test'"
+    )
 
     # write some points and run simple query
-    $one->succeed(q~
-      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"
-    ~);
+    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
   '';
 })