This is an automated email from the ASF dual-hosted git repository.
chenBright pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new dfce9652 Fix flaky Prometheus metrics startup test (#3610)
dfce9652 is described below
commit dfce9652299b723590d143039c3294cafce2ed0d
Author: songgaoye <[email protected]>
AuthorDate: Thu Oct 15 11:56:29 2026 +0800
Fix flaky Prometheus metrics startup test (#3610)
---
test/brpc_prometheus_metrics_unittest.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/test/brpc_prometheus_metrics_unittest.cpp
b/test/brpc_prometheus_metrics_unittest.cpp
index be99787d..2c7574c0 100644
--- a/test/brpc_prometheus_metrics_unittest.cpp
+++ b/test/brpc_prometheus_metrics_unittest.cpp
@@ -26,6 +26,7 @@
#include "butil/iobuf.h"
#include "butil/strings/string_piece.h"
#include "butil/string_printf.h"
+#include "butil/time.h"
#include "echo.pb.h"
#include "bvar/bvar.h"
#include "bvar/histogram.h"
@@ -79,8 +80,9 @@ TEST(PrometheusMetrics, sanity) {
std::string echo_count_name = butil::string_printf(
"rpc_server_%d_test_echo_service_echo_count",
server.listen_address().port);
- for (int i = 0; i < 500 &&
- bvar::Variable::describe_exposed(echo_count_name).empty(); ++i) {
+ const int64_t deadline_us = butil::cpuwide_time_us() + 5000000;
+ while (bvar::Variable::describe_exposed(echo_count_name).empty() &&
+ butil::cpuwide_time_us() < deadline_us) {
bthread_usleep(10000);
}
ASSERT_FALSE(bvar::Variable::describe_exposed(echo_count_name).empty());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]