diff options
author | Matthew Justin Bauer <mjbauer95@gmail.com> | 2018-04-21 14:53:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-21 14:53:23 -0500 |
commit | 1eea73eaa8185bd6f4fe2a0facc90652277ea399 (patch) | |
tree | fa5e6aaccbdf1ef9f4e71d0f74225252a5c2168c /nixos/tests/couchdb.nix | |
parent | e70d293b6b5f236d69d559ccccdafba19c6d29c3 (diff) | |
parent | 17b73ff90cf9f7631e543d880540441bdf56d719 (diff) | |
download | nixlib-1eea73eaa8185bd6f4fe2a0facc90652277ea399.tar nixlib-1eea73eaa8185bd6f4fe2a0facc90652277ea399.tar.gz nixlib-1eea73eaa8185bd6f4fe2a0facc90652277ea399.tar.bz2 nixlib-1eea73eaa8185bd6f4fe2a0facc90652277ea399.tar.lz nixlib-1eea73eaa8185bd6f4fe2a0facc90652277ea399.tar.xz nixlib-1eea73eaa8185bd6f4fe2a0facc90652277ea399.tar.zst nixlib-1eea73eaa8185bd6f4fe2a0facc90652277ea399.zip |
Merge branch 'master' into feat/acme/delay
Diffstat (limited to 'nixos/tests/couchdb.nix')
-rw-r--r-- | nixos/tests/couchdb.nix | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/nixos/tests/couchdb.nix b/nixos/tests/couchdb.nix new file mode 100644 index 000000000000..a3f675236bc6 --- /dev/null +++ b/nixos/tests/couchdb.nix @@ -0,0 +1,56 @@ +import ./make-test.nix ({ pkgs, lib, ...}: + +with lib; + +{ + name = "couchdb"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ fpletz ]; + }; + + nodes = { + couchdb1 = + { pkgs, config, ... }: + + { environment.systemPackages = with pkgs; [ jq ]; + services.couchdb.enable = true; + }; + + couchdb2 = + { pkgs, config, ... }: + + { environment.systemPackages = with pkgs; [ jq ]; + services.couchdb.enable = true; + services.couchdb.package = pkgs.couchdb2; + }; + }; + + testScript = let + curlJqCheck = action: path: jqexpr: result: + pkgs.writeScript "curl-jq-check-${action}-${path}.sh" '' + RESULT=$(curl -X ${action} http://127.0.0.1:5984/${path} | jq -r '${jqexpr}') + echo $RESULT >&2 + if [ "$RESULT" != "${result}" ]; then + exit 1 + fi + ''; + in '' + startAll; + + $couchdb1->waitForUnit("couchdb.service"); + $couchdb1->waitUntilSucceeds("${curlJqCheck "GET" "" ".couchdb" "Welcome"}"); + $couchdb1->waitUntilSucceeds("${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"); + $couchdb1->succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}"); + $couchdb1->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "3"}"); + $couchdb1->succeed("${curlJqCheck "DELETE" "foo" ".ok" "true"}"); + $couchdb1->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"); + + $couchdb2->waitForUnit("couchdb.service"); + $couchdb2->waitUntilSucceeds("${curlJqCheck "GET" "" ".couchdb" "Welcome"}"); + $couchdb2->waitUntilSucceeds("${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"); + $couchdb2->succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}"); + $couchdb2->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "1"}"); + $couchdb2->succeed("${curlJqCheck "DELETE" "foo" ".ok" "true"}"); + $couchdb2->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"); + ''; +}) |