1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-24 22:50:49 +00:00
nixpkgs/nixos/tests/mongodb.nix

43 lines
1.2 KiB
Nix
Raw Normal View History

2016-09-13 16:38:45 +01:00
# This test start mongodb, runs a query using mongo shell
2019-11-22 19:56:43 +00:00
import ./make-test-python.nix ({ pkgs, ...} : let
2016-09-13 16:38:45 +01:00
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 ];
2016-09-13 16:38:45 +01:00
};
nodes = {
one =
{ ... }:
2016-09-13 16:38:45 +01:00
{
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"}]});
'';
2016-09-13 16:38:45 +01:00
mongodb.extraConfig = ''
# Allow starting engine with only a small virtual disk
storage.journal.enabled: false
storage.mmapv1.smallFiles: true
'';
};
};
};
testScript = ''
2019-11-22 19:56:43 +00:00
start_all()
one.wait_for_unit("mongodb.service")
one.succeed(
"mongo -u nixtest -p nixtest nixtest ${testQuery} | grep -q hello"
)
2016-09-13 16:38:45 +01:00
'';
})