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

Use homepage's API to ensure that ping works
This commit is contained in:
Parthiv Krishna
2025-09-17 08:20:45 +00:00
parent 4058df754e
commit 74411c6c0d

View File

@@ -21,10 +21,23 @@
]; ];
} }
]; ];
services = [
{
Machines = [
{
Localhost = {
ping = "127.0.0.1";
};
}
];
}
];
}; };
}; };
testScript = '' testScript = ''
import json
# Ensure the services are started on managed machine # Ensure the services are started on managed machine
machine.wait_for_unit("homepage-dashboard.service") machine.wait_for_unit("homepage-dashboard.service")
machine.wait_for_open_port(8082) machine.wait_for_open_port(8082)
@@ -40,5 +53,9 @@
# Ensure that we see the custom bookmarks on the page # Ensure that we see the custom bookmarks on the page
page = machine.succeed("curl --fail http://127.0.0.1:8082/api/bookmarks") page = machine.succeed("curl --fail http://127.0.0.1:8082/api/bookmarks")
assert "nixpkgs" in page, "Custom bookmarks not found" 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"
''; '';
} }