3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/tests/mongodb.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.4 KiB
Nix
Raw Normal View History

2016-09-13 16:38:45 +01:00
# 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);
'';
2016-09-13 16:38:45 +01:00
runMongoDBTest = pkg: ''
node.execute("(rm -rf data || true) && mkdir data")
node.execute(
"${pkg}/bin/mongod --fork --logpath logs --dbpath data"
)
node.wait_for_open_port(27017)
assert "hello" in node.succeed(
"${pkg}/bin/mongo ${testQuery}"
)
node.execute(
"${pkg}/bin/mongod --shutdown --dbpath data"
)
node.wait_for_closed_port(27017)
'';
in {
name = "mongodb";
meta = with pkgs.lib.maintainers; {
maintainers = [ bluescreen303 offline cstrahan rvl phile314 ];
};
nodes = {
node = {...}: {
environment.systemPackages = with pkgs; [
mongodb-3_4
mongodb-3_6
mongodb-4_0
mongodb-4_2
2022-03-02 10:55:53 +00:00
mongodb-4_4
mongodb-5_0
];
};
2016-09-13 16:38:45 +01:00
};
testScript = ''
node.start()
''
+ runMongoDBTest pkgs.mongodb-3_4
2020-08-02 10:25:04 +01:00
+ runMongoDBTest pkgs.mongodb-3_6
+ runMongoDBTest pkgs.mongodb-4_0
+ runMongoDBTest pkgs.mongodb-4_2
2022-03-02 10:55:53 +00:00
+ runMongoDBTest pkgs.mongodb-4_4
+ runMongoDBTest pkgs.mongodb-5_0
+ ''
node.shutdown()
'';
})