Replace absl::Random with std::random in EventEngine test suite (#27765)

Avoids an iOS compatibility problem.
pull/27714/head
AJ Heller 3 years ago committed by GitHub
parent c1d4e96433
commit 72ef0bca54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      test/core/event_engine/BUILD
  2. 11
      test/core/event_engine/test_suite/timer_test.cc

@ -38,7 +38,6 @@ grpc_cc_library(
],
hdrs = ["test_suite/event_engine_test.h"],
external_deps = [
"absl/random",
"gtest",
],
language = "C++",

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <random>
#include <thread>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/functional/bind_front.h"
#include "absl/random/random.h"
#include "absl/time/time.h"
#include <grpc/event_engine/event_engine.h>
@ -146,11 +146,12 @@ TEST_F(EventEngineTimerTest, StressTestTimersNotCalledBeforeScheduled) {
threads.reserve(thread_count);
for (int thread_n = 0; thread_n < thread_count; ++thread_n) {
threads.emplace_back([&]() {
absl::BitGen bitgen;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<> dis(timeout_min_seconds,
timeout_max_seconds);
for (int call_n = 0; call_n < call_count_per_thread; ++call_n) {
absl::Time when = absl::Now() + absl::Seconds(absl::Uniform(
bitgen, timeout_min_seconds,
timeout_max_seconds));
absl::Time when = absl::Now() + absl::Seconds(dis(gen));
engine->RunAt(
when, absl::bind_front(&EventEngineTimerTest::ScheduleCheckCB, this,
when, &call_count, &failed_call_count,

Loading…
Cancel
Save