nixos/tests/mongodb: rewrite with python

perl-based VM tests are deprecated.
This commit is contained in:
Maximilian Bosch 2020-03-26 13:46:22 +01:00
parent 80e6da7bd3
commit 2934f04641
No known key found for this signature in database
GPG Key ID: 091DBF4D1FC46B8E

View File

@ -1,6 +1,6 @@
# This test start mongodb, runs a query using mongo shell
import ./make-test.nix ({ pkgs, ... }:
import ./make-test-python.nix ({ pkgs, ... }:
let
testQuery = pkgs.writeScript "nixtest.js" ''
db.greetings.insert({ "greeting": "hello" });
@ -8,14 +8,20 @@ import ./make-test.nix ({ pkgs, ... }:
'';
runMongoDBTest = pkg: ''
$node->execute("(rm -rf data || true) && mkdir data");
$node->execute("${pkg}/bin/mongod --fork --logpath logs --dbpath data");
$node->waitForOpenPort(27017);
node.execute("(rm -rf data || true) && mkdir data")
node.execute(
"${pkg}/bin/mongod --fork --logpath logs --dbpath data"
)
node.wait_for_open_port(27017)
$node->succeed("mongo ${testQuery}") =~ /hello/ or die;
assert "hello" in node.succeed(
"mongo ${testQuery}"
)
$node->execute("${pkg}/bin/mongod --shutdown --dbpath data");
$node->waitForClosedPort(27017);
node.execute(
"${pkg}/bin/mongod --shutdown --dbpath data"
)
node.wait_for_closed_port(27017)
'';
in {
@ -34,9 +40,13 @@ import ./make-test.nix ({ pkgs, ... }:
};
};
testScript = "$node->start;"
testScript = ''
node.start()
''
# + runMongoDBTest pkgs.mongodb-3_4
+ runMongoDBTest pkgs.mongodb-3_6
+ runMongoDBTest pkgs.mongodb-4_0
+ "$node->shutdown;";
+ ''
node.shutdown()
'';
})