aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver-test
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2026-03-25 21:26:52 +0100
committerDan Engelbrecht <[email protected]>2026-03-25 21:26:52 +0100
commitccb519896dfd8c5a375a6e8139c4f7dfafcc75a4 (patch)
tree615c864ed0c1e37d3a59bf3e15b5ed09d645ba16 /src/zenserver-test
parentupdated comment and improved rejection message on recovering state (diff)
downloadzen-de/hub-instance-state-refactor.tar.xz
zen-de/hub-instance-state-refactor.zip
fix hub.consul.provision.registration testde/hub-instance-state-refactor
Diffstat (limited to 'src/zenserver-test')
-rw-r--r--src/zenserver-test/hub-tests.cpp40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/zenserver-test/hub-tests.cpp b/src/zenserver-test/hub-tests.cpp
index c3aaa85d5..303357339 100644
--- a/src/zenserver-test/hub-tests.cpp
+++ b/src/zenserver-test/hub-tests.cpp
@@ -568,13 +568,12 @@ TEST_CASE("hub.consul.provision.registration")
CHECK_EQ(HubService["Port"sv].AsDouble(0), double(PortNumber));
}
- // Verify health check endpoint URLs
+ // Verify hub health check endpoint URL (registered from startup with an active interval)
{
std::string ChecksJsonError;
CbFieldIterator ChecksRoot = LoadCompactBinaryFromJson(Client.GetAgentChecksJson(), ChecksJsonError);
REQUIRE(ChecksJsonError.empty());
- CbObjectView ModCheck;
CbObjectView HubCheck;
for (CbFieldView F : ChecksRoot)
{
@@ -585,18 +584,12 @@ TEST_CASE("hub.consul.provision.registration")
for (CbFieldView C : F.AsObjectView())
{
CbObjectView Check = C.AsObjectView();
- if (Check["ServiceID"sv].AsString() == "testmod"sv)
- {
- ModCheck = Check;
- }
- else if (Check["ServiceID"sv].AsString() == "zen-hub-test-instance"sv)
+ if (Check["ServiceID"sv].AsString() == "zen-hub-test-instance"sv)
{
HubCheck = Check;
}
}
}
- REQUIRE(ModCheck);
- CHECK(ModCheck["HTTP"sv].AsString().find("/health") != std::string_view::npos);
REQUIRE(HubCheck);
CHECK(HubCheck["HTTP"sv].AsString().find("/hub/health") != std::string_view::npos);
}
@@ -604,6 +597,35 @@ TEST_CASE("hub.consul.provision.registration")
// Wait for Provisioned before touching the module's HTTP endpoint.
REQUIRE(WaitForModuleState(HubClient, "testmod", "provisioned"));
+
+ // Verify module health check endpoint URL. No health check is registered during Provisioning
+ // (to avoid Consul marking the service critical before the child process is ready); it is added
+ // on transition to Provisioned.
+ {
+ std::string ChecksJsonError;
+ CbFieldIterator ChecksRoot = LoadCompactBinaryFromJson(Client.GetAgentChecksJson(), ChecksJsonError);
+ REQUIRE(ChecksJsonError.empty());
+
+ CbObjectView ModCheck;
+ for (CbFieldView F : ChecksRoot)
+ {
+ if (!F.IsObject())
+ {
+ continue;
+ }
+ for (CbFieldView C : F.AsObjectView())
+ {
+ CbObjectView Check = C.AsObjectView();
+ if (Check["ServiceID"sv].AsString() == "testmod"sv)
+ {
+ ModCheck = Check;
+ }
+ }
+ }
+ REQUIRE(ModCheck);
+ CHECK(ModCheck["HTTP"sv].AsString().find("/health") != std::string_view::npos);
+ }
+
{
HttpClient ModClient(fmt::format("http://localhost:{}", ModulePort), kFastTimeout);
CHECK(ModClient.Get("/health/"));