git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit44641ed00bf3b1d5914a685137f16910f6454951 authorNathan Smyth <nathan.smyth@mongodb.com> dateSun 4 Aug 2019, 16:25 (7 years ago) parent165d8bd
5 files changed+94−80
nixos/tests/mongodb.nix+37−37 pkgs/servers/nosql/mongodb/mongodb.nix+20−15 pkgs/servers/nosql/mongodb/v3_4.nix+12−9 pkgs/servers/nosql/mongodb/v3_6.nix+12−9 pkgs/servers/nosql/mongodb/v4_0.nix+13−10
nixos/tests/mongodb.nix+37−37
@@ -1,42 +1,42 @@
11# This test start mongodb, runs a query using mongo shell
22
3−import ./make-test-python.nix ({ pkgs, ...} : let
4− testQuery = pkgs.writeScript "nixtest.js" ''
5− db.greetings.insert({ "greeting": "hello" });
6− print(db.greetings.findOne().greeting);
7− '';
8−in {
9− name = "mongodb";
10− meta = with pkgs.stdenv.lib.maintainers; {
11− maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
12− };
3+import ./make-test.nix ({ pkgs, ... }:
4+ let
5+ testQuery = pkgs.writeScript "nixtest.js" ''
6+ db.greetings.insert({ "greeting": "hello" });
7+ print(db.greetings.findOne().greeting);
8+ '';
139
14− nodes = {
15− one =
16− { ... }:
17− {
18− services = {
19− mongodb.enable = true;
20− mongodb.enableAuth = true;
21− mongodb.initialRootPassword = "root";
22− mongodb.initialScript = pkgs.writeText "mongodb_initial.js" ''
23− db = db.getSiblingDB("nixtest");
24− db.createUser({user:"nixtest",pwd:"nixtest",roles:[{role:"readWrite",db:"nixtest"}]});
25− '';
26− mongodb.extraConfig = ''
27− # Allow starting engine with only a small virtual disk
28− storage.journal.enabled: false
29− storage.mmapv1.smallFiles: true
30− '';
31− };
32− };
10+ runMongoDBTest = pkg: ''
11+ $node->execute("(rm -rf data || true) && mkdir data");
12+ $node->execute("${pkg}/bin/mongod --fork --logpath logs --dbpath data");
13+ $node->waitForOpenPort(27017);
14+
15+ $node->succeed("mongo ${testQuery}") =~ /hello/ or die;
16+
17+ $node->execute("${pkg}/bin/mongod --shutdown --dbpath data");
18+ $node->waitForClosedPort(27017);
19+ '';
20+
21+ in {
22+ name = "mongodb";
23+ meta = with pkgs.stdenv.lib.maintainers; {
24+ maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
25+ };
26+
27+ nodes = {
28+ node = {...}: {
29+ environment.systemPackages = with pkgs; [
30+# mongodb-3_4
31+ mongodb-3_6
32+ mongodb-4_0
33+ ];
34+ };
3335 };
3436
35− testScript = ''
36− start_all()
37− one.wait_for_unit("mongodb.service")
38− one.succeed(
39− "mongo -u nixtest -p nixtest nixtest ${testQuery} | grep -q hello"
40− )
41− '';
42−})
37+ testScript = "$node->start;"
38+# + runMongoDBTest pkgs.mongodb-3_4
39+ + runMongoDBTest pkgs.mongodb-3_6
40+ + runMongoDBTest pkgs.mongodb-4_0
41+ + "$node->shutdown;";
42+ })
pkgs/servers/nosql/mongodb/mongodb.nix+20−15
@@ -1,26 +1,25 @@
1−{ stdenv, fetchurl, fetchpatch, scons, boost, gperftools, pcre-cpp, snappy, zlib,
2− libyamlcpp, sasl, openssl, libpcap, wiredtiger, Security, python27, curl, CoreFoundation, cctools
3−}:
1+{ stdenv, fetchurl, scons, boost, gperftools, pcre-cpp, snappy, zlib, libyamlcpp
2+, sasl, openssl, libpcap, python27, curl, Security, CoreFoundation, cctools }:
43
54# Note:
65# The command line tools are written in Go as part of a different package (mongodb-tools)
76
87with stdenv.lib;
98
10−{ version, sha256, patches ? [ ] }@args:
9+{ version, sha256, patches ? [] }@args:
1110
1211let
1312 python = python27.withPackages (ps: with ps; [ pyyaml typing cheetah ]);
1413 system-libraries = [
15− "pcre"
16− #"asio" -- XXX use package?
17− #"wiredtiger"
1814 "boost"
15+ "pcre"
1916 "snappy"
17+ "yaml"
2018 "zlib"
21− #"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
19+ #"asio" -- XXX use package?
2220 #"stemmer" -- not nice to package yet (no versioning, no makefile, no shared libs).
23− "yaml"
21+ #"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
22+ #"wiredtiger"
2423 ] ++ optionals stdenv.isLinux [ "tcmalloc" ];
2524 inherit (stdenv.lib) systems subtractLists;
2625
@@ -35,8 +34,18 @@ in stdenv.mkDerivation rec {
3534
3635 nativeBuildInputs = [ scons ];
3736 buildInputs = [
38− sasl boost gperftools pcre-cpp snappy
39− zlib libyamlcpp sasl openssl.dev openssl.out libpcap python curl
37+ boost
38+ curl
39+ gperftools
40+ libpcap
41+ libyamlcpp
42+ openssl.dev
43+ openssl.out
44+ pcre-cpp
45+ python
46+ sasl
47+ snappy
48+ zlib
4049 ] ++ stdenv.lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ];
4150
4251 # MongoDB keeps track of its build parameters, which tricks nix into
@@ -84,10 +93,6 @@ in stdenv.mkDerivation rec {
8493 sconsFlags+=" CXX=$CXX"
8594 '' + optionalString stdenv.isAarch64 ''
8695 sconsFlags+=" CCFLAGS='-march=armv8-a+crc'"
87− '' + optionalString stdenv.isDarwin ''
88− sconsFlags+=" CPPPATH=${openssl.dev}/include"
89− '' + optionalString stdenv.isDarwin ''
90− sconsFlags+=" LIBPATH=${openssl.out}/lib"
9196 '';
9297
9398 preInstall = ''
pkgs/servers/nosql/mongodb/v3_4.nix+12−9
@@ -1,12 +1,15 @@
11{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
22
33let
4− buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; };
5−in
6− buildMongoDB {
7− version = "3.4.22";
8− sha256 = "1rizrr69b26y7fb973n52hk387sf3mxzqg8wka4f3zdjdidfyiny";
9− patches = [
10− ./forget-build-dependencies-3-4.patch
11− ];
12− }
4+ buildMongoDB = callPackage ./mongodb.nix {
5+ inherit sasl;
6+ inherit boost;
7+ inherit Security;
8+ inherit CoreFoundation;
9+ inherit cctools;
10+ };
11+in buildMongoDB {
12+ version = "3.4.22";
13+ sha256 = "1rizrr69b26y7fb973n52hk387sf3mxzqg8wka4f3zdjdidfyiny";
14+ patches = [ ./forget-build-dependencies-3-4.patch ];
15+}
pkgs/servers/nosql/mongodb/v3_6.nix+12−9
@@ -1,12 +1,15 @@
11{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
22
33let
4− buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; };
5−in
6− buildMongoDB {
7− version = "3.6.13";
8− sha256 = "1mbvk4bmabrswjdm01jssxcygjpq5799zqyx901nsi12vlcymwg4";
9− patches = [
10− ./forget-build-dependencies.patch
11− ];
12− }
4+ buildMongoDB = callPackage ./mongodb.nix {
5+ inherit sasl;
6+ inherit boost;
7+ inherit Security;
8+ inherit CoreFoundation;
9+ inherit cctools;
10+ };
11+in buildMongoDB {
12+ version = "3.6.13";
13+ sha256 = "1mbvk4bmabrswjdm01jssxcygjpq5799zqyx901nsi12vlcymwg4";
14+ patches = [ ./forget-build-dependencies.patch ];
15+}
pkgs/servers/nosql/mongodb/v4_0.nix+13−10
@@ -1,13 +1,16 @@
11{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
22
33let
4− buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; };
5−in
6− buildMongoDB {
7− version = "4.0.11";
8− sha256 = "0kry8kzzpah0l7j8xa333y1ixwvarc28ip3f6lx5590yy11j8ry2";
9− patches = [
10− ./forget-build-dependencies.patch
11− ./mozjs-45_fix-3-byte-opcode.patch
12− ];
13− }
4+ buildMongoDB = callPackage ./mongodb.nix {
5+ inherit sasl;
6+ inherit boost;
7+ inherit Security;
8+ inherit CoreFoundation;
9+ inherit cctools;
10+ };
11+in buildMongoDB {
12+ version = "4.0.11";
13+ sha256 = "0kry8kzzpah0l7j8xa333y1ixwvarc28ip3f6lx5590yy11j8ry2";
14+ patches =
15+ [ ./forget-build-dependencies.patch ./mozjs-45_fix-3-byte-opcode.patch ];
16+}