Merge pull request #14081 from yang-g/cpp17

remove use of random_shuffle
pull/14084/head
Yang Gao 7 years ago committed by GitHub
commit bb2f7e28ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      test/cpp/client/client_channel_stress_test.cc
  2. 7
      test/cpp/end2end/client_lb_end2end_test.cc

@ -19,6 +19,7 @@
#include <atomic>
#include <memory>
#include <mutex>
#include <random>
#include <sstream>
#include <thread>
@ -104,8 +105,8 @@ class BalancerServiceImpl : public LoadBalancer::Service {
for (size_t i = 0; i < num_drop_entry; ++i) {
random_backend_indices.push_back(-1);
}
std::random_shuffle(random_backend_indices.begin(),
random_backend_indices.end());
std::shuffle(random_backend_indices.begin(), random_backend_indices.end(),
std::mt19937(std::random_device()()));
// Build the response according to the random list generated above.
LoadBalanceResponse response;
for (int index : random_backend_indices) {
@ -149,7 +150,8 @@ class ClientChannelStressTest {
addresses.emplace_back(AddressData{balancer_server.port_, true, ""});
}
}
std::random_shuffle(addresses.begin(), addresses.end());
std::shuffle(addresses.begin(), addresses.end(),
std::mt19937(std::random_device()()));
SetNextResolution(addresses);
std::this_thread::sleep_for(wait_duration);
}

@ -19,6 +19,7 @@
#include <algorithm>
#include <memory>
#include <mutex>
#include <random>
#include <thread>
#include <grpc++/channel.h>
@ -456,7 +457,8 @@ TEST_F(ClientLbEnd2endTest, PickFirstManyUpdates) {
grpc_subchannel_index_test_only_set_force_creation(force_creation);
gpr_log(GPR_INFO, "Force subchannel creation: %d", force_creation);
for (size_t i = 0; i < 1000; ++i) {
std::random_shuffle(ports.begin(), ports.end());
std::shuffle(ports.begin(), ports.end(),
std::mt19937(std::random_device()()));
SetNextResolution(ports);
if (i % 10 == 0) CheckRpcSendOk();
}
@ -621,7 +623,8 @@ TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) {
ports.emplace_back(servers_[i]->port_);
}
for (size_t i = 0; i < 1000; ++i) {
std::random_shuffle(ports.begin(), ports.end());
std::shuffle(ports.begin(), ports.end(),
std::mt19937(std::random_device()()));
SetNextResolution(ports);
if (i % 10 == 0) CheckRpcSendOk();
}

Loading…
Cancel
Save