Merge pull request #305845 from abathur/resholve_0.10.5
[NixPkgs.git] / nixos / tests / ferretdb.nix
blob7251198af77dc09f0158459ae0d7472cdbca9a8e
1 { system ? builtins.currentSystem
2 , pkgs ? import ../.. { inherit system; }
3 , ...
4 }:
5 let
6   lib = pkgs.lib;
7   testScript = ''
8     machine.start()
9     machine.wait_for_unit("ferretdb.service")
10     machine.wait_for_open_port(27017)
11     machine.succeed("mongosh --eval 'use myNewDatabase;' --eval 'db.myCollection.insertOne( { x: 1 } );'")
12   '';
14 with import ../lib/testing-python.nix { inherit system; };
17   postgresql = makeTest
18     {
19       inherit testScript;
20       name = "ferretdb-postgresql";
21       meta.maintainers = with lib.maintainers; [ julienmalka ];
23       nodes.machine =
24         { pkgs, ... }:
25         {
26           services.ferretdb = {
27             enable = true;
28             settings.FERRETDB_HANDLER = "pg";
29             settings.FERRETDB_POSTGRESQL_URL = "postgres://ferretdb@localhost/ferretdb?host=/run/postgresql";
30           };
32           systemd.services.ferretdb.serviceConfig = {
33             Requires = "postgresql.service";
34             After = "postgresql.service";
35           };
37           services.postgresql = {
38             enable = true;
39             ensureDatabases = [ "ferretdb" ];
40             ensureUsers = [{
41               name = "ferretdb";
42               ensureDBOwnership = true;
43             }];
44           };
46           environment.systemPackages = with pkgs; [ mongosh ];
47         };
48     };
50   sqlite = makeTest
51     {
52       inherit testScript;
53       name = "ferretdb-sqlite";
54       meta.maintainers = with lib.maintainers; [ julienmalka ];
56       nodes.machine =
57         { pkgs, ... }:
58         {
59           services.ferretdb.enable = true;
61           environment.systemPackages = with pkgs; [ mongosh ];
62         };
63     };