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.
This commit is contained in:
Nathan Smyth 2019-08-04 16:25:56 +10:00 committed by Maximilian Bosch
parent 165d8bda82
commit 44641ed00b
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E
5 changed files with 95 additions and 81 deletions

View File

@ -1,42 +1,42 @@
# This test start mongodb, runs a query using mongo shell # This test start mongodb, runs a query using mongo shell
import ./make-test-python.nix ({ pkgs, ...} : let import ./make-test.nix ({ pkgs, ... }:
testQuery = pkgs.writeScript "nixtest.js" '' let
db.greetings.insert({ "greeting": "hello" }); testQuery = pkgs.writeScript "nixtest.js" ''
print(db.greetings.findOne().greeting); 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 ];
};
nodes = { runMongoDBTest = pkg: ''
one = $node->execute("(rm -rf data || true) && mkdir data");
{ ... }: $node->execute("${pkg}/bin/mongod --fork --logpath logs --dbpath data");
{ $node->waitForOpenPort(27017);
services = {
mongodb.enable = true; $node->succeed("mongo ${testQuery}") =~ /hello/ or die;
mongodb.enableAuth = true;
mongodb.initialRootPassword = "root"; $node->execute("${pkg}/bin/mongod --shutdown --dbpath data");
mongodb.initialScript = pkgs.writeText "mongodb_initial.js" '' $node->waitForClosedPort(27017);
db = db.getSiblingDB("nixtest"); '';
db.createUser({user:"nixtest",pwd:"nixtest",roles:[{role:"readWrite",db:"nixtest"}]});
''; in {
mongodb.extraConfig = '' name = "mongodb";
# Allow starting engine with only a small virtual disk meta = with pkgs.stdenv.lib.maintainers; {
storage.journal.enabled: false maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
storage.mmapv1.smallFiles: true
'';
};
};
}; };
testScript = '' nodes = {
start_all() node = {...}: {
one.wait_for_unit("mongodb.service") environment.systemPackages = with pkgs; [
one.succeed( # mongodb-3_4
"mongo -u nixtest -p nixtest nixtest ${testQuery} | grep -q hello" mongodb-3_6
) mongodb-4_0
''; ];
}) };
};
testScript = "$node->start;"
# + runMongoDBTest pkgs.mongodb-3_4
+ runMongoDBTest pkgs.mongodb-3_6
+ runMongoDBTest pkgs.mongodb-4_0
+ "$node->shutdown;";
})

View File

