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, ... }:
let
testQuery = pkgs.writeScript "nixtest.js" '' testQuery = pkgs.writeScript "nixtest.js" ''
db.greetings.insert({ "greeting": "hello" }); db.greetings.insert({ "greeting": "hello" });
print(db.greetings.findOne().greeting); print(db.greetings.findOne().greeting);
''; '';
in {
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"; name = "mongodb";
meta = with pkgs.stdenv.lib.maintainers; { meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ bluescreen303 offline cstrahan rvl phile314 ]; maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
}; };
nodes = { nodes = {
one = node = {...}: {
{ ... }: environment.systemPackages = with pkgs; [
{ # mongodb-3_4
services = { mongodb-3_6
mongodb.enable = true; mongodb-4_0
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
'';
};
}; };
}; };
testScript = '' testScript = "$node->start;"
start_all() # + runMongoDBTest pkgs.mongodb-3_4
one.wait_for_unit("mongodb.service") + runMongoDBTest pkgs.mongodb-3_6
one.succeed( + runMongoDBTest pkgs.mongodb-4_0
"mongo -u nixtest -p nixtest nixtest ${testQuery} | grep -q hello" + "$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;
inherit Security;
inherit CoreFoundation;
inherit cctools;
};
in buildMongoDB {
version = "3.4.22"; version = "3.4.22";
sha256 = "1rizrr69b26y7fb973n52hk387sf3mxzqg8wka4f3zdjdidfyiny"; sha256 = "1rizrr69b26y7fb973n52hk387sf3mxzqg8wka4f3zdjdidfyiny";
patches = [ patches = [ ./forget-build-dependencies-3-4.patch ];
./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;
inherit Security;
inherit CoreFoundation;
inherit cctools;
};
in buildMongoDB {
version = "3.6.13"; version = "3.6.13";
sha256 = "1mbvk4bmabrswjdm01jssxcygjpq5799zqyx901nsi12vlcymwg4"; sha256 = "1mbvk4bmabrswjdm01jssxcygjpq5799zqyx901nsi12vlcymwg4";
patches = [ patches = [ ./forget-build-dependencies.patch ];
./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;
inherit Security;
inherit CoreFoundation;
inherit cctools;
};
in buildMongoDB {
version = "4.0.11"; version = "4.0.11";
sha256 = "0kry8kzzpah0l7j8xa333y1ixwvarc28ip3f6lx5590yy11j8ry2"; sha256 = "0kry8kzzpah0l7j8xa333y1ixwvarc28ip3f6lx5590yy11j8ry2";
patches = [ patches =
./forget-build-dependencies.patch [ ./forget-build-dependencies.patch ./mozjs-45_fix-3-byte-opcode.patch ];
./mozjs-45_fix-3-byte-opcode.patch }
];
}