[fixit] Fix flakiness for test case ChannelzSamplerTest.SimpleTest by reducing the chance of port conflict (#30620)

* Fix flakiness for test case ChannelzSamplerTest.SimpleTest by reducing the chance of port conflict

* Update
pull/30625/head
Cheng-Yu Chung 3 years ago committed by GitHub
parent 8a466c209e
commit feeb54ec33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      test/cpp/util/BUILD
  2. 5
      test/cpp/util/channelz_sampler_test.cc

@ -332,6 +332,7 @@ grpc_cc_binary(
srcs = ["channelz_sampler.cc"],
external_deps = [
"absl/flags:flag",
"absl/strings",
],
language = "c++",
tags = [

@ -26,6 +26,7 @@
#include <string>
#include <thread>
#include "absl/strings/str_cat.h"
#include "gtest/gtest.h"
#include <grpc/grpc.h>
@ -44,6 +45,7 @@
#include "src/core/lib/gpr/env.h"
#include "src/cpp/server/channelz/channelz_service.h"
#include "src/proto/grpc/testing/test.grpc.pb.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
#include "test/cpp/util/subprocess.h"
#include "test/cpp/util/test_credentials_provider.h"
@ -174,6 +176,9 @@ int main(int argc, char** argv) {
} else {
g_root = ".";
}
/// ensures the target address is unique even if this test is run in parallel
server_address = absl::StrCat("0.0.0.0:", grpc_pick_unused_port_or_die());
int ret = RUN_ALL_TESTS();
return ret;
}

Loading…
Cancel
Save