-
Notifications
You must be signed in to change notification settings - Fork 3
feat: more logging #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -382,6 +382,8 @@ class GatewayImpl : public IGateway, private IClientTransport | |
| Server server; | ||
| std::thread watchdogThread; | ||
| std::atomic<bool> watchdogRunning; | ||
| std::mutex watchdogMutex_; | ||
| std::condition_variable watchdogCv_; | ||
| bool legacyRPCv1; | ||
|
|
||
| std::map<MessageID, std::string> rpcv1_eventMap; | ||
|
|
@@ -401,6 +403,7 @@ class GatewayImpl : public IGateway, private IClientTransport | |
| if (watchdogRunning) | ||
| { | ||
| watchdogRunning = false; | ||
| watchdogCv_.notify_one(); | ||
| if (watchdogThread.joinable()) | ||
| { | ||
| watchdogThread.join(); | ||
|
|
@@ -450,7 +453,11 @@ class GatewayImpl : public IGateway, private IClientTransport | |
| { | ||
| while (watchdogRunning) | ||
| { | ||
| std::this_thread::sleep_for(std::chrono::milliseconds(watchdog_interval_ms)); | ||
| std::unique_lock<std::mutex> lock(watchdogMutex_); | ||
| watchdogCv_.wait_for(lock, std::chrono::milliseconds(watchdog_interval_ms), | ||
| [this] { return !watchdogRunning.load(); }); | ||
| if (!watchdogRunning) | ||
| break; | ||
| client.checkPromises(); | ||
| } | ||
| }); | ||
|
|
@@ -461,19 +468,37 @@ class GatewayImpl : public IGateway, private IClientTransport | |
|
|
||
| virtual Firebolt::Error disconnect() override | ||
| { | ||
| FIREBOLT_LOG_INFO("Gateway", "[disconnect] transport.disconnect() start"); | ||
| auto t0_disc = std::chrono::steady_clock::now(); | ||
| Firebolt::Error status = transport.disconnect(); | ||
| FIREBOLT_LOG_INFO("Gateway", "[disconnect] transport.disconnect() done in %ld ms, status=%d", | ||
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_disc) | ||
| .count(), | ||
| static_cast<int>(status)); | ||
| if (status != Firebolt::Error::None) | ||
| { | ||
| return status; | ||
| } | ||
| if (watchdogRunning.exchange(false)) | ||
| { | ||
| watchdogCv_.notify_one(); | ||
| FIREBOLT_LOG_INFO("Gateway", "[disconnect] waiting for watchdog thread join..."); | ||
| auto t0_wdog = std::chrono::steady_clock::now(); | ||
| if (watchdogThread.joinable()) | ||
| { | ||
| watchdogThread.join(); | ||
| } | ||
| FIREBOLT_LOG_INFO("Gateway", "[disconnect] watchdog joined in %ld ms", | ||
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - | ||
| t0_wdog) | ||
| .count()); | ||
|
Comment on lines
+491
to
+494
|
||
| } | ||
| FIREBOLT_LOG_INFO("Gateway", "[disconnect] stopping notification worker..."); | ||
| auto t0_nw = std::chrono::steady_clock::now(); | ||
| server.stopNotificationWorker(); | ||
| FIREBOLT_LOG_INFO("Gateway", "[disconnect] notification worker stopped in %ld ms", | ||
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_nw) | ||
| .count()); | ||
|
Comment on lines
+499
to
+501
|
||
| return Error::None; | ||
| } | ||
|
|
||
|
|
@@ -512,11 +537,25 @@ class GatewayImpl : public IGateway, private IClientTransport | |
| nlohmann::json params; | ||
| params["listen"] = true; | ||
|
|
||
| auto result = request(event, params, id).get(); | ||
|
|
||
| if (!result) | ||
| FIREBOLT_LOG_INFO("Gateway", "[subscribe] waiting for subscribe ACK for '%s'...", event.c_str()); | ||
| auto t0_sub = std::chrono::steady_clock::now(); | ||
| auto fut = request(event, params, id); | ||
| if (fut.wait_for(std::chrono::milliseconds(50)) == std::future_status::ready) | ||
| { | ||
| auto result = fut.get(); | ||
| FIREBOLT_LOG_INFO("Gateway", "[subscribe] ACK for '%s' received in %ld ms", event.c_str(), | ||
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - | ||
| t0_sub) | ||
| .count()); | ||
| if (!result) | ||
| { | ||
| status = result.error(); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| status = result.error(); | ||
| FIREBOLT_LOG_INFO("Gateway", "[subscribe] ACK not received within 50ms, giving up"); | ||
| status = Firebolt::Error::Timedout; | ||
| } | ||
|
|
||
| if (status != Firebolt::Error::None) | ||
|
|
@@ -533,9 +572,12 @@ class GatewayImpl : public IGateway, private IClientTransport | |
|
|
||
| Firebolt::Error unsubscribe(const std::string& event, void* usercb) override | ||
| { | ||
| FIREBOLT_LOG_DEBUG("Gateway", "Unsubscribe called for event '%s'", event.c_str()); | ||
| Firebolt::Error status = server.unsubscribe(event, usercb); | ||
|
|
||
| if (status != Firebolt::Error::None) | ||
| { | ||
| FIREBOLT_LOG_DEBUG("Gateway", "Unsubscribe failed for event '%s'", event.c_str()); | ||
| return status; | ||
| } | ||
|
|
||
|
|
@@ -563,11 +605,25 @@ class GatewayImpl : public IGateway, private IClientTransport | |
|
|
||
| nlohmann::json params; | ||
| params["listen"] = false; | ||
| auto result = request(event, params).get(); | ||
|
|
||
| if (!result) | ||
| FIREBOLT_LOG_INFO("Gateway", "[unsubscribe] sending unsubscribe for '%s', waiting for ACK (waitTime_ms=%u)...", | ||
| event.c_str(), runtime_waitTime_ms); | ||
| auto t0_unsub = std::chrono::steady_clock::now(); | ||
| auto fut = request(event, params); | ||
| if (fut.wait_for(std::chrono::milliseconds(50)) == std::future_status::ready) | ||
| { | ||
| auto result = fut.get(); | ||
| auto unsub_ms = | ||
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_unsub).count(); | ||
| FIREBOLT_LOG_INFO("Gateway", "[unsubscribe] ACK received after %ld ms", unsub_ms); | ||
| if (!result) | ||
| { | ||
| status = result.error(); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| status = result.error(); | ||
| FIREBOLT_LOG_INFO("Gateway", "[unsubscribe] ACK not received within 50ms, giving up"); | ||
| status = Firebolt::Error::Timedout; | ||
| } | ||
|
|
||
| return status; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "firebolt/logger.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "firebolt/types.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <assert.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <chrono> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <memory> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace Firebolt::Transport | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -234,19 +235,30 @@ Firebolt::Error Transport::disconnect() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| websocketpp::lib::error_code ec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FIREBOLT_LOG_INFO("Transport", "[disconnect] close() start (handshake timeout=100ms)"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| client_->close(connectionHandle_, websocketpp::close::status::going_away, "", ec); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+238
to
239
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ec) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FIREBOLT_LOG_ERROR("Transport", "Error closing connection: %s", ec.message().c_str()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FIREBOLT_LOG_INFO("Transport", "[disconnect] waiting for connectionThread join (close handshake in progress)..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto t0_ct = std::chrono::steady_clock::now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (connectionThread_ && connectionThread_->joinable()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| connectionThread_->join(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FIREBOLT_LOG_INFO("Transport", "[disconnect] connectionThread joined in %ld ms", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_ct) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .count()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FIREBOLT_LOG_INFO("Transport", "[disconnect] stopping message worker..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto t0_mw = std::chrono::steady_clock::now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stopMessageWorker(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FIREBOLT_LOG_INFO("Transport", "[disconnect] message worker stopped in %ld ms", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_mw) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .count()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+252
to
+261
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FIREBOLT_LOG_INFO("Transport", "[disconnect] connectionThread joined in %ld ms", | |
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_ct) | |
| .count()); | |
| FIREBOLT_LOG_INFO("Transport", "[disconnect] stopping message worker..."); | |
| auto t0_mw = std::chrono::steady_clock::now(); | |
| stopMessageWorker(); | |
| FIREBOLT_LOG_INFO("Transport", "[disconnect] message worker stopped in %ld ms", | |
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_mw) | |
| .count()); | |
| FIREBOLT_LOG_INFO( | |
| "Transport", "[disconnect] connectionThread joined in %lld ms", | |
| static_cast<long long>( | |
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_ct).count())); | |
| FIREBOLT_LOG_INFO("Transport", "[disconnect] stopping message worker..."); | |
| auto t0_mw = std::chrono::steady_clock::now(); | |
| stopMessageWorker(); | |
| FIREBOLT_LOG_INFO( | |
| "Transport", "[disconnect] message worker stopped in %lld ms", | |
| static_cast<long long>( | |
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_mw).count())); |
Copilot
AI
Apr 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same format-string issue: "%ld" is used for milliseconds::count() (typically long long), which can produce format warnings/UB. Prefer "%lld" (with cast) or PRI macros.
| FIREBOLT_LOG_INFO("Transport", "[disconnect] connectionThread joined in %ld ms", | |
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_ct) | |
| .count()); | |
| FIREBOLT_LOG_INFO("Transport", "[disconnect] stopping message worker..."); | |
| auto t0_mw = std::chrono::steady_clock::now(); | |
| stopMessageWorker(); | |
| FIREBOLT_LOG_INFO("Transport", "[disconnect] message worker stopped in %ld ms", | |
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_mw) | |
| .count()); | |
| FIREBOLT_LOG_INFO( | |
| "Transport", "[disconnect] connectionThread joined in %lld ms", | |
| static_cast<long long>( | |
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_ct) | |
| .count())); | |
| FIREBOLT_LOG_INFO("Transport", "[disconnect] stopping message worker..."); | |
| auto t0_mw = std::chrono::steady_clock::now(); | |
| stopMessageWorker(); | |
| FIREBOLT_LOG_INFO( | |
| "Transport", "[disconnect] message worker stopped in %lld ms", | |
| static_cast<long long>( | |
| std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - t0_mw) | |
| .count())); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "firebolt/gateway.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "firebolt/logger.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "utils.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <gtest/gtest.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <nlohmann/json.hpp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -152,7 +153,7 @@ class GatewayUTest : public ::testing::Test | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Firebolt::Config cfg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cfg.wsUrl = m_uri; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cfg.log.level = Firebolt::LogLevel::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cfg.log.level = Firebolt::LogLevel::Debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cfg.log.level = Firebolt::LogLevel::Debug; | |
| cfg.log.level = Firebolt::LogLevel::Error; |
Copilot
AI
Apr 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test name/comments state this is asserting disconnect() returns quickly, but the timing/EXPECT only measures unsubscribe(); disconnect() is not timed or asserted. Either rename/update the comments to match what’s measured, or time gateway.disconnect() and assert on that duration.
| // Regression test: disconnect() must return quickly even when the server dies | |
| // while active subscriptions are held. | |
| // | |
| // Repro scenario (RDKEMW-16573): | |
| // 1. Client subscribes to an event (gateway sends subscribe ACK) | |
| // 2. Server disappears abruptly (no WS close handshake, no unsubscribe ACK) | |
| // 3. Client calls disconnect() | |
| // | |
| // Before the fix: disconnect() blocked for ~waitTime_ms per subscription | |
| // (request(...).get() inside unsubscribe() held the calling thread). | |
| // | |
| // After the fix: disconnect() uses wait_for(50ms) ceilings and returns in | |
| // well under 500ms regardless of server responsiveness. | |
| // | |
| // The test asserts disconnect() completes within 500ms (generous allowance). | |
| // On an unpatched build it will take >= waitTime_ms (1000ms default) and fail. | |
| // --------------------------------------------------------------------------- | |
| TEST_F(GatewayUTest, DisconnectDoesNotHangWhenServerDisappearsWithActiveSubscription) | |
| // Regression test: unsubscribe() must return quickly even when the server dies | |
| // after a subscription has become active. | |
| // | |
| // Repro scenario (RDKEMW-16573): | |
| // 1. Client subscribes to an event (gateway sends subscribe ACK) | |
| // 2. Server disappears abruptly (no WS close handshake, no unsubscribe ACK) | |
| // 3. Client calls unsubscribe() | |
| // | |
| // Before the fix: unsubscribe() could block for ~waitTime_ms because | |
| // request(...).get() waited on a reply that never arrived. | |
| // | |
| // After the fix: unsubscribe() uses wait_for(50ms) ceilings and returns in | |
| // well under 500ms regardless of server responsiveness. | |
| // | |
| // The test asserts unsubscribe() completes within 500ms (generous allowance). | |
| // On an unpatched build it will take >= waitTime_ms (1000ms default) and fail. | |
| // --------------------------------------------------------------------------- | |
| TEST_F(GatewayUTest, UnsubscribeDoesNotHangWhenServerDisappearsAfterActiveSubscription) |
Copilot
AI
Apr 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the new regression test, the result of connectionFuture.wait_for(...) is ignored. If the connection never becomes ready, the test will proceed to subscribe/unsubscribe and fail in less obvious ways; it should ASSERT/EXPECT that the future becomes ready (as other tests in this file do).
| connectionFuture.wait_for(std::chrono::seconds(2)); | |
| ASSERT_EQ(connectionFuture.wait_for(std::chrono::seconds(2)), std::future_status::ready) | |
| << "Timed out waiting for connection to become ready"; |
Copilot
AI
Apr 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test uses a fixed sleep_for(50ms) to “give the subscribe ACK time to arrive”. This can be flaky under load. Prefer synchronizing on a condition (e.g., wait until subscribeAckSent is set, with a reasonable timeout) rather than sleeping a fixed duration.
| Firebolt::Error subErr = gateway.subscribe("test.onStateChanged", onEvent, &eventPromise); | |
| ASSERT_EQ(subErr, Firebolt::Error::None) << "subscribe() failed"; | |
| // Give the subscribe ACK time to arrive. | |
| std::this_thread::sleep_for(std::chrono::milliseconds(50)); | |
| std::promise<void> subscribeAckPromise; | |
| std::future<void> subscribeAckFuture = subscribeAckPromise.get_future(); | |
| bool subscribeAckObserved = false; | |
| std::function<void(connection_hdl, server::message_ptr)> previousMessageHandler = m_messageHandler; | |
| m_messageHandler = [&subscribeAckPromise, &subscribeAckObserved, previousMessageHandler](connection_hdl hdl, | |
| server::message_ptr msg) | |
| { | |
| previousMessageHandler(hdl, msg); | |
| if (!subscribeAckObserved) | |
| { | |
| nlohmann::json request = nlohmann::json::parse(msg->get_payload(), nullptr, false); | |
| if (!request.is_discarded() && request.value("method", "") == "test.onStateChanged") | |
| { | |
| subscribeAckObserved = true; | |
| subscribeAckPromise.set_value(); | |
| } | |
| } | |
| }; | |
| Firebolt::Error subErr = gateway.subscribe("test.onStateChanged", onEvent, &eventPromise); | |
| ASSERT_EQ(subErr, Firebolt::Error::None) << "subscribe() failed"; | |
| EXPECT_EQ(subscribeAckFuture.wait_for(std::chrono::seconds(2)), std::future_status::ready) | |
| << "Timed out waiting for subscribe request to be processed before switching server to silent mode"; |
Copilot
AI
Apr 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test prints timing via std::cout, which is not used elsewhere in the unit tests and can add noisy output in CI. Consider reporting timing only on failure (via the EXPECT/ASSERT message) or using existing logging facilities behind a log level.
| std::cout << "[timing] unsubscribe() took " << elapsed.count() << " ms\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log uses "%ld" for a std::chrono::milliseconds::count() value (typically long long). This can trigger -Wformat warnings and is undefined behavior on platforms where long != long long. Consider using "%lld" with an explicit cast (or PRI macros).