|
|
|
@ -353,11 +353,6 @@ class GrpclbEnd2endTest : public ::testing::Test { |
|
|
|
|
"balancer", server_host_, balancers_.back().get())); |
|
|
|
|
} |
|
|
|
|
ResetStub(); |
|
|
|
|
std::vector<AddressData> addresses; |
|
|
|
|
for (size_t i = 0; i < balancer_servers_.size(); ++i) { |
|
|
|
|
addresses.emplace_back(AddressData{balancer_servers_[i].port_, true, ""}); |
|
|
|
|
} |
|
|
|
|
SetNextResolution(addresses); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TearDown() override { |
|
|
|
@ -370,6 +365,14 @@ class GrpclbEnd2endTest : public ::testing::Test { |
|
|
|
|
grpc_fake_resolver_response_generator_unref(response_generator_); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SetNextResolutionAllBalancers() { |
|
|
|
|
std::vector<AddressData> addresses; |
|
|
|
|
for (size_t i = 0; i < balancer_servers_.size(); ++i) { |
|
|
|
|
addresses.emplace_back(AddressData{balancer_servers_[i].port_, true, ""}); |
|
|
|
|
} |
|
|
|
|
SetNextResolution(addresses); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ResetStub(int fallback_timeout = 0) { |
|
|
|
|
ChannelArguments args; |
|
|
|
|
args.SetGrpclbFallbackTimeout(fallback_timeout); |
|
|
|
@ -581,6 +584,7 @@ class SingleBalancerTest : public GrpclbEnd2endTest { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerTest, Vanilla) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const size_t kNumRpcsPerAddress = 100; |
|
|
|
|
ScheduleResponseForBalancer( |
|
|
|
|
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), |
|
|
|
@ -608,6 +612,7 @@ TEST_F(SingleBalancerTest, Vanilla) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); |
|
|
|
|
const int kCallDeadlineMs = 1000 * grpc_test_slowdown_factor(); |
|
|
|
|
|
|
|
|
@ -645,6 +650,7 @@ TEST_F(SingleBalancerTest, InitiallyEmptyServerlist) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerTest, Fallback) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); |
|
|
|
|
const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); |
|
|
|
|
const size_t kNumBackendInResolution = backends_.size() / 2; |
|
|
|
@ -711,6 +717,7 @@ TEST_F(SingleBalancerTest, Fallback) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerTest, FallbackUpdate) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const int kFallbackTimeoutMs = 200 * grpc_test_slowdown_factor(); |
|
|
|
|
const int kServerlistDelayMs = 500 * grpc_test_slowdown_factor(); |
|
|
|
|
const size_t kNumBackendInResolution = backends_.size() / 3; |
|
|
|
@ -818,6 +825,7 @@ TEST_F(SingleBalancerTest, FallbackUpdate) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerTest, BackendsRestart) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const size_t kNumRpcsPerAddress = 100; |
|
|
|
|
ScheduleResponseForBalancer( |
|
|
|
|
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), |
|
|
|
@ -857,6 +865,7 @@ class UpdatesTest : public GrpclbEnd2endTest { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_F(UpdatesTest, UpdateBalancers) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const std::vector<int> first_backend{GetBackendPorts()[0]}; |
|
|
|
|
const std::vector<int> second_backend{GetBackendPorts()[1]}; |
|
|
|
|
ScheduleResponseForBalancer( |
|
|
|
@ -919,6 +928,7 @@ TEST_F(UpdatesTest, UpdateBalancers) { |
|
|
|
|
// verify that the LB channel inside grpclb keeps the initial connection (which
|
|
|
|
|
// by definition is also present in the update).
|
|
|
|
|
TEST_F(UpdatesTest, UpdateBalancersRepeated) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const std::vector<int> first_backend{GetBackendPorts()[0]}; |
|
|
|
|
const std::vector<int> second_backend{GetBackendPorts()[0]}; |
|
|
|
|
|
|
|
|
@ -989,6 +999,9 @@ TEST_F(UpdatesTest, UpdateBalancersRepeated) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { |
|
|
|
|
std::vector<AddressData> addresses; |
|
|
|
|
addresses.emplace_back(AddressData{balancer_servers_[0].port_, true, ""}); |
|
|
|
|
SetNextResolution(addresses); |
|
|
|
|
const std::vector<int> first_backend{GetBackendPorts()[0]}; |
|
|
|
|
const std::vector<int> second_backend{GetBackendPorts()[1]}; |
|
|
|
|
|
|
|
|
@ -1030,7 +1043,7 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { |
|
|
|
|
EXPECT_EQ(0U, balancer_servers_[2].service_->request_count()); |
|
|
|
|
EXPECT_EQ(0U, balancer_servers_[2].service_->response_count()); |
|
|
|
|
|
|
|
|
|
std::vector<AddressData> addresses; |
|
|
|
|
addresses.clear(); |
|
|
|
|
addresses.emplace_back(AddressData{balancer_servers_[1].port_, true, ""}); |
|
|
|
|
gpr_log(GPR_INFO, "========= ABOUT TO UPDATE 1 =========="); |
|
|
|
|
SetNextResolution(addresses); |
|
|
|
@ -1055,8 +1068,14 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { |
|
|
|
|
balancers_[2]->NotifyDoneWithServerlists(); |
|
|
|
|
EXPECT_EQ(1U, balancer_servers_[0].service_->request_count()); |
|
|
|
|
EXPECT_EQ(1U, balancer_servers_[0].service_->response_count()); |
|
|
|
|
EXPECT_EQ(1U, balancer_servers_[1].service_->request_count()); |
|
|
|
|
EXPECT_EQ(1U, balancer_servers_[1].service_->response_count()); |
|
|
|
|
// The second balancer, published as part of the first update, may end up
|
|
|
|
|
// getting two requests (that is, 1 <= #req <= 2) if the LB call retry timer
|
|
|
|
|
// firing races with the arrival of the update containing the second
|
|
|
|
|
// balancer.
|
|
|
|
|
EXPECT_GE(balancer_servers_[1].service_->request_count(), 1U); |
|
|
|
|
EXPECT_GE(balancer_servers_[1].service_->response_count(), 1U); |
|
|
|
|
EXPECT_LE(balancer_servers_[1].service_->request_count(), 2U); |
|
|
|
|
EXPECT_LE(balancer_servers_[1].service_->response_count(), 2U); |
|
|
|
|
EXPECT_EQ(0U, balancer_servers_[2].service_->request_count()); |
|
|
|
|
EXPECT_EQ(0U, balancer_servers_[2].service_->response_count()); |
|
|
|
|
// Check LB policy name for the channel.
|
|
|
|
@ -1064,6 +1083,7 @@ TEST_F(UpdatesTest, UpdateBalancersDeadUpdate) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerTest, Drop) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const size_t kNumRpcsPerAddress = 100; |
|
|
|
|
const int num_of_drop_by_rate_limiting_addresses = 1; |
|
|
|
|
const int num_of_drop_by_load_balancing_addresses = 2; |
|
|
|
@ -1107,6 +1127,7 @@ TEST_F(SingleBalancerTest, Drop) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerTest, DropAllFirst) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
// All registered addresses are marked as "drop".
|
|
|
|
|
const int num_of_drop_by_rate_limiting_addresses = 1; |
|
|
|
|
const int num_of_drop_by_load_balancing_addresses = 1; |
|
|
|
@ -1122,6 +1143,7 @@ TEST_F(SingleBalancerTest, DropAllFirst) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerTest, DropAll) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
ScheduleResponseForBalancer( |
|
|
|
|
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), |
|
|
|
|
0); |
|
|
|
@ -1152,6 +1174,7 @@ class SingleBalancerWithClientLoadReportingTest : public GrpclbEnd2endTest { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const size_t kNumRpcsPerAddress = 100; |
|
|
|
|
ScheduleResponseForBalancer( |
|
|
|
|
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}), |
|
|
|
@ -1186,6 +1209,7 @@ TEST_F(SingleBalancerWithClientLoadReportingTest, Vanilla) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(SingleBalancerWithClientLoadReportingTest, Drop) { |
|
|
|
|
SetNextResolutionAllBalancers(); |
|
|
|
|
const size_t kNumRpcsPerAddress = 3; |
|
|
|
|
const int num_of_drop_by_rate_limiting_addresses = 2; |
|
|
|
|
const int num_of_drop_by_load_balancing_addresses = 1; |
|
|
|
|