git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/tests: add couchdb test
commit71b8437e2c6169210fdc1d528240c8b1ea0193ac authorFranz Pletz <fpletz@fnordicwalking.de> dateSun 19 Nov 2017, 17:36 (9 years ago) parenta86d0d6
2 files changed+57
nixos/release.nix+1 nixos/tests/couchdb.nix+56
nixos/release.nix+1
@@ -235,6 +235,7 @@ in rec {
235235 tests.containers-tmpfs = callTest tests/containers-tmpfs.nix {};
236236 tests.containers-hosts = callTest tests/containers-hosts.nix {};
237237 tests.containers-macvlans = callTest tests/containers-macvlans.nix {};
238+ tests.couchdb = callTest tests/couchdb.nix {};
238239 tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; });
239240 tests.docker-edge = hydraJob (import tests/docker-edge.nix { system = "x86_64-linux"; });
240241 tests.dovecot = callTest tests/dovecot.nix {};
nixos/tests/couchdb.nixnew file+56
@@ -0,0 +1,56 @@
1+import ./make-test.nix ({ pkgs, lib, ...}:
2+
3+with lib;
4+
5+{
6+ name = "couchdb";
7+ meta = with pkgs.stdenv.lib.maintainers; {
8+ maintainers = [ fpletz ];
9+ };
10+
11+ nodes = {
12+ couchdb1 =
13+ { pkgs, config, ... }:
14+
15+ { environment.systemPackages = with pkgs; [ jq ];
16+ services.couchdb.enable = true;
17+ };
18+
19+ couchdb2 =
20+ { pkgs, config, ... }:
21+
22+ { environment.systemPackages = with pkgs; [ jq ];
23+ services.couchdb.enable = true;
24+ services.couchdb.package = pkgs.couchdb2;
25+ };
26+ };
27+
28+ testScript = let
29+ curlJqCheck = action: path: jqexpr: result:
30+ pkgs.writeScript "curl-jq-check-${action}-${path}.sh" ''
31+ RESULT=$(curl -X ${action} http://127.0.0.1:5984/${path} | jq -r '${jqexpr}')
32+ echo $RESULT >&2
33+ if [ "$RESULT" != "${result}" ]; then
34+ exit 1
35+ fi
36+ '';
37+ in ''
38+ startAll;
39+
40+ $couchdb1->waitForUnit("couchdb.service");
41+ $couchdb1->waitUntilSucceeds("${curlJqCheck "GET" "" ".couchdb" "Welcome"}");
42+ $couchdb1->waitUntilSucceeds("${curlJqCheck "GET" "_all_dbs" ". | length" "2"}");
43+ $couchdb1->succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}");
44+ $couchdb1->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "3"}");
45+ $couchdb1->succeed("${curlJqCheck "DELETE" "foo" ".ok" "true"}");
46+ $couchdb1->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "2"}");
47+
48+ $couchdb2->waitForUnit("couchdb.service");
49+ $couchdb2->waitUntilSucceeds("${curlJqCheck "GET" "" ".couchdb" "Welcome"}");
50+ $couchdb2->waitUntilSucceeds("${curlJqCheck "GET" "_all_dbs" ". | length" "0"}");
51+ $couchdb2->succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}");
52+ $couchdb2->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "1"}");
53+ $couchdb2->succeed("${curlJqCheck "DELETE" "foo" ".ok" "true"}");
54+ $couchdb2->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "0"}");
55+ '';
56+})