summary refs log tree commit diff
diff options
context:
space:
mode:
authorNathan Smyth <nathan.smyth@mongodb.com>2019-08-04 16:25:56 +1000
committerMaximilian Bosch <maximilian@mbosch.me>2020-03-26 14:02:49 +0100
commit44641ed00bf3b1d5914a685137f16910f6454951 (patch)
tree947500bd346d326c3021e85c9f44fd5ba498a147
parent165d8bda8265ca9c247d1ab5e1137117c3236e25 (diff)
downloadnixpkgs-44641ed00bf3b1d5914a685137f16910f6454951.tar
nixpkgs-44641ed00bf3b1d5914a685137f16910f6454951.tar.gz
nixpkgs-44641ed00bf3b1d5914a685137f16910f6454951.tar.bz2
nixpkgs-44641ed00bf3b1d5914a685137f16910f6454951.tar.lz
nixpkgs-44641ed00bf3b1d5914a685137f16910f6454951.tar.xz
nixpkgs-44641ed00bf3b1d5914a685137f16910f6454951.tar.zst
nixpkgs-44641ed00bf3b1d5914a685137f16910f6454951.zip
nixos/tests/mongodb: test against mongodb versions 3.4, 3.6, 4.0
Now has tests for 3.4, 3.6, 4.0. Has some duplication, but it appears to
work on my machine.
-rw-r--r--nixos/tests/mongodb.nix74
-rw-r--r--pkgs/servers/nosql/mongodb/mongodb.nix35
-rw-r--r--pkgs/servers/nosql/mongodb/v3_4.nix21
-rw-r--r--pkgs/servers/nosql/mongodb/v3_6.nix21
-rw-r--r--pkgs/servers/nosql/mongodb/v4_0.nix23
5 files changed, 94 insertions, 80 deletions
diff --git a/nixos/tests/mongodb.nix b/nixos/tests/mongodb.nix
index 9ebf84eed23..dfb23ce6c0d 100644
--- a/nixos/tests/mongodb.nix
+++ b/nixos/tests/mongodb.nix
@@ -1,42 +1,42 @@
 # This test start mongodb, runs a query using mongo shell
 
-import ./make-test-python.nix ({ pkgs, ...} : let
-  testQuery = pkgs.writeScript "nixtest.js" ''
-    db.greetings.insert({ "greeting": "hello" });
-    print(db.greetings.findOne().greeting);
-  '';
-in {
-  name = "mongodb";
-  meta = with pkgs.stdenv.lib.maintainers; {
-    maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
-  };
+import ./make-test.nix ({ pkgs, ... }:
+  let
+    testQuery = pkgs.writeScript "nixtest.js" ''
+      db.greetings.insert({ "greeting": "hello" });
+      print(db.greetings.findOne().greeting);
+    '';
 
-  nodes = {
-    one =
-      { ... }:
-        {
-          services = {
-           mongodb.enable = true;
-           mongodb.enableAuth = true;
-           mongodb.initialRootPassword = "root";
-           mongodb.initialScript = pkgs.writeText "mongodb_initial.js" ''
-             db = db.getSiblingDB("nixtest");
-             db.createUser({user:"nixtest",pwd:"nixtest",roles:[{role:"readWrite",db:"nixtest"}]});
-           '';
-           mongodb.extraConfig = ''
-             # Allow starting engine with only a small virtual disk
-             storage.journal.enabled: false
-             storage.mmapv1.smallFiles: true
-           '';
-          };
-        };
+    runMongoDBTest = pkg: ''
+      $node->execute("(rm -rf data || true) && mkdir data");
+      $node->execute("${pkg}/bin/mongod --fork --logpath logs --dbpath data");
+      $node->waitForOpenPort(27017);
+
+      $node->succeed("mongo ${testQuery}") =~ /hello/ or die;
+
+      $node->execute("${pkg}/bin/mongod --shutdown --dbpath data");
+      $node->waitForClosedPort(27017);
+    '';
+
+  in {
+    name = "mongodb";
+    meta = with pkgs.stdenv.lib.maintainers; {
+      maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
+    };
+
+    nodes = {
+      node = {...}: {
+        environment.systemPackages = with pkgs; [
+#          mongodb-3_4
+          mongodb-3_6
+          mongodb-4_0
+        ];
+      };
     };
 
-  testScript = ''
-    start_all()
-    one.wait_for_unit("mongodb.service")
-    one.succeed(
-        "mongo -u nixtest -p nixtest nixtest ${testQuery} | grep -q hello"
-    )
-  '';
-})
+    testScript = "$node->start;" 
+#      + runMongoDBTest pkgs.mongodb-3_4
+      + runMongoDBTest pkgs.mongodb-3_6 
+      + runMongoDBTest pkgs.mongodb-4_0
+      + "$node->shutdown;";
+  })
diff --git a/pkgs/servers/nosql/mongodb/mongodb.nix b/pkgs/servers/nosql/mongodb/mongodb.nix
index 3824fc6d1a7..da4b46a69da 100644
--- a/pkgs/servers/nosql/mongodb/mongodb.nix
+++ b/pkgs/servers/nosql/mongodb/mongodb.nix
@@ -1,26 +1,25 @@
-{ stdenv, fetchurl, fetchpatch, scons, boost, gperftools, pcre-cpp, snappy, zlib,
-  libyamlcpp, sasl, openssl, libpcap, wiredtiger, Security, python27, curl, CoreFoundation, cctools
-}:
+{ stdenv, fetchurl, scons, boost, gperftools, pcre-cpp, snappy, zlib, libyamlcpp
+, sasl, openssl, libpcap, python27, curl, Security, CoreFoundation, cctools }:
 
 # Note:
 # The command line tools are written in Go as part of a different package (mongodb-tools)
 
 with stdenv.lib;
 
-{ version, sha256, patches ? [ ] }@args:
+{ version, sha256, patches ? [] }@args:
 
 let
   python = python27.withPackages (ps: with ps; [ pyyaml typing cheetah ]);
   system-libraries = [
-    "pcre"
-    #"asio" -- XXX use package?
-    #"wiredtiger"
     "boost"
+    "pcre"
     "snappy"
+    "yaml"
     "zlib"
-    #"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
+    #"asio" -- XXX use package?
     #"stemmer"  -- not nice to package yet (no versioning, no makefile, no shared libs).
-    "yaml"
+    #"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
+    #"wiredtiger"
   ] ++ optionals stdenv.isLinux [ "tcmalloc" ];
   inherit (stdenv.lib) systems subtractLists;
 
@@ -35,8 +34,18 @@ in stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ scons ];
   buildInputs = [
-    sasl boost gperftools pcre-cpp snappy
-    zlib libyamlcpp sasl openssl.dev openssl.out libpcap python curl
+    boost
+    curl
+    gperftools
+    libpcap
+    libyamlcpp
+    openssl.dev
+    openssl.out
+    pcre-cpp
+    python
+    sasl
+    snappy
+    zlib
   ] ++ stdenv.lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ];
 
   # MongoDB keeps track of its build parameters, which tricks nix into
