Commit 52cb257e authored by Bruno BELANYI's avatar Bruno BELANYI
Browse files

nixosTest.homebox: test postgres provisioning

parent 9c099621
Loading
Loading
Loading
Loading
+28 −11
Original line number Diff line number Diff line
@@ -8,19 +8,36 @@ import ./make-test-python.nix (
    meta = with pkgs.lib.maintainers; {
      maintainers = [ patrickdag ];
    };
    nodes.machine = {
    nodes =
      let
        self = {
          simple = {
            services.homebox = {
              enable = true;
              settings.HBOX_WEB_PORT = port;
            };
          };

          postgres = {
            imports = [ self.simple ];
            services.homebox.database.createLocally = true;
          };
        };
      in
      self;
    testScript = ''
      machine.wait_for_unit("homebox.service")
      machine.wait_for_open_port(${port})
      def test_homebox(node):
        node.wait_for_unit("homebox.service")
        node.wait_for_open_port(${port})

      machine.succeed("curl --fail -X GET 'http://localhost:${port}/'")
      out = machine.succeed("curl --fail 'http://localhost:${port}/api/v1/status'")
        node.succeed("curl --fail -X GET 'http://localhost:${port}/'")
        out = node.succeed("curl --fail 'http://localhost:${port}/api/v1/status'")
        assert '"health":true' in out

      test_homebox(simple)
      simple.send_monitor_command("quit")
      simple.wait_for_shutdown()
      test_homebox(postgres)
    '';
  }
)