nixos/tests/grafana: port to python

This commit is contained in:
WilliButz 2019-11-06 16:50:33 +01:00
parent 9a7101c999
commit 34755fb5e4
No known key found for this signature in database
GPG Key ID: 92582A10F1179CB2

View File

@ -1,4 +1,4 @@
import ./make-test.nix ({ lib, pkgs, ... }: import ./make-test-python.nix ({ lib, pkgs, ... }:
let let
inherit (lib) mkMerge nameValuePair maintainers; inherit (lib) mkMerge nameValuePair maintainers;
@ -64,28 +64,34 @@ in {
inherit nodes; inherit nodes;
testScript = '' testScript = ''
startAll(); start_all()
subtest "Grafana sqlite", sub { with subtest("Successful API query as admin user with sqlite db"):
$sqlite->waitForUnit("grafana.service"); sqlite.wait_for_unit("grafana.service")
$sqlite->waitForOpenPort(3000); sqlite.wait_for_open_port(3000)
$sqlite->succeed("curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"); sqlite.succeed(
}; "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"
)
sqlite.shutdown()
subtest "Grafana postgresql", sub { with subtest("Successful API query as admin user with postgresql db"):
$postgresql->waitForUnit("grafana.service"); postgresql.wait_for_unit("grafana.service")
$postgresql->waitForUnit("postgresql.service"); postgresql.wait_for_unit("postgresql.service")
$postgresql->waitForOpenPort(3000); postgresql.wait_for_open_port(3000)
$postgresql->waitForOpenPort(5432); postgresql.wait_for_open_port(5432)
$postgresql->succeed("curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"); postgresql.succeed(
}; "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"
)
postgresql.shutdown()
subtest "Grafana mysql", sub { with subtest("Successful API query as admin user with mysql db"):
$mysql->waitForUnit("grafana.service"); mysql.wait_for_unit("grafana.service")
$mysql->waitForUnit("mysql.service"); mysql.wait_for_unit("mysql.service")
$mysql->waitForOpenPort(3000); mysql.wait_for_open_port(3000)
$mysql->waitForOpenPort(3306); mysql.wait_for_open_port(3306)
$mysql->succeed("curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"); mysql.succeed(
}; "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1:3000/api/org/users | grep -q testadmin\@localhost"
)
mysql.shutdown()
''; '';
}) })