diff options
| author | Dan Engelbrecht <[email protected]> | 2026-04-22 13:01:59 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-04-22 13:01:59 +0200 |
| commit | fb694ccf923881e079e8f2c219acaedda3b8c890 (patch) | |
| tree | 9804856f6f049fb8af27c09092ebcfb10cbbf414 | |
| parent | BlockStore: fix correctness issues in block storage layer (#996) (diff) | |
| download | archived-zen-fb694ccf923881e079e8f2c219acaedda3b8c890.tar.xz archived-zen-fb694ccf923881e079e8f2c219acaedda3b8c890.zip | |
fix consul test timeout (#1010)
- Improvement: Hub Consul client HTTP timeout defaults raised to 1s connect / 2s total so transient latency to a slow Consul agent no longer fails registration calls
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | src/zenserver-test/hub-tests.cpp | 17 | ||||
| -rw-r--r-- | src/zenutil/consul/consul.cpp | 9 | ||||
| -rw-r--r-- | src/zenutil/include/zenutil/consul.h | 9 |
4 files changed, 26 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c2d7928e3..732c19774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ ## -- Improvement: Zen log messages are forwarded to trace as typed `ZenLog.*` events that preserve structured `fmt` args end-to-end, so the zen trace analyzer and other downstream consumers can re-render messages with full formatter support (nested widths, chrono specs, etc.). `--trace=log` now routes to the zen log channel (the upstream UE `log` channel is unused since zen no longer emits `Logging.*` events) - Improvement: `zen builds` zen-folder handling is now consistent per subcommand - `list-namespaces`, `list`, `list-blocks`, `ls`: no local scratch folder is created; responses stay in memory - `upload`, `fetch-blob`, `prime-cache`, `validate-part`: default to `<cwd>/.zen` (no change) - `download`: default to `<local-path>/.zen` (no change) - Improvement: Dashboard banner displays the zenserver version next to the wordmark +- Improvement: Zen log messages are forwarded to trace as typed `ZenLog.*` events that preserve structured `fmt` args end-to-end, so the zen trace analyzer and other downstream consumers can re-render messages with full formatter support (nested widths, chrono specs, etc.). `--trace=log` now routes to the zen log channel (the upstream UE `log` channel is unused since zen no longer emits `Logging.*` events) +- Improvement: Hub Consul client HTTP timeout defaults raised to 1s connect / 2s total so transient latency to a slow Consul agent no longer fails registration calls - Bugfix: `zen builds ls` no longer fails against cloud build storage (`--host`/`--url`) when `--storage-path` is not supplied - Bugfix: `NamedEvent` construction on Linux/macOS no longer races against a concurrent destructor's `unlink()` of the backing file; the IPC key is now derived via `fstat()` on the open fd instead of `ftok()` re-stat'ing the path - Bugfix: Hub provision requests now return 202 Accepted when the module is `Recovering` or `Waking` instead of rejecting @@ -60,7 +61,6 @@ - `zen cache record <path>` replaces `zen rpc-record-start` - `zen cache record stop` replaces `zen rpc-record-stop` - `zen cache replay` replaces `zen rpc-record-replay` -- Improvement: `--zen-folder-path` is used verbatim as the zen state and temp folder (no `.zen` subfolder appended) - Bugfix: `builds download` partial-block fetch decisions now account for build storage host latency - Bugfix: Transfer rate displays in `builds` commands now smooth correctly - Bugfix: Structured cache PUT errors with a detail body no longer write the HTTP response twice diff --git a/src/zenserver-test/hub-tests.cpp b/src/zenserver-test/hub-tests.cpp index e83e18446..9d1ee44fb 100644 --- a/src/zenserver-test/hub-tests.cpp +++ b/src/zenserver-test/hub-tests.cpp @@ -374,6 +374,15 @@ TEST_CASE("hub.lifecycle.children") CHECK(Result); } +// Local agent talks on loopback but can still be slow on shared CI runners +// (macOS in particular). Override ConsulClient's short production-default +// timeouts so tests don't flake on first-call latency. +static consul::ConsulClient::Configuration +MakeTestConsulClientConfig() +{ + return {.BaseUri = "http://localhost:8500/", .ConnectTimeout = std::chrono::seconds{5}, .Timeout = std::chrono::seconds{5}}; +} + static bool WaitForConsulService(consul::ConsulClient& Client, std::string_view ServiceId, bool ExpectedState, int TimeoutMs) { @@ -400,7 +409,7 @@ TEST_CASE("hub.consul.kv") consul::ConsulProcess ConsulProc; ConsulProc.SpawnConsulAgent(); - consul::ConsulClient Client({.BaseUri = "http://localhost:8500/"}); + consul::ConsulClient Client(MakeTestConsulClientConfig()); Client.SetKeyValue("zen/hub/testkey", "testvalue"); std::string RetrievedValue = Client.GetKeyValue("zen/hub/testkey"); @@ -422,7 +431,7 @@ TEST_CASE("hub.consul.hub.registration") "--consul-health-interval-seconds=5 --consul-deregister-after-seconds=60"); REQUIRE(PortNumber != 0); - consul::ConsulClient Client({.BaseUri = "http://localhost:8500/"}); + consul::ConsulClient Client(MakeTestConsulClientConfig()); REQUIRE(WaitForConsulService(Client, "zen-hub-test-instance", true, 5000)); // Verify custom intervals flowed through to the registered check @@ -503,7 +512,7 @@ TEST_CASE("hub.consul.hub.registration.token") // Use a plain client -- dev-mode Consul doesn't enforce ACLs, but the // server has exercised the ConsulTokenEnv -> GetEnvVariable -> ConsulClient path. - consul::ConsulClient Client({.BaseUri = "http://localhost:8500/"}); + consul::ConsulClient Client(MakeTestConsulClientConfig()); REQUIRE(WaitForConsulService(Client, "zen-hub-test-instance", true, 5000)); @@ -524,7 +533,7 @@ TEST_CASE("hub.consul.provision.registration") Instance.SpawnServerAndWaitUntilReady("--consul-endpoint=http://localhost:8500/ --instance-id=test-instance"); REQUIRE(PortNumber != 0); - consul::ConsulClient Client({.BaseUri = "http://localhost:8500/"}); + consul::ConsulClient Client(MakeTestConsulClientConfig()); REQUIRE(WaitForConsulService(Client, "zen-hub-test-instance", true, 5000)); diff --git a/src/zenutil/consul/consul.cpp b/src/zenutil/consul/consul.cpp index 3d16a9188..762f06817 100644 --- a/src/zenutil/consul/consul.cpp +++ b/src/zenutil/consul/consul.cpp @@ -117,9 +117,9 @@ ConsulProcess::StopConsulAgent() ConsulClient::ConsulClient(const Configuration& Config) : m_Config(Config) -, m_HttpClient(m_Config.BaseUri, - HttpClientSettings{.ConnectTimeout = std::chrono::milliseconds{500}, .Timeout = std::chrono::milliseconds{500}}, - [this] { return m_Stop.load(); }) +, m_HttpClient(m_Config.BaseUri, HttpClientSettings{.ConnectTimeout = m_Config.ConnectTimeout, .Timeout = m_Config.Timeout}, [this] { + return m_Stop.load(); +}) { m_Worker = std::thread(&ConsulClient::WorkerLoop, this); } @@ -790,7 +790,8 @@ TEST_CASE("util.consul.service_lifecycle") TestHealthServer HealthServer; HealthServer.Start(); - ConsulClient Client({.BaseUri = "http://localhost:8500/"}); + ConsulClient Client( + {.BaseUri = "http://localhost:8500/", .ConnectTimeout = std::chrono::seconds{5}, .Timeout = std::chrono::seconds{5}}); const std::string ServiceId = "test-health-svc"; diff --git a/src/zenutil/include/zenutil/consul.h b/src/zenutil/include/zenutil/consul.h index 4efb10263..38d450583 100644 --- a/src/zenutil/include/zenutil/consul.h +++ b/src/zenutil/include/zenutil/consul.h @@ -7,6 +7,7 @@ #include <zenhttp/httpclient.h> #include <atomic> +#include <chrono> #include <cstdint> #include <string> #include <string_view> @@ -33,9 +34,11 @@ class ConsulClient public: struct Configuration { - std::string BaseUri; - std::string StaticToken; - std::string TokenEnvName; + std::string BaseUri; + std::string StaticToken; + std::string TokenEnvName; + std::chrono::milliseconds ConnectTimeout{1000}; + std::chrono::milliseconds Timeout{2000}; }; ConsulClient(const Configuration& Config); |