summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorDamien Cassou <damien@cassou.me>2020-09-11 17:47:47 +0200
committerGitHub <noreply@github.com>2020-09-11 17:47:47 +0200
commit607f5a6755dddb0b6ecce5bb227234db1a527501 (patch)
tree31b2a9ba9f1fb549ec7d6c54fe03b9b051b3fe66 /nixos/tests
parent5e0112b7ef581053fcd15a44aa9f104b8df186e2 (diff)
parent0ef1be0aa1f9a12ffe0bf1a194888d845fdc3532 (diff)
downloadnixpkgs-607f5a6755dddb0b6ecce5bb227234db1a527501.tar
nixpkgs-607f5a6755dddb0b6ecce5bb227234db1a527501.tar.gz
nixpkgs-607f5a6755dddb0b6ecce5bb227234db1a527501.tar.bz2
nixpkgs-607f5a6755dddb0b6ecce5bb227234db1a527501.tar.lz
nixpkgs-607f5a6755dddb0b6ecce5bb227234db1a527501.tar.xz
nixpkgs-607f5a6755dddb0b6ecce5bb227234db1a527501.tar.zst
nixpkgs-607f5a6755dddb0b6ecce5bb227234db1a527501.zip
Merge pull request #84246 from lostnet/couchdbpr
couchdb: add support for version 3.0.0
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/couchdb.nix80
1 files changed, 51 insertions, 29 deletions
diff --git a/nixos/tests/couchdb.nix b/nixos/tests/couchdb.nix
index 10e95701acd..57b79e29b43 100644
--- a/nixos/tests/couchdb.nix
+++ b/nixos/tests/couchdb.nix
@@ -1,4 +1,19 @@
-import ./make-test-python.nix ({ pkgs, lib, ...}:
+let
+
+  makeNode = couchpkg: user: passwd:
+    { pkgs, ... } :
+
+      { environment.systemPackages = with pkgs; [ jq ];
+        services.couchdb.enable = true;
+        services.couchdb.package = couchpkg;
+        services.couchdb.adminUser = user;
+        services.couchdb.adminPass = passwd;
+      };
+  testuser = "testadmin";
+  testpass = "cowabunga";
+  testlogin = "${testuser}:${testpass}@";
+
+in import ./make-test-python.nix ({ pkgs, lib, ...}:
 
 with lib;
 
@@ -9,26 +24,15 @@ with lib;
   };
 
   nodes = {
-    couchdb1 =
-      { pkgs, ... }:
-
-      { environment.systemPackages = with pkgs; [ jq ];
-        services.couchdb.enable = true;
-      };
-
-    couchdb2 =
-      { pkgs, ... }:
-
-      { environment.systemPackages = with pkgs; [ jq ];
-        services.couchdb.enable = true;
-        services.couchdb.package = pkgs.couchdb2;
-      };
+    couchdb1 = makeNode pkgs.couchdb testuser testpass;
+    couchdb2 = makeNode pkgs.couchdb2 testuser testpass;
+    couchdb3 = makeNode pkgs.couchdb3 testuser testpass;
   };
 
   testScript = let
-    curlJqCheck = action: path: jqexpr: result:
+    curlJqCheck = login: 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}')
+        RESULT=$(curl -X ${action} http://${login}127.0.0.1:5984/${path} | jq -r '${jqexpr}')
         echo $RESULT >&2
         if [ "$RESULT" != "${result}" ]; then
           exit 1
@@ -39,38 +43,56 @@ with lib;
 
     couchdb1.wait_for_unit("couchdb.service")
     couchdb1.wait_until_succeeds(
-        "${curlJqCheck "GET" "" ".couchdb" "Welcome"}"
+        "${curlJqCheck "" "GET" "" ".couchdb" "Welcome"}"
     )
     couchdb1.wait_until_succeeds(
-        "${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"
+        "${curlJqCheck "" "GET" "_all_dbs" ". | length" "2"}"
     )
-    couchdb1.succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}")
+    couchdb1.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
     couchdb1.succeed(
-        "${curlJqCheck "GET" "_all_dbs" ". | length" "3"}"
+        "${curlJqCheck "" "GET" "_all_dbs" ". | length" "3"}"
     )
     couchdb1.succeed(
-        "${curlJqCheck "DELETE" "foo" ".ok" "true"}"
+        "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
     )
     couchdb1.succeed(
-        "${curlJqCheck "GET" "_all_dbs" ". | length" "2"}"
+        "${curlJqCheck "" "GET" "_all_dbs" ". | length" "2"}"
     )
 
     couchdb2.wait_for_unit("couchdb.service")
     couchdb2.wait_until_succeeds(
-        "${curlJqCheck "GET" "" ".couchdb" "Welcome"}"
+        "${curlJqCheck "" "GET" "" ".couchdb" "Welcome"}"
     )
     couchdb2.wait_until_succeeds(
-        "${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"
+        "${curlJqCheck "" "GET" "_all_dbs" ". | length" "0"}"
     )
-    couchdb2.succeed("${curlJqCheck "PUT" "foo" ".ok" "true"}")
+    couchdb2.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
     couchdb2.succeed(
-        "${curlJqCheck "GET" "_all_dbs" ". | length" "1"}"
+        "${curlJqCheck "" "GET" "_all_dbs" ". | length" "1"}"
     )
     couchdb2.succeed(
-        "${curlJqCheck "DELETE" "foo" ".ok" "true"}"
+        "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
     )
     couchdb2.succeed(
-        "${curlJqCheck "GET" "_all_dbs" ". | length" "0"}"
+        "${curlJqCheck "" "GET" "_all_dbs" ". | length" "0"}"
+    )
+
+    couchdb3.wait_for_unit("couchdb.service")
+    couchdb3.wait_until_succeeds(
+        "${curlJqCheck testlogin "GET" "" ".couchdb" "Welcome"}"
+    )
+    couchdb3.wait_until_succeeds(
+        "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
+    )
+    couchdb3.succeed("${curlJqCheck testlogin "PUT" "foo" ".ok" "true"}")
+    couchdb3.succeed(
+        "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "1"}"
+    )
+    couchdb3.succeed(
+        "${curlJqCheck testlogin "DELETE" "foo" ".ok" "true"}"
+    )
+    couchdb3.succeed(
+        "${curlJqCheck testlogin "GET" "_all_dbs" ". | length" "0"}"
     )
   '';
 })