From 8e137e524a1b1da7bbf4603662876d5719563b57 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 12 Jun 2023 15:03:33 -0700 Subject: [PATCH] [end2end] Reduce likelihood of two tests opening the same UDS socket (#33410) --- test/core/end2end/end2end_test_suites.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/core/end2end/end2end_test_suites.cc b/test/core/end2end/end2end_test_suites.cc index 527b9db497a..9ab56030312 100644 --- a/test/core/end2end/end2end_test_suites.cc +++ b/test/core/end2end/end2end_test_suites.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -85,7 +86,7 @@ namespace grpc_core { namespace { -std::atomic unique{0}; +std::atomic unique{std::random_device()()}; void ProcessAuthFailure(void* state, grpc_auth_context* /*ctx*/, const grpc_metadata* /*md*/, size_t /*md_count*/, @@ -568,7 +569,7 @@ std::vector AllConfigs() { return std::make_unique( absl::StrFormat( "unix-abstract:grpc_fullstack_test.%%00.%d.%" PRId64 - ".%" PRId32 ".%d", + ".%" PRId32 ".%" PRId64, getpid(), now.tv_sec, now.tv_nsec, unique.fetch_add(1, std::memory_order_relaxed)), UDS); @@ -611,7 +612,7 @@ std::vector AllConfigs() { return std::make_unique( absl::StrFormat( "unix:/tmp/grpc_fullstack_test.%%25.%d.%" PRId64 - ".%" PRId32 ".%d", + ".%" PRId32 ".%" PRId64, getpid(), now.tv_sec, now.tv_nsec, unique.fetch_add(1, std::memory_order_relaxed)), UDS); @@ -628,7 +629,7 @@ std::vector AllConfigs() { return std::make_unique( absl::StrFormat( "unix:/tmp/grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 - ".%d", + ".%" PRId64, getpid(), now.tv_sec, now.tv_nsec, unique.fetch_add(1, std::memory_order_relaxed)), UDS); @@ -846,7 +847,7 @@ std::vector AllConfigs() { gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); return std::make_unique(absl::StrFormat( "unix-abstract:grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 - ".%d", + ".%" PRId64, getpid(), now.tv_sec, now.tv_nsec, unique.fetch_add(1, std::memory_order_relaxed))); }}, @@ -860,7 +861,8 @@ std::vector AllConfigs() { [](const ChannelArgs&, const ChannelArgs&) { gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); return std::make_unique(absl::StrFormat( - "unix:/tmp/grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 ".%d", + "unix:/tmp/grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 + ".%" PRId64, getpid(), now.tv_sec, now.tv_nsec, unique.fetch_add(1, std::memory_order_relaxed))); }},