|
|
@ -46,6 +46,9 @@ |
|
|
|
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" |
|
|
|
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h" |
|
|
|
#include "src/core/ext/filters/client_channel/server_address.h" |
|
|
|
#include "src/core/ext/filters/client_channel/server_address.h" |
|
|
|
#include "src/core/ext/xds/xds_api.h" |
|
|
|
#include "src/core/ext/xds/xds_api.h" |
|
|
|
|
|
|
|
#include "src/core/ext/xds/xds_channel_args.h" |
|
|
|
|
|
|
|
#include "src/core/ext/xds/xds_client.h" |
|
|
|
|
|
|
|
#include "src/core/lib/channel/channel_args.h" |
|
|
|
#include "src/core/lib/gpr/env.h" |
|
|
|
#include "src/core/lib/gpr/env.h" |
|
|
|
#include "src/core/lib/gpr/tmpfile.h" |
|
|
|
#include "src/core/lib/gpr/tmpfile.h" |
|
|
|
#include "src/core/lib/gprpp/map.h" |
|
|
|
#include "src/core/lib/gprpp/map.h" |
|
|
@ -144,7 +147,7 @@ constexpr char kBootstrapFileV3[] = |
|
|
|
"{\n" |
|
|
|
"{\n" |
|
|
|
" \"xds_servers\": [\n" |
|
|
|
" \"xds_servers\": [\n" |
|
|
|
" {\n" |
|
|
|
" {\n" |
|
|
|
" \"server_uri\": \"fake:///lb\",\n" |
|
|
|
" \"server_uri\": \"fake:///xds_server\",\n" |
|
|
|
" \"channel_creds\": [\n" |
|
|
|
" \"channel_creds\": [\n" |
|
|
|
" {\n" |
|
|
|
" {\n" |
|
|
|
" \"type\": \"fake\"\n" |
|
|
|
" \"type\": \"fake\"\n" |
|
|
@ -171,7 +174,7 @@ constexpr char kBootstrapFileV2[] = |
|
|
|
"{\n" |
|
|
|
"{\n" |
|
|
|
" \"xds_servers\": [\n" |
|
|
|
" \"xds_servers\": [\n" |
|
|
|
" {\n" |
|
|
|
" {\n" |
|
|
|
" \"server_uri\": \"fake:///lb\",\n" |
|
|
|
" \"server_uri\": \"fake:///xds_server\",\n" |
|
|
|
" \"channel_creds\": [\n" |
|
|
|
" \"channel_creds\": [\n" |
|
|
|
" {\n" |
|
|
|
" {\n" |
|
|
|
" \"type\": \"fake\"\n" |
|
|
|
" \"type\": \"fake\"\n" |
|
|
@ -193,25 +196,8 @@ constexpr char kBootstrapFileV2[] = |
|
|
|
" }\n" |
|
|
|
" }\n" |
|
|
|
"}\n"; |
|
|
|
"}\n"; |
|
|
|
|
|
|
|
|
|
|
|
constexpr char kBootstrapFileBad[] = |
|
|
|
|
|
|
|
"{\n" |
|
|
|
|
|
|
|
" \"xds_servers\": [\n" |
|
|
|
|
|
|
|
" {\n" |
|
|
|
|
|
|
|
" \"server_uri\": \"fake:///wrong_lb\",\n" |
|
|
|
|
|
|
|
" \"channel_creds\": [\n" |
|
|
|
|
|
|
|
" {\n" |
|
|
|
|
|
|
|
" \"type\": \"fake\"\n" |
|
|
|
|
|
|
|
" }\n" |
|
|
|
|
|
|
|
" ]\n" |
|
|
|
|
|
|
|
" }\n" |
|
|
|
|
|
|
|
" ],\n" |
|
|
|
|
|
|
|
" \"node\": {\n" |
|
|
|
|
|
|
|
" }\n" |
|
|
|
|
|
|
|
"}\n"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char* g_bootstrap_file_v3; |
|
|
|
char* g_bootstrap_file_v3; |
|
|
|
char* g_bootstrap_file_v2; |
|
|
|
char* g_bootstrap_file_v2; |
|
|
|
char* g_bootstrap_file_bad; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void WriteBootstrapFiles() { |
|
|
|
void WriteBootstrapFiles() { |
|
|
|
char* bootstrap_file; |
|
|
|
char* bootstrap_file; |
|
|
@ -223,10 +209,6 @@ void WriteBootstrapFiles() { |
|
|
|
fputs(kBootstrapFileV2, out); |
|
|
|
fputs(kBootstrapFileV2, out); |
|
|
|
fclose(out); |
|
|
|
fclose(out); |
|
|
|
g_bootstrap_file_v2 = bootstrap_file; |
|
|
|
g_bootstrap_file_v2 = bootstrap_file; |
|
|
|
out = gpr_tmpfile("xds_bootstrap_bad", &bootstrap_file); |
|
|
|
|
|
|
|
fputs(kBootstrapFileBad, out); |
|
|
|
|
|
|
|
fclose(out); |
|
|
|
|
|
|
|
g_bootstrap_file_bad = bootstrap_file; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Helper class to minimize the number of unique ports we use for this test.
|
|
|
|
// Helper class to minimize the number of unique ports we use for this test.
|
|
|
@ -842,6 +824,12 @@ class AdsServiceImpl : public std::enable_shared_from_this<AdsServiceImpl> { |
|
|
|
resource->set_type_url(request.type_url()); |
|
|
|
resource->set_type_url(request.type_url()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
gpr_log(GPR_INFO, |
|
|
|
|
|
|
|
"ADS[%p]: client does not need update for " |
|
|
|
|
|
|
|
"type=%s name=%s version=%d", |
|
|
|
|
|
|
|
this, request.type_url().c_str(), |
|
|
|
|
|
|
|
resource_name.c_str(), resource_state.version); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// Process unsubscriptions for any resource no longer
|
|
|
|
// Process unsubscriptions for any resource no longer
|
|
|
@ -1349,8 +1337,20 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> { |
|
|
|
g_port_saver->Reset(); |
|
|
|
g_port_saver->Reset(); |
|
|
|
response_generator_ = |
|
|
|
response_generator_ = |
|
|
|
grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); |
|
|
|
grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); |
|
|
|
|
|
|
|
// Inject xDS channel response generator.
|
|
|
|
lb_channel_response_generator_ = |
|
|
|
lb_channel_response_generator_ = |
|
|
|
grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); |
|
|
|
grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>(); |
|
|
|
|
|
|
|
xds_channel_args_to_add_.emplace_back( |
|
|
|
|
|
|
|
grpc_core::FakeResolverResponseGenerator::MakeChannelArg( |
|
|
|
|
|
|
|
lb_channel_response_generator_.get())); |
|
|
|
|
|
|
|
if (xds_resource_does_not_exist_timeout_ms_ > 0) { |
|
|
|
|
|
|
|
xds_channel_args_to_add_.emplace_back(grpc_channel_arg_integer_create( |
|
|
|
|
|
|
|
GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS, |
|
|
|
|
|
|
|
xds_resource_does_not_exist_timeout_ms_)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
xds_channel_args_.num_args = xds_channel_args_to_add_.size(); |
|
|
|
|
|
|
|
xds_channel_args_.args = xds_channel_args_to_add_.data(); |
|
|
|
|
|
|
|
grpc_core::internal::SetXdsChannelArgsForTest(&xds_channel_args_); |
|
|
|
// Start the backends.
|
|
|
|
// Start the backends.
|
|
|
|
for (size_t i = 0; i < num_backends_; ++i) { |
|
|
|
for (size_t i = 0; i < num_backends_; ++i) { |
|
|
|
backends_.emplace_back(new BackendServerThread); |
|
|
|
backends_.emplace_back(new BackendServerThread); |
|
|
@ -1391,31 +1391,16 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> { |
|
|
|
|
|
|
|
|
|
|
|
void ShutdownBackend(size_t index) { backends_[index]->Shutdown(); } |
|
|
|
void ShutdownBackend(size_t index) { backends_[index]->Shutdown(); } |
|
|
|
|
|
|
|
|
|
|
|
void ResetStub(int failover_timeout = 0, |
|
|
|
void ResetStub(int failover_timeout = 0) { |
|
|
|
const std::string& expected_targets = "", |
|
|
|
|
|
|
|
int xds_resource_does_not_exist_timeout = 0) { |
|
|
|
|
|
|
|
ChannelArguments args; |
|
|
|
ChannelArguments args; |
|
|
|
if (failover_timeout > 0) { |
|
|
|
if (failover_timeout > 0) { |
|
|
|
args.SetInt(GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS, failover_timeout); |
|
|
|
args.SetInt(GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS, failover_timeout); |
|
|
|
} |
|
|
|
} |
|
|
|
if (xds_resource_does_not_exist_timeout > 0) { |
|
|
|
|
|
|
|
args.SetInt(GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS, |
|
|
|
|
|
|
|
xds_resource_does_not_exist_timeout); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// If the parent channel is using the fake resolver, we inject the
|
|
|
|
// If the parent channel is using the fake resolver, we inject the
|
|
|
|
// response generator for the parent here, and then SetNextResolution()
|
|
|
|
// response generator here.
|
|
|
|
// will inject the xds channel's response generator via the parent's
|
|
|
|
if (!GetParam().use_xds_resolver()) { |
|
|
|
// response generator.
|
|
|
|
args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, |
|
|
|
//
|
|
|
|
response_generator_.get()); |
|
|
|
// In contrast, if we are using the xds resolver, then the parent
|
|
|
|
|
|
|
|
// channel never uses a response generator, and we inject the xds
|
|
|
|
|
|
|
|
// channel's response generator here.
|
|
|
|
|
|
|
|
args.SetPointer(GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR, |
|
|
|
|
|
|
|
GetParam().use_xds_resolver() |
|
|
|
|
|
|
|
? lb_channel_response_generator_.get() |
|
|
|
|
|
|
|
: response_generator_.get()); |
|
|
|
|
|
|
|
if (!expected_targets.empty()) { |
|
|
|
|
|
|
|
args.SetString(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS, expected_targets); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
std::string uri = absl::StrCat( |
|
|
|
std::string uri = absl::StrCat( |
|
|
|
GetParam().use_xds_resolver() ? "xds" : "fake", ":///", kServerName); |
|
|
|
GetParam().use_xds_resolver() ? "xds" : "fake", ":///", kServerName); |
|
|
@ -1603,9 +1588,7 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> { |
|
|
|
return addresses; |
|
|
|
return addresses; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SetNextResolution(const std::vector<int>& ports, |
|
|
|
void SetNextResolution(const std::vector<int>& ports) { |
|
|
|
grpc_core::FakeResolverResponseGenerator* |
|
|
|
|
|
|
|
lb_channel_response_generator = nullptr) { |
|
|
|
|
|
|
|
if (GetParam().use_xds_resolver()) return; // Not used with xds resolver.
|
|
|
|
if (GetParam().use_xds_resolver()) return; // Not used with xds resolver.
|
|
|
|
grpc_core::ExecCtx exec_ctx; |
|
|
|
grpc_core::ExecCtx exec_ctx; |
|
|
|
grpc_core::Resolver::Result result; |
|
|
|
grpc_core::Resolver::Result result; |
|
|
@ -1619,30 +1602,22 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> { |
|
|
|
grpc_core::ServiceConfig::Create(service_config_json, &error); |
|
|
|
grpc_core::ServiceConfig::Create(service_config_json, &error); |
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); |
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); |
|
|
|
ASSERT_NE(result.service_config.get(), nullptr); |
|
|
|
ASSERT_NE(result.service_config.get(), nullptr); |
|
|
|
grpc_arg arg = grpc_core::FakeResolverResponseGenerator::MakeChannelArg( |
|
|
|
|
|
|
|
lb_channel_response_generator == nullptr |
|
|
|
|
|
|
|
? lb_channel_response_generator_.get() |
|
|
|
|
|
|
|
: lb_channel_response_generator); |
|
|
|
|
|
|
|
result.args = grpc_channel_args_copy_and_add(nullptr, &arg, 1); |
|
|
|
|
|
|
|
response_generator_->SetResponse(std::move(result)); |
|
|
|
response_generator_->SetResponse(std::move(result)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SetNextResolutionForLbChannelAllBalancers( |
|
|
|
void SetNextResolutionForLbChannelAllBalancers( |
|
|
|
const char* service_config_json = nullptr, |
|
|
|
const char* service_config_json = nullptr, |
|
|
|
grpc_core::FakeResolverResponseGenerator* lb_channel_response_generator = |
|
|
|
const char* expected_targets = nullptr) { |
|
|
|
nullptr) { |
|
|
|
|
|
|
|
std::vector<int> ports; |
|
|
|
std::vector<int> ports; |
|
|
|
for (size_t i = 0; i < balancers_.size(); ++i) { |
|
|
|
for (size_t i = 0; i < balancers_.size(); ++i) { |
|
|
|
ports.emplace_back(balancers_[i]->port()); |
|
|
|
ports.emplace_back(balancers_[i]->port()); |
|
|
|
} |
|
|
|
} |
|
|
|
SetNextResolutionForLbChannel(ports, service_config_json, |
|
|
|
SetNextResolutionForLbChannel(ports, service_config_json, expected_targets); |
|
|
|
lb_channel_response_generator); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SetNextResolutionForLbChannel( |
|
|
|
void SetNextResolutionForLbChannel(const std::vector<int>& ports, |
|
|
|
const std::vector<int>& ports, const char* service_config_json = nullptr, |
|
|
|
const char* service_config_json = nullptr, |
|
|
|
grpc_core::FakeResolverResponseGenerator* lb_channel_response_generator = |
|
|
|
const char* expected_targets = nullptr) { |
|
|
|
nullptr) { |
|
|
|
|
|
|
|
grpc_core::ExecCtx exec_ctx; |
|
|
|
grpc_core::ExecCtx exec_ctx; |
|
|
|
grpc_core::Resolver::Result result; |
|
|
|
grpc_core::Resolver::Result result; |
|
|
|
result.addresses = CreateAddressListFromPortList(ports); |
|
|
|
result.addresses = CreateAddressListFromPortList(ports); |
|
|
@ -1653,10 +1628,14 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> { |
|
|
|
ASSERT_NE(result.service_config.get(), nullptr); |
|
|
|
ASSERT_NE(result.service_config.get(), nullptr); |
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); |
|
|
|
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_string(error); |
|
|
|
} |
|
|
|
} |
|
|
|
if (lb_channel_response_generator == nullptr) { |
|
|
|
if (expected_targets != nullptr) { |
|
|
|
lb_channel_response_generator = lb_channel_response_generator_.get(); |
|
|
|
grpc_arg expected_targets_arg = grpc_channel_arg_string_create( |
|
|
|
|
|
|
|
const_cast<char*>(GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS), |
|
|
|
|
|
|
|
const_cast<char*>(expected_targets)); |
|
|
|
|
|
|
|
result.args = |
|
|
|
|
|
|
|
grpc_channel_args_copy_and_add(nullptr, &expected_targets_arg, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
lb_channel_response_generator->SetResponse(std::move(result)); |
|
|
|
lb_channel_response_generator_->SetResponse(std::move(result)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SetNextReresolutionResponse(const std::vector<int>& ports) { |
|
|
|
void SetNextReresolutionResponse(const std::vector<int>& ports) { |
|
|
@ -1725,9 +1704,10 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CheckRpcSendFailure(const size_t times = 1, bool server_fail = false) { |
|
|
|
void CheckRpcSendFailure(const size_t times = 1, |
|
|
|
|
|
|
|
const RpcOptions& rpc_options = RpcOptions()) { |
|
|
|
for (size_t i = 0; i < times; ++i) { |
|
|
|
for (size_t i = 0; i < times; ++i) { |
|
|
|
const Status status = SendRpc(RpcOptions().set_server_fail(server_fail)); |
|
|
|
const Status status = SendRpc(rpc_options); |
|
|
|
EXPECT_FALSE(status.ok()); |
|
|
|
EXPECT_FALSE(status.ok()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1912,6 +1892,9 @@ class XdsEnd2endTest : public ::testing::TestWithParam<TestType> { |
|
|
|
response_generator_; |
|
|
|
response_generator_; |
|
|
|
grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> |
|
|
|
grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator> |
|
|
|
lb_channel_response_generator_; |
|
|
|
lb_channel_response_generator_; |
|
|
|
|
|
|
|
int xds_resource_does_not_exist_timeout_ms_ = 0; |
|
|
|
|
|
|
|
absl::InlinedVector<grpc_arg, 2> xds_channel_args_to_add_; |
|
|
|
|
|
|
|
grpc_channel_args xds_channel_args_; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class BasicTest : public XdsEnd2endTest { |
|
|
|
class BasicTest : public XdsEnd2endTest { |
|
|
@ -2384,43 +2367,30 @@ using SecureNamingTest = BasicTest; |
|
|
|
|
|
|
|
|
|
|
|
// Tests that secure naming check passes if target name is expected.
|
|
|
|
// Tests that secure naming check passes if target name is expected.
|
|
|
|
TEST_P(SecureNamingTest, TargetNameIsExpected) { |
|
|
|
TEST_P(SecureNamingTest, TargetNameIsExpected) { |
|
|
|
// TODO(juanlishen): Use separate fake creds for the balancer channel.
|
|
|
|
|
|
|
|
ResetStub(0, absl::StrCat(kServerName, ";lb")); |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
SetNextResolution({}); |
|
|
|
SetNextResolutionForLbChannel({balancers_[0]->port()}); |
|
|
|
SetNextResolutionForLbChannel({balancers_[0]->port()}, nullptr, "xds_server"); |
|
|
|
const size_t kNumRpcsPerAddress = 100; |
|
|
|
|
|
|
|
AdsServiceImpl::EdsResourceArgs args({ |
|
|
|
AdsServiceImpl::EdsResourceArgs args({ |
|
|
|
{"locality0", GetBackendPorts()}, |
|
|
|
{"locality0", GetBackendPorts()}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
balancers_[0]->ads_service()->SetEdsResource( |
|
|
|
balancers_[0]->ads_service()->SetEdsResource( |
|
|
|
AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); |
|
|
|
AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); |
|
|
|
// Make sure that trying to connect works without a call.
|
|
|
|
CheckRpcSendOk(); |
|
|
|
channel_->GetState(true /* try_to_connect */); |
|
|
|
|
|
|
|
// We need to wait for all backends to come online.
|
|
|
|
|
|
|
|
WaitForAllBackends(); |
|
|
|
|
|
|
|
// Send kNumRpcsPerAddress RPCs per server.
|
|
|
|
|
|
|
|
CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); |
|
|
|
|
|
|
|
// Each backend should have gotten 100 requests.
|
|
|
|
|
|
|
|
for (size_t i = 0; i < backends_.size(); ++i) { |
|
|
|
|
|
|
|
EXPECT_EQ(kNumRpcsPerAddress, |
|
|
|
|
|
|
|
backends_[i]->backend_service()->request_count()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Tests that secure naming check fails if target name is unexpected.
|
|
|
|
// Tests that secure naming check fails if target name is unexpected.
|
|
|
|
TEST_P(SecureNamingTest, TargetNameIsUnexpected) { |
|
|
|
TEST_P(SecureNamingTest, TargetNameIsUnexpected) { |
|
|
|
gpr_setenv("GRPC_XDS_BOOTSTRAP", g_bootstrap_file_bad); |
|
|
|
|
|
|
|
::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
|
|
|
::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannel({balancers_[0]->port()}, nullptr, |
|
|
|
|
|
|
|
"incorrect_server_name"); |
|
|
|
|
|
|
|
AdsServiceImpl::EdsResourceArgs args({ |
|
|
|
|
|
|
|
{"locality0", GetBackendPorts()}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetEdsResource( |
|
|
|
|
|
|
|
AdsServiceImpl::BuildEdsResource(args, DefaultEdsServiceName())); |
|
|
|
// Make sure that we blow up (via abort() from the security connector) when
|
|
|
|
// Make sure that we blow up (via abort() from the security connector) when
|
|
|
|
// the name from the balancer doesn't match expectations.
|
|
|
|
// the name from the balancer doesn't match expectations.
|
|
|
|
ASSERT_DEATH_IF_SUPPORTED( |
|
|
|
ASSERT_DEATH_IF_SUPPORTED({ CheckRpcSendOk(); }, ""); |
|
|
|
{ |
|
|
|
|
|
|
|
ResetStub(0, absl::StrCat(kServerName, ";lb")); |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannel({balancers_[0]->port()}); |
|
|
|
|
|
|
|
channel_->WaitForConnected(grpc_timeout_seconds_to_deadline(1)); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
""); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
using LdsTest = BasicTest; |
|
|
|
using LdsTest = BasicTest; |
|
|
@ -2964,19 +2934,6 @@ TEST_P(LdsRdsTest, RouteHeaderMatchInvalidRange) { |
|
|
|
"cannot be smaller than start."); |
|
|
|
"cannot be smaller than start."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Tests that LDS client times out when no response received.
|
|
|
|
|
|
|
|
TEST_P(LdsRdsTest, Timeout) { |
|
|
|
|
|
|
|
ResetStub(0, "", 500); |
|
|
|
|
|
|
|
if (GetParam().enable_rds_testing()) { |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetResourceIgnore(kRdsTypeUrl); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetResourceIgnore(kLdsTypeUrl); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tests that LDS client should choose the default route (with no matching
|
|
|
|
// Tests that LDS client should choose the default route (with no matching
|
|
|
|
// specified) after unable to find a match with previous routes.
|
|
|
|
// specified) after unable to find a match with previous routes.
|
|
|
|
TEST_P(LdsRdsTest, XdsRoutingPathMatching) { |
|
|
|
TEST_P(LdsRdsTest, XdsRoutingPathMatching) { |
|
|
@ -4270,25 +4227,8 @@ TEST_P(CdsTest, WrongLrsServer) { |
|
|
|
EXPECT_EQ(response_state.error_message, "LRS ConfigSource is not self."); |
|
|
|
EXPECT_EQ(response_state.error_message, "LRS ConfigSource is not self."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Tests that CDS client times out when no response received.
|
|
|
|
|
|
|
|
TEST_P(CdsTest, Timeout) { |
|
|
|
|
|
|
|
ResetStub(0, "", 500); |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetResourceIgnore(kCdsTypeUrl); |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using EdsTest = BasicTest; |
|
|
|
using EdsTest = BasicTest; |
|
|
|
|
|
|
|
|
|
|
|
TEST_P(EdsTest, Timeout) { |
|
|
|
|
|
|
|
ResetStub(0, "", 500); |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetResourceIgnore(kEdsTypeUrl); |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tests that EDS client should send a NACK if the EDS update contains
|
|
|
|
// Tests that EDS client should send a NACK if the EDS update contains
|
|
|
|
// sparse priorities.
|
|
|
|
// sparse priorities.
|
|
|
|
TEST_P(EdsTest, NacksSparsePriorityList) { |
|
|
|
TEST_P(EdsTest, NacksSparsePriorityList) { |
|
|
@ -4326,6 +4266,44 @@ TEST_P(EdsTest, EdsServiceNameDefaultsToClusterName) { |
|
|
|
CheckRpcSendOk(); |
|
|
|
CheckRpcSendOk(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TimeoutTest : public BasicTest { |
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
void SetUp() override { |
|
|
|
|
|
|
|
xds_resource_does_not_exist_timeout_ms_ = 500; |
|
|
|
|
|
|
|
BasicTest::SetUp(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tests that LDS client times out when no response received.
|
|
|
|
|
|
|
|
TEST_P(TimeoutTest, Lds) { |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetResourceIgnore(kLdsTypeUrl); |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(TimeoutTest, Rds) { |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetResourceIgnore(kRdsTypeUrl); |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tests that CDS client times out when no response received.
|
|
|
|
|
|
|
|
TEST_P(TimeoutTest, Cds) { |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetResourceIgnore(kCdsTypeUrl); |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(TimeoutTest, Eds) { |
|
|
|
|
|
|
|
balancers_[0]->ads_service()->SetResourceIgnore(kEdsTypeUrl); |
|
|
|
|
|
|
|
SetNextResolution({}); |
|
|
|
|
|
|
|
SetNextResolutionForLbChannelAllBalancers(); |
|
|
|
|
|
|
|
CheckRpcSendFailure(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
using LocalityMapTest = BasicTest; |
|
|
|
using LocalityMapTest = BasicTest; |
|
|
|
|
|
|
|
|
|
|
|
// Tests that the localities in a locality map are picked according to their
|
|
|
|
// Tests that the localities in a locality map are picked according to their
|
|
|
@ -4564,7 +4542,7 @@ class FailoverTest : public BasicTest { |
|
|
|
public: |
|
|
|
public: |
|
|
|
void SetUp() override { |
|
|
|
void SetUp() override { |
|
|
|
BasicTest::SetUp(); |
|
|
|
BasicTest::SetUp(); |
|
|
|
ResetStub(500, ""); |
|
|
|
ResetStub(500); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -5276,7 +5254,7 @@ TEST_P(ClientLoadReportingTest, Vanilla) { |
|
|
|
// Send kNumRpcsPerAddress RPCs per server.
|
|
|
|
// Send kNumRpcsPerAddress RPCs per server.
|
|
|
|
CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); |
|
|
|
CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); |
|
|
|
CheckRpcSendFailure(kNumFailuresPerAddress * num_backends_, |
|
|
|
CheckRpcSendFailure(kNumFailuresPerAddress * num_backends_, |
|
|
|
/*server_fail=*/true); |
|
|
|
RpcOptions().set_server_fail(true)); |
|
|
|
// Check that each backend got the right number of requests.
|
|
|
|
// Check that each backend got the right number of requests.
|
|
|
|
for (size_t i = 0; i < backends_.size(); ++i) { |
|
|
|
for (size_t i = 0; i < backends_.size(); ++i) { |
|
|
|
EXPECT_EQ(kNumRpcsPerAddress + kNumFailuresPerAddress, |
|
|
|
EXPECT_EQ(kNumRpcsPerAddress + kNumFailuresPerAddress, |
|
|
@ -5323,7 +5301,7 @@ TEST_P(ClientLoadReportingTest, SendAllClusters) { |
|
|
|
// Send kNumRpcsPerAddress RPCs per server.
|
|
|
|
// Send kNumRpcsPerAddress RPCs per server.
|
|
|
|
CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); |
|
|
|
CheckRpcSendOk(kNumRpcsPerAddress * num_backends_); |
|
|
|
CheckRpcSendFailure(kNumFailuresPerAddress * num_backends_, |
|
|
|
CheckRpcSendFailure(kNumFailuresPerAddress * num_backends_, |
|
|
|
/*server_fail=*/true); |
|
|
|
RpcOptions().set_server_fail(true)); |
|
|
|
// Check that each backend got the right number of requests.
|
|
|
|
// Check that each backend got the right number of requests.
|
|
|
|
for (size_t i = 0; i < backends_.size(); ++i) { |
|
|
|
for (size_t i = 0; i < backends_.size(); ++i) { |
|
|
|
EXPECT_EQ(kNumRpcsPerAddress + kNumFailuresPerAddress, |
|
|
|
EXPECT_EQ(kNumRpcsPerAddress + kNumFailuresPerAddress, |
|
|
@ -5536,6 +5514,12 @@ std::string TestTypeName(const ::testing::TestParamInfo<TestType>& info) { |
|
|
|
return info.param.AsString(); |
|
|
|
return info.param.AsString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TestType params:
|
|
|
|
|
|
|
|
// - use_xds_resolver
|
|
|
|
|
|
|
|
// - enable_load_reporting
|
|
|
|
|
|
|
|
// - enable_rds_testing = false
|
|
|
|
|
|
|
|
// - use_v2 = false
|
|
|
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_SUITE_P(XdsTest, BasicTest, |
|
|
|
INSTANTIATE_TEST_SUITE_P(XdsTest, BasicTest, |
|
|
|
::testing::Values(TestType(false, true), |
|
|
|
::testing::Values(TestType(false, true), |
|
|
|
TestType(false, false), |
|
|
|
TestType(false, false), |
|
|
@ -5543,11 +5527,12 @@ INSTANTIATE_TEST_SUITE_P(XdsTest, BasicTest, |
|
|
|
TestType(true, true)), |
|
|
|
TestType(true, true)), |
|
|
|
&TestTypeName); |
|
|
|
&TestTypeName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Run with both fake resolver and xds resolver.
|
|
|
|
|
|
|
|
// Don't run with load reporting or v2 or RDS, since they are irrelevant to
|
|
|
|
|
|
|
|
// the tests.
|
|
|
|
INSTANTIATE_TEST_SUITE_P(XdsTest, SecureNamingTest, |
|
|
|
INSTANTIATE_TEST_SUITE_P(XdsTest, SecureNamingTest, |
|
|
|
::testing::Values(TestType(false, true), |
|
|
|
::testing::Values(TestType(false, false), |
|
|
|
TestType(false, false), |
|
|
|
TestType(true, false)), |
|
|
|
TestType(true, false), |
|
|
|
|
|
|
|
TestType(true, true)), |
|
|
|
|
|
|
|
&TestTypeName); |
|
|
|
&TestTypeName); |
|
|
|
|
|
|
|
|
|
|
|
// LDS depends on XdsResolver.
|
|
|
|
// LDS depends on XdsResolver.
|
|
|
@ -5579,6 +5564,14 @@ INSTANTIATE_TEST_SUITE_P(XdsTest, EdsTest, |
|
|
|
TestType(true, true)), |
|
|
|
TestType(true, true)), |
|
|
|
&TestTypeName); |
|
|
|
&TestTypeName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test initial resource timeouts for each resource type.
|
|
|
|
|
|
|
|
// Do this only for XdsResolver with RDS enabled, so that we can test
|
|
|
|
|
|
|
|
// all resource types.
|
|
|
|
|
|
|
|
// Run with V3 only, since the functionality is no different in V2.
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_SUITE_P(XdsTest, TimeoutTest, |
|
|
|
|
|
|
|
::testing::Values(TestType(true, false, true)), |
|
|
|
|
|
|
|
&TestTypeName); |
|
|
|
|
|
|
|
|
|
|
|
// XdsResolverOnlyTest depends on XdsResolver.
|
|
|
|
// XdsResolverOnlyTest depends on XdsResolver.
|
|
|
|
INSTANTIATE_TEST_SUITE_P(XdsTest, XdsResolverOnlyTest, |
|
|
|
INSTANTIATE_TEST_SUITE_P(XdsTest, XdsResolverOnlyTest, |
|
|
|
::testing::Values(TestType(true, false), |
|
|
|
::testing::Values(TestType(true, false), |
|
|
|