@ -1,26 +1,25 @@
{ stdenv, fetchurl, fetchpatch, scons, boost, gperftools, pcre-cpp, snappy, zlib, { stdenv, fetchurl, scons, boost, gperftools, pcre-cpp, snappy, zlib, libyamlcpp
libyamlcpp, sasl, openssl, libpcap, wiredtiger, Security, python27, curl, CoreFoundation, cctools , sasl, openssl, libpcap, python27, curl, Security, CoreFoundation, cctools }:
}:
# Note: # Note:
# The command line tools are written in Go as part of a different package (mongodb-tools) # The command line tools are written in Go as part of a different package (mongodb-tools)
with stdenv.lib; with stdenv.lib;
{ version, sha256, patches ? [ ] }@args: { version, sha256, patches ? [] }@args:
let let
python = python27.withPackages (ps: with ps; [ pyyaml typing cheetah ]); python = python27.withPackages (ps: with ps; [ pyyaml typing cheetah ]);
system-libraries = [ system-libraries = [
"pcre"
#"asio" -- XXX use package?
#"wiredtiger"
"boost" "boost"
"pcre"
"snappy" "snappy"
"zlib"
#"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
#"stemmer" -- not nice to package yet (no versioning, no makefile, no shared libs).
"yaml" "yaml"
"zlib"
#"asio" -- XXX use package?
#"stemmer" -- not nice to package yet (no versioning, no makefile, no shared libs).
#"valgrind" -- mongodb only requires valgrind.h, which is vendored in the source.
#"wiredtiger"
] ++ optionals stdenv.isLinux [ "tcmalloc" ]; ] ++ optionals stdenv.isLinux [ "tcmalloc" ];
inherit (stdenv.lib) systems subtractLists; inherit (stdenv.lib) systems subtractLists;
@ -35,8 +34,18 @@ in stdenv.mkDerivation rec {
nativeBuildInputs = [ scons ]; nativeBuildInputs = [ scons ];
buildInputs = [ buildInputs = [
sasl boost gperftools pcre-cpp snappy boost
zlib libyamlcpp sasl openssl.dev openssl.out libpcap python curl curl
gperftools
libpcap
libyamlcpp
openssl.dev
openssl.out
pcre-cpp
python
sasl
snappy
zlib
] ++ stdenv.lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ]; ] ++ stdenv.lib.optionals stdenv.isDarwin [ Security CoreFoundation cctools ];
# MongoDB keeps track of its build parameters, which tricks nix into # MongoDB keeps track of its build parameters, which tricks nix into
@ -84,10 +93,6 @@ in stdenv.mkDerivation rec {
sconsFlags+=" CXX=$CXX" sconsFlags+=" CXX=$CXX"
'' + optionalString stdenv.isAarch64 '' '' + optionalString stdenv.isAarch64 ''
sconsFlags+=" CCFLAGS='-march=armv8-a+crc'" sconsFlags+=" CCFLAGS='-march=armv8-a+crc'"
'' + optionalString stdenv.isDarwin ''
sconsFlags+=" CPPPATH=${openssl.dev}/include"
'' + optionalString stdenv.isDarwin ''
sconsFlags+=" LIBPATH=${openssl.out}/lib"
''; '';
preInstall = '' preInstall = ''

View File

@ -1,12 +1,15 @@
{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }: { stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
let let
buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; }; buildMongoDB = callPackage ./mongodb.nix {
in inherit sasl;
buildMongoDB { inherit boost;
version = "3.4.22"; inherit Security;
sha256 = "1rizrr69b26y7fb973n52hk387sf3mxzqg8wka4f3zdjdidfyiny"; inherit CoreFoundation;
patches = [ inherit cctools;
./forget-build-dependencies-3-4.patch };
]; in buildMongoDB {
} version = "3.4.22";
sha256 = "1rizrr69b26y7fb973n52hk387sf3mxzqg8wka4f3zdjdidfyiny";
patches = [ ./forget-build-dependencies-3-4.patch ];
}

View File

@ -1,12 +1,15 @@
{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }: { stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
let let
buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; }; buildMongoDB = callPackage ./mongodb.nix {
in inherit sasl;
buildMongoDB { inherit boost;
version = "3.6.13"; inherit Security;
sha256 = "1mbvk4bmabrswjdm01jssxcygjpq5799zqyx901nsi12vlcymwg4"; inherit CoreFoundation;
patches = [ inherit cctools;
./forget-build-dependencies.patch };
]; in buildMongoDB {
} version = "3.6.13";
sha256 = "1mbvk4bmabrswjdm01jssxcygjpq5799zqyx901nsi12vlcymwg4";
patches = [ ./forget-build-dependencies.patch ];
}

View File

@ -1,13 +1,16 @@
{ stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }: { stdenv, callPackage, lib, sasl, boost, Security, CoreFoundation, cctools }:
let let
buildMongoDB = callPackage ./mongodb.nix { inherit sasl; inherit boost; inherit Security; inherit CoreFoundation; inherit cctools; }; buildMongoDB = callPackage ./mongodb.nix {
in inherit sasl;
buildMongoDB { inherit boost;
version = "4.0.11"; inherit Security;
sha256 = "0kry8kzzpah0l7j8xa333y1ixwvarc28ip3f6lx5590yy11j8ry2"; inherit CoreFoundation;
patches = [ inherit cctools;
./forget-build-dependencies.patch };
./mozjs-45_fix-3-byte-opcode.patch in buildMongoDB {
]; version = "4.0.11";
} sha256 = "0kry8kzzpah0l7j8xa333y1ixwvarc28ip3f6lx5590yy11j8ry2";
patches =
[ ./forget-build-dependencies.patch ./mozjs-45_fix-3-byte-opcode.patch ];
}