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

Reduce test execution from 900ms to 9ms. #217

Merged
merged 2 commits into from
Nov 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions test/common/upstream/load_balancer_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,36 +261,39 @@ TEST_F(RoundRobinLoadBalancerTest, LowPrecisionForDistribution) {

// The following host distribution with current precision should lead to the no_capacity_left
// situation.
// Reuse the same host in all of the structures below to reduce time test takes and this does not
// impact load balancing logic.
HostPtr host = newTestHost(cluster_, "tcp://127.0.0.1:80");
std::vector<HostPtr> current(45000);

for (int i = 0; i < 45000; ++i) {
current[i] = newTestHost(cluster_, "tcp://127.0.0.1:0");
current[i] = host;
}
local_hosts_per_zone->push_back(current);

current.resize(55000);
for (int i = 0; i < 55000; ++i) {
current[i] = newTestHost(cluster_, "tcp://127.0.0.1:0");
current[i] = host;
}
local_hosts_per_zone->push_back(current);
local_cluster_hosts_->updateHosts(local_hosts, local_hosts, local_hosts_per_zone,
local_hosts_per_zone, empty_host_vector_, empty_host_vector_);

current.resize(44999);
for (int i = 0; i < 44999; ++i) {
current[i] = newTestHost(cluster_, "tcp://127.0.0.1:0");
current[i] = host;
}
upstream_hosts_per_zone->push_back(current);

current.resize(55001);
for (int i = 0; i < 55001; ++i) {
current[i] = newTestHost(cluster_, "tcp://127.0.0.1:0");
current[i] = host;
}
upstream_hosts_per_zone->push_back(current);

cluster_.healthy_hosts_per_zone_ = *upstream_hosts_per_zone;

// Force request out of small zone.
// Force request out of small zone and to randomly select zone.
EXPECT_CALL(random_, random()).WillOnce(Return(9999)).WillOnce(Return(2));
lb_->chooseHost();
EXPECT_EQ(1U, stats_.lb_zone_no_capacity_left_.value());
Expand Down