tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/tests: add couchdb test
Franz Pletz
8 years ago
71b8437e
a86d0d61
+57
2 changed files
expand all
collapse all
unified
split
nixos
release.nix
tests
couchdb.nix
+1
nixos/release.nix
···
235
235
tests.containers-tmpfs = callTest tests/containers-tmpfs.nix {};
236
236
tests.containers-hosts = callTest tests/containers-hosts.nix {};
237
237
tests.containers-macvlans = callTest tests/containers-macvlans.nix {};
238
238
+
tests.couchdb = callTest tests/couchdb.nix {};
238
239
tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; });
239
240
tests.docker-edge = hydraJob (import tests/docker-edge.nix { system = "x86_64-linux"; });
240
241
tests.dovecot = callTest tests/dovecot.nix {};
+56
nixos/tests/couchdb.nix
···
1
1
+
import ./make-test.nix ({ pkgs, lib, ...}:
2
2
+
3
3
+
with lib;
4
4
+
5
5
+
{
6
6
+
name = "couchdb";
7
7
+
meta = with pkgs.stdenv.lib.maintainers; {
8
8
+
maintainers = [ fpletz ];
9
9
+
};
10
10
+
11
11
+
nodes = {
12
12
+
couchdb1 =
13
13
+
{ pkgs, config, ... }:
14
14
+
15
15
+
{ environment.systemPackages = with pkgs; [ jq ];
16
16
+
services.couchdb.enable = true;
17
17
+
};
18
18
+
19
19
+
couchdb2 =
20
20
+
{ pkgs, config, ... }:
21
21
+
22
22
+
{ environment.systemPackages = with pkgs; [ jq ];
23
23
+
services.couchdb.enable = true;
24
24
+
services.couchdb.package = pkgs.couchdb2;
25
25
+
};
26
26
+
};
27
27
+
28
28
+
testScript = let
29
29
+
curlJqCheck = action: path: jqexpr: result:
30
30
+
pkgs.writeScript "curl-jq-check-${action}-${path}.sh" ''
31
31
+
RESULT=$(curl -X ${action} http://127.0.0.1:5984/${path} | jq -r '${jqexpr}')
32
32
+
echo $RESULT >&2
33
33
+
if [ "$RESULT" != "${result}" ]; then
34
34
+
exit 1
35
35
+
fi
36
36
+
'';
37
37
+
in ''
38
38
+
startAll;
39
39
+
40
40
+
$couchdb1->waitForUnit("couchdb.service");
41
41
+
$couchdb1->waitUntilSucceeds("${curlJqCheck "GET" "" ".couchdb" "Welcome"}");
42
42
+
$couchdb1->waitUntilSucceeds("${curlJqCheck "GET" "_all_dbs" ". | length" "2"}");
43
43
+
$couchdb1->succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}");
44
44
+
$couchdb1->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "3"}");
45
45
+
$couchdb1->succeed("${curlJqCheck "DELETE" "foo" ".ok" "true"}");
46
46
+
$couchdb1->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "2"}");
47
47
+
48
48
+
$couchdb2->waitForUnit("couchdb.service");
49
49
+
$couchdb2->waitUntilSucceeds("${curlJqCheck "GET" "" ".couchdb" "Welcome"}");
50
50
+
$couchdb2->waitUntilSucceeds("${curlJqCheck "GET" "_all_dbs" ". | length" "0"}");
51
51
+
$couchdb2->succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}");
52
52
+
$couchdb2->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "1"}");
53
53
+
$couchdb2->succeed("${curlJqCheck "DELETE" "foo" ".ok" "true"}");
54
54
+
$couchdb2->succeed("${curlJqCheck "GET" "_all_dbs" ". | length" "0"}");
55
55
+
'';
56
56
+
})