Add rich HTTP health endpoints for cluster monitoring

Enhance /api/health with component-level health, ServiceLevel, and
redundancy state for load balancer probes. Add /health HTML page for
operators to monitor node health in clustered System Platform deployments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-03-28 16:44:31 -04:00
parent f0a076ec26
commit 9d3599fbb6
5 changed files with 381 additions and 3 deletions

View File

@@ -107,6 +107,35 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.Status
response.Headers.CacheControl?.NoStore.ShouldBe(true);
}
/// <summary>
/// Confirms that the /health route returns an HTML health page.
/// </summary>
[Fact]
public async Task HealthPage_ReturnsHtml200()
{
var response = await _client.GetAsync("/health");
response.StatusCode.ShouldBe(HttpStatusCode.OK);
response.Content.Headers.ContentType?.MediaType.ShouldBe("text/html");
var body = await response.Content.ReadAsStringAsync();
body.ShouldContain("SERVICE LEVEL");
body.ShouldContain("MXAccess");
}
/// <summary>
/// Confirms that /api/health returns rich JSON with component health details.
/// </summary>
[Fact]
public async Task ApiHealth_ReturnsRichJson()
{
var response = await _client.GetAsync("/api/health");
response.StatusCode.ShouldBe(HttpStatusCode.OK);
response.Content.Headers.ContentType?.MediaType.ShouldBe("application/json");
var body = await response.Content.ReadAsStringAsync();
body.ShouldContain("ServiceLevel");
body.ShouldContain("Components");
body.ShouldContain("Uptime");
}
/// <summary>
/// Confirms that the server can be started and stopped cleanly.
/// </summary>