diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2020-03-26 13:46:22 +0100 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2020-03-26 14:02:49 +0100 |
commit | 2934f0464161d01aebb347080d5ccb05bd03200d (patch) | |
tree | 428d133f82b8977bd301fb604fa335d92b38426d | |
parent | 80e6da7bd399fe62b461c8e5f6a4756753af9707 (diff) | |
download | nixpkgs-2934f0464161d01aebb347080d5ccb05bd03200d.tar nixpkgs-2934f0464161d01aebb347080d5ccb05bd03200d.tar.gz nixpkgs-2934f0464161d01aebb347080d5ccb05bd03200d.tar.bz2 nixpkgs-2934f0464161d01aebb347080d5ccb05bd03200d.tar.lz nixpkgs-2934f0464161d01aebb347080d5ccb05bd03200d.tar.xz nixpkgs-2934f0464161d01aebb347080d5ccb05bd03200d.tar.zst nixpkgs-2934f0464161d01aebb347080d5ccb05bd03200d.zip |
nixos/tests/mongodb: rewrite with python
perl-based VM tests are deprecated.
-rw-r--r-- | nixos/tests/mongodb.nix | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/nixos/tests/mongodb.nix b/nixos/tests/mongodb.nix index dfb23ce6c0d..ee7fc50f7ec 100644 --- a/nixos/tests/mongodb.nix +++ b/nixos/tests/mongodb.nix @@ -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() + ''; }) |