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
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 ];
};
testScript = ''
start_all()
one.wait_for_unit("mongodb.service")
one.succeed(
"mongo -u nixtest -p nixtest nixtest ${testQuery} | grep -q hello"
)
'';
})
nodes = {
node = {...}: {
environment.systemPackages = with pkgs; [
# mongodb-3_4
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,
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"
"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"
"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" ];
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 = ''

View file

@ -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 ];
}

View file

@ -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 ];
}

View file

@ -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 ];
}