@@ -84,10 +93,6 @@ in stdenv.mkDerivation rec {
     sconsFlags+=" CXX=$CXX"
   '' + optionalString stdenv.isAarch64 ''
     sconsFlags+=" CCFLAGS='-march=armv8-a+crc'"
-  '' + optionalString stdenv.isDarwin ''
-    sconsFlags+=" CPPPATH=${openssl.dev}/include"
-  '' + optionalString stdenv.isDarwin ''
-    sconsFlags+=" LIBPATH=${openssl.out}/lib"
   '';
 
   preInstall = ''
diff --git a/pkgs/servers/nosql/mongodb/v3_4.nix b/pkgs/servers/nosql/mongodb/v3_4.nix
index fb124a6b2e5..113fa0680c3 100644
--- a/pkgs/servers/nosql/mongodb/v3_4.nix
+++ b/pkgs/servers/nosql/mongodb/v3_4.nix
@@ -1,12 +1,15 @@
 { stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
 
 let
-  buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; };
-in
-  buildMongoDB {
-    version = "3.4.22";
-    sha256 = "1rizrr69b26y7fb973n52hk387sf3mxzqg8wka4f3zdjdidfyiny";
-    patches = [
-      ./forget-build-dependencies-3-4.patch
-    ];
-  }
+  buildMongoDB = callPackage ./mongodb.nix {
+    inherit sasl;
+    inherit boost;
+    inherit Security;
+    inherit CoreFoundation;
+    inherit cctools;
+  };
+in buildMongoDB {
+  version = "3.4.22";
+  sha256 = "1rizrr69b26y7fb973n52hk387sf3mxzqg8wka4f3zdjdidfyiny";
+  patches = [ ./forget-build-dependencies-3-4.patch ];
+}
diff --git a/pkgs/servers/nosql/mongodb/v3_6.nix b/pkgs/servers/nosql/mongodb/v3_6.nix
index 412d72b4e66..8da901c00c5 100644
--- a/pkgs/servers/nosql/mongodb/v3_6.nix
+++ b/pkgs/servers/nosql/mongodb/v3_6.nix
@@ -1,12 +1,15 @@
 { stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
 
 let
-  buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; };
-in
-  buildMongoDB {
-    version = "3.6.13";
-    sha256 = "1mbvk4bmabrswjdm01jssxcygjpq5799zqyx901nsi12vlcymwg4";
-    patches = [
-      ./forget-build-dependencies.patch
-    ];
-  }
+  buildMongoDB = callPackage ./mongodb.nix {
+    inherit sasl;
+    inherit boost;
+    inherit Security;
+    inherit CoreFoundation;
+    inherit cctools;
+  };
+in buildMongoDB {
+  version = "3.6.13";
+  sha256 = "1mbvk4bmabrswjdm01jssxcygjpq5799zqyx901nsi12vlcymwg4";
+  patches = [ ./forget-build-dependencies.patch ];
+}
diff --git a/pkgs/servers/nosql/mongodb/v4_0.nix b/pkgs/servers/nosql/mongodb/v4_0.nix
index 819d41cd17e..95606317f31 100644
--- a/pkgs/servers/nosql/mongodb/v4_0.nix
+++ b/pkgs/servers/nosql/mongodb/v4_0.nix
@@ -1,13 +1,16 @@
 { stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
 
 let
-  buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; };
-in
-  buildMongoDB {
-    version = "4.0.11";
-    sha256 = "0kry8kzzpah0l7j8xa333y1ixwvarc28ip3f6lx5590yy11j8ry2";
-    patches = [
-      ./forget-build-dependencies.patch
-      ./mozjs-45_fix-3-byte-opcode.patch
-    ];
-  }
+  buildMongoDB = callPackage ./mongodb.nix {
+    inherit sasl;
+    inherit boost;
+    inherit Security;
+    inherit CoreFoundation;
+    inherit cctools;
+  };
+in buildMongoDB {
+  version = "4.0.11";
+  sha256 = "0kry8kzzpah0l7j8xa333y1ixwvarc28ip3f6lx5590yy11j8ry2";
+  patches =
+    [ ./forget-build-dependencies.patch ./mozjs-45_fix-3-byte-opcode.patch ];
+}