Commit 74411c6c authored by Parthiv Krishna's avatar Parthiv Krishna
Browse files

nixosTests.homepage-dashboard: add test for ping property on service

Use homepage's API to ensure that ping works
parent 4058df75
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -21,10 +21,23 @@
          ];
        }
      ];
      services = [
        {
          Machines = [
            {
              Localhost = {
                ping = "127.0.0.1";
              };
            }
          ];
        }
      ];
    };
  };

  testScript = ''
    import json

    # Ensure the services are started on managed machine
    machine.wait_for_unit("homepage-dashboard.service")
    machine.wait_for_open_port(8082)
@@ -40,5 +53,9 @@
    # Ensure that we see the custom bookmarks on the page
    page = machine.succeed("curl --fail http://127.0.0.1:8082/api/bookmarks")
    assert "nixpkgs" in page, "Custom bookmarks not found"

    # Ensure that the ping command works
    response = machine.succeed("curl --fail \"http://localhost:8082/api/ping?groupName=Machines&serviceName=Localhost\"")
    assert json.loads(response)["alive"] is True, "Ping to localhost failed"
  '';
}