diff options
author | Nathan Smyth <nathan.smyth@mongodb.com> | 2019-08-04 16:25:56 +1000 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2020-03-26 14:02:49 +0100 |
commit | 44641ed00bf3b1d5914a685137f16910f6454951 (patch) | |
tree | 947500bd346d326c3021e85c9f44fd5ba498a147 /nixos | |
parent | 165d8bda8265ca9c247d1ab5e1137117c3236e25 (diff) |
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.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/tests/mongodb.nix | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/nixos/tests/mongodb.nix b/nixos/tests/mongodb.nix index 9ebf84eed2325..dfb23ce6c0dbf 100644 --- a/nixos/tests/mongodb.nix +++ b/nixos/tests/mongodb.nix @@ -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 ]; + }; + + nodes = { + node = {...}: { + environment.systemPackages = with pkgs; [ +# mongodb-3_4 + mongodb-3_6 + mongodb-4_0 + ]; + }; }; - testScript = '' - start_all() - one.wait_for_unit("mongodb.service") - one.succeed( - "mongo -u nixtest -p nixtest nixtest ${testQuery} | grep -q hello" - ) - ''; -}) + testScript = "$node->start;" +# + runMongoDBTest pkgs.mongodb-3_4 + + runMongoDBTest pkgs.mongodb-3_6 + + runMongoDBTest pkgs.mongodb-4_0 + + "$node->shutdown;"; + }) |