2016-09-13 17:38:45 +02:00
|
|
|
# This test start mongodb, runs a query using mongo shell
|
|
|
|
|
|
|
|
import ./make-test.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; {
|
2019-05-25 11:09:30 +02:00
|
|
|
maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
|
2016-09-13 17:38:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
one =
|
2018-07-20 22:56:59 +02:00
|
|
|
{ ... }:
|
2016-09-13 17:38:45 +02:00
|
|
|
{
|
|
|
|
services = {
|
|
|
|
mongodb.enable = true;
|
2019-05-25 11:09:30 +02:00
|
|
|
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"}]});
|
|
|
|
'';
|
2016-09-13 17:38:45 +02:00
|
|
|
mongodb.extraConfig = ''
|
|
|
|
# Allow starting engine with only a small virtual disk
|
|
|
|
storage.journal.enabled: false
|
|
|
|
storage.mmapv1.smallFiles: true
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
startAll;
|
|
|
|
$one->waitForUnit("mongodb.service");
|
2019-05-25 11:09:30 +02:00
|
|
|
$one->succeed("mongo -u nixtest -p nixtest nixtest ${testQuery}") =~ /hello/ or die;
|
2016-09-13 17:38:45 +02:00
|
|
|
'';
|
|
|
|
})
|