python.pkgs.pyqt5: 5.14.2 -> 5.15.0
[NixPkgs.git] / nixos / tests / couchdb.nix
blob10e95701acdbe283261377230a4e56668c78fa57
1 import ./make-test-python.nix ({ pkgs, lib, ...}:
3 with lib;
6   name = "couchdb";
7   meta = with pkgs.stdenv.lib.maintainers; {
8     maintainers = [ fpletz ];
9   };
11   nodes = {
12     couchdb1 =
13       { pkgs, ... }:
15       { environment.systemPackages = with pkgs; [ jq ];
16         services.couchdb.enable = true;
17       };
19     couchdb2 =
20       { pkgs, ... }:
22       { environment.systemPackages = with pkgs; [ jq ];
23         services.couchdb.enable = true;
24         services.couchdb.package = pkgs.couchdb2;
25       };
26   };
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     start_all()
40     couchdb1.wait_for_unit("couchdb.service")
41     couchdb1.wait_until_succeeds(
42         "${curlJqCheck "GET" "" ".couchdb" "Welcome"}"
43     )
44     couchdb1.wait_until_succeeds(
45         "${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"
46     )
47     couchdb1.succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}")
48     couchdb1.succeed(
49         "${curlJqCheck "GET" "_all_dbs" ". | length" "3"}"
50     )
51     couchdb1.succeed(
52         "${curlJqCheck "DELETE" "foo" ".ok" "true"}"
53     )
54     couchdb1.succeed(
55         "${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"
56     )
58     couchdb2.wait_for_unit("couchdb.service")
59     couchdb2.wait_until_succeeds(
60         "${curlJqCheck "GET" "" ".couchdb" "Welcome"}"
61     )
62     couchdb2.wait_until_succeeds(
63         "${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"
64     )
65     couchdb2.succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}")
66     couchdb2.succeed(
67         "${curlJqCheck "GET" "_all_dbs" ". | length" "1"}"
68     )
69     couchdb2.succeed(
70         "${curlJqCheck "DELETE" "foo" ".ok" "true"}"
71     )
72     couchdb2.succeed(
73         "${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"
74     )
75   '';