Skip to content
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

//test/common/router:config_impl_headermap_benchmark_test is broken #33794

Open
ravenblackx opened this issue Apr 25, 2024 · 0 comments
Open

Comments

@ravenblackx
Copy link
Contributor

bazel run -c opt //test/common/router:config_impl_headermap_benchmark_test

Throws an exception because there are no clusters.

I had a brief shot at fixing it, like so:

diff --git a/test/common/router/config_impl_headermap_benchmark_test.cc b/test/common/router/config_impl_headermap_benchmark_test.cc
index 18c2092a8a..8416327d02 100644
--- a/test/common/router/config_impl_headermap_benchmark_test.cc
+++ b/test/common/router/config_impl_headermap_benchmark_test.cc
@@ -56,6 +56,11 @@ static void manyCountryRoutesLongHeaders(benchmark::State& state) {
   Api::ApiPtr api(Api::createApiForTest());
   NiceMock<Server::Configuration::MockServerFactoryContext> factory_context;
   ON_CALL(factory_context, api()).WillByDefault(ReturnRef(*api));
+  std::vector<std::string> clusters{"default"};
+  for (size_t i = 0; i < countries_num; i++) {
+    clusters.push_back(absl::StrCat("country", i));
+  }
+  factory_context.cluster_manager_.initializeClusters(clusters, clusters);
   ConfigImpl config(proto_config, factory_context, ProtobufMessage::getNullValidationVisitor(),
                     true);
 
@@ -66,7 +71,7 @@ static void manyCountryRoutesLongHeaders(benchmark::State& state) {
   for (int i = 0; i < 90; i++) {
     req_headers.addCopy(Http::LowerCaseString(absl::StrCat("dummyheader", i)), "some_value");
   }
-  req_headers.addReferenceKey(country_header_name, absl::StrCat("country", countries_num));
+  req_headers.addReferenceKey(country_header_name, absl::StrCat("country", (countries_num - 1)));
   for (auto _ : state) { // NOLINT
     auto& result = config.route(req_headers, stream_info, 0)->routeEntry()->clusterName();
     benchmark::DoNotOptimize(result);

But there's still a segfault later in the test, and I don't really know what the test is even trying to do enough to fix it from there.

I'd suggest either someone who knows about it should fix it (looks like @adisuissa is the main person on it 4 years ago), or it should just be deleted since apparently it doesn't get run anyway or someone would have noticed it's broken!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant