XDS: enable XDS federation by default (#32711)

Integration tests have been green so let's enable this (verification of
test results in https://b.corp.google.com/issues/262593165#comment30).
pull/32737/head
apolcyn 2 years ago committed by GitHub
parent ea839de878
commit 4b46dbc19e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      build_autogenerated.yaml
  2. 6
      src/core/ext/xds/xds_bootstrap.cc
  3. 1
      test/core/xds/BUILD
  4. 8
      test/core/xds/xds_bootstrap_test.cc
  5. 22
      test/core/xds/xds_client_test.cc
  6. 15
      test/cpp/end2end/xds/xds_core_end2end_test.cc

@ -12809,6 +12809,7 @@ targets:
build: test
language: c++
headers:
- test/core/util/scoped_env_var.h
- test/core/xds/xds_transport_fake.h
src:
- src/proto/grpc/testing/xds/v3/base.proto

@ -25,11 +25,11 @@
namespace grpc_core {
// TODO(donnadionne): check to see if federation is enabled, this will be
// removed once federation is fully integrated and enabled by default.
// TODO(roth,apolcyn): remove this federation env var after the 1.55
// release.
bool XdsFederationEnabled() {
auto value = GetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
if (!value.has_value()) return false;
if (!value.has_value()) return true;
bool parsed_value;
bool parse_succeeded = gpr_parse_bool_value(value->c_str(), &parsed_value);
return parse_succeeded && parsed_value;

@ -158,6 +158,7 @@ grpc_cc_test(
"//:xds_client",
"//src/proto/grpc/testing/xds/v3:discovery_proto",
"//test/core/util:grpc_test_util",
"//test/core/util:scoped_env_var",
],
)

@ -56,7 +56,6 @@ namespace testing {
namespace {
TEST(XdsBootstrapTest, Basic) {
SetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION", "true");
const char* json_str =
"{"
" \"xds_servers\": ["
@ -192,7 +191,6 @@ TEST(XdsBootstrapTest, Basic) {
::testing::Property(&Json::string_value, "1")))));
EXPECT_EQ(bootstrap->server_listener_resource_name_template(),
"example/resource");
UnsetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
}
TEST(XdsBootstrapTest, ValidWithoutNode) {
@ -496,7 +494,6 @@ TEST(XdsBootstrapTest, CertificateProvidersUnrecognizedPluginName) {
}
TEST(XdsBootstrapTest, AuthorityXdsServerInvalidResourceTemplate) {
SetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION", "true");
const char* json_str =
"{"
" \"xds_servers\": ["
@ -531,11 +528,9 @@ TEST(XdsBootstrapTest, AuthorityXdsServerInvalidResourceTemplate) {
".client_listener_resource_name_template error:"
"field must begin with \"xdstp://xds.example.com/\"]")
<< bootstrap.status();
UnsetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
}
TEST(XdsBootstrapTest, AuthorityXdsServerMissingServerUri) {
SetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION", "true");
const char* json_str =
"{"
" \"xds_servers\": ["
@ -562,7 +557,6 @@ TEST(XdsBootstrapTest, AuthorityXdsServerMissingServerUri) {
"field:authorities[\"xds.example.com\"].xds_servers[0].server_uri "
"error:field not present]")
<< bootstrap.status();
UnsetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
}
class FakeCertificateProviderFactory : public CertificateProviderFactory {
@ -703,7 +697,6 @@ TEST(XdsBootstrapTest, CertificateProvidersFakePluginEmptyConfig) {
}
TEST(XdsBootstrapTest, XdsServerToJsonAndParse) {
SetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION", "true");
const char* json_str =
" {"
" \"server_uri\": \"fake:///lb\","
@ -724,7 +717,6 @@ TEST(XdsBootstrapTest, XdsServerToJsonAndParse) {
LoadFromJson<GrpcXdsBootstrap::GrpcXdsServer>(output);
ASSERT_TRUE(output_xds_server.ok()) << output_xds_server.status();
EXPECT_EQ(*xds_server, *output_xds_server);
UnsetEnv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
}
} // namespace

@ -47,13 +47,13 @@
#include "src/core/ext/xds/xds_resource_type_impl.h"
#include "src/core/lib/event_engine/default_event_engine.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/env.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/json/json.h"
#include "src/core/lib/json/json_args.h"
#include "src/core/lib/json/json_object_loader.h"
#include "src/proto/grpc/testing/xds/v3/base.pb.h"
#include "src/proto/grpc/testing/xds/v3/discovery.pb.h"
#include "test/core/util/scoped_env_var.h"
#include "test/core/util/test_config.h"
#include "test/core/xds/xds_transport_fake.h"
@ -553,18 +553,6 @@ class XdsClientTest : public ::testing::Test {
DiscoveryResponse response_;
};
class ScopedExperimentalEnvVar {
public:
explicit ScopedExperimentalEnvVar(const char* env_var) : env_var_(env_var) {
SetEnv(env_var_, "true");
}
~ScopedExperimentalEnvVar() { UnsetEnv(env_var_); }
private:
const char* env_var_;
};
// Sets transport_factory_ and initializes xds_client_ with the
// specified bootstrap config.
void InitXdsClient(
@ -2324,7 +2312,6 @@ TEST_F(XdsClientTest, MultipleResourceTypes) {
}
TEST_F(XdsClientTest, Federation) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
constexpr char kAuthority[] = "xds.example.com";
const std::string kXdstpResourceName = absl::StrCat(
"xdstp://", kAuthority, "/", XdsFooResource::TypeUrl(), "/foo2");
@ -2413,7 +2400,6 @@ TEST_F(XdsClientTest, Federation) {
}
TEST_F(XdsClientTest, FederationAuthorityDefaultsToTopLevelXdsServer) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
constexpr char kAuthority[] = "xds.example.com";
const std::string kXdstpResourceName = absl::StrCat(
"xdstp://", kAuthority, "/", XdsFooResource::TypeUrl(), "/foo2");
@ -2502,7 +2488,6 @@ TEST_F(XdsClientTest, FederationAuthorityDefaultsToTopLevelXdsServer) {
}
TEST_F(XdsClientTest, FederationWithUnknownAuthority) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
constexpr char kAuthority[] = "xds.example.com";
const std::string kXdstpResourceName = absl::StrCat(
"xdstp://", kAuthority, "/", XdsFooResource::TypeUrl(), "/foo2");
@ -2520,7 +2505,6 @@ TEST_F(XdsClientTest, FederationWithUnknownAuthority) {
}
TEST_F(XdsClientTest, FederationWithUnparseableXdstpResourceName) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
// Note: Not adding authority to bootstrap config.
InitXdsClient();
// Start a watch for the xdstp resource name.
@ -2533,7 +2517,10 @@ TEST_F(XdsClientTest, FederationWithUnparseableXdstpResourceName) {
<< *error;
}
// TODO(roth,apolcyn): remove this test when the
// GRPC_EXPERIMENTAL_XDS_FEDERATION env var is removed.
TEST_F(XdsClientTest, FederationDisabledWithNewStyleName) {
testing::ScopedEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION", "false");
// We will use this xdstp name, whose authority is not present in
// the bootstrap config. But since federation is not enabled, we
// will treat this as an opaque old-style name, so we'll send it to
@ -2581,7 +2568,6 @@ TEST_F(XdsClientTest, FederationDisabledWithNewStyleName) {
}
TEST_F(XdsClientTest, FederationChannelFailureReportedToWatchers) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
constexpr char kAuthority[] = "xds.example.com";
const std::string kXdstpResourceName = absl::StrCat(
"xdstp://", kAuthority, "/", XdsFooResource::TypeUrl(), "/foo2");

@ -33,8 +33,6 @@ namespace {
using ClientStats = LrsServiceImpl::ClientStats;
using ::grpc_core::testing::ScopedExperimentalEnvVar;
//
// XdsClientTest - basic tests of XdsClient functionality
//
@ -689,7 +687,6 @@ INSTANTIATE_TEST_SUITE_P(
// Bootstrap config default client listener template uses new-style name with
// authority "xds.example.com".
TEST_P(XdsFederationTest, FederationTargetNoAuthorityWithResourceTemplate) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewListenerTemplate =
"xdstp://xds.example.com/envoy.config.listener.v3.Listener/"
@ -746,7 +743,6 @@ TEST_P(XdsFederationTest, FederationTargetNoAuthorityWithResourceTemplate) {
// In bootstrap config, authority has no client listener template, so we use the
// default.
TEST_P(XdsFederationTest, FederationTargetAuthorityDefaultResourceTemplate) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewServerName = "whee%/server.example.com";
const char* kNewListenerName =
@ -813,7 +809,6 @@ TEST_P(XdsFederationTest, FederationTargetAuthorityDefaultResourceTemplate) {
// Channel is created with URI "xds://xds.example.com/server.example.com".
// Bootstrap entry for that authority specifies a client listener name template.
TEST_P(XdsFederationTest, FederationTargetAuthorityWithResourceTemplate) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewServerName = "whee%/server.example.com";
const char* kNewListenerTemplate =
@ -882,7 +877,6 @@ TEST_P(XdsFederationTest, FederationTargetAuthorityWithResourceTemplate) {
}
TEST_P(XdsFederationTest, TargetUriAuthorityUnknown) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewServerName = "whee%/server.example.com";
const char* kNewListenerTemplate =
@ -908,7 +902,6 @@ TEST_P(XdsFederationTest, TargetUriAuthorityUnknown) {
}
TEST_P(XdsFederationTest, RdsResourceNameAuthorityUnknown) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewServerName = "whee%/server.example.com";
const char* kNewListenerTemplate =
@ -952,7 +945,6 @@ TEST_P(XdsFederationTest, RdsResourceNameAuthorityUnknown) {
}
TEST_P(XdsFederationTest, CdsResourceNameAuthorityUnknown) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewServerName = "whee%/server.example.com";
const char* kNewListenerTemplate =
@ -1003,7 +995,6 @@ TEST_P(XdsFederationTest, CdsResourceNameAuthorityUnknown) {
}
TEST_P(XdsFederationTest, EdsResourceNameAuthorityUnknown) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewServerName = "whee%/server.example.com";
const char* kNewListenerTemplate =
@ -1066,7 +1057,6 @@ TEST_P(XdsFederationTest, EdsResourceNameAuthorityUnknown) {
// Setting server_listener_resource_name_template to start with "xdstp:" and
// look up xds server under an authority map.
TEST_P(XdsFederationTest, FederationServer) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewListenerTemplate =
"xdstp://xds.example.com/envoy.config.listener.v3.Listener/"
@ -1154,7 +1144,11 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(XdsTestType().set_enable_rds_testing()),
&XdsTestType::Name);
// TODO(roth,apolcyn): remove this test when the
// GRPC_EXPERIMENTAL_XDS_FEDERATION env var is removed.
TEST_P(XdsFederationDisabledTest, FederationDisabledWithNewStyleNames) {
grpc_core::testing::ScopedEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION",
"false");
const char* kNewRouteConfigName =
"xdstp://xds.example.com/envoy.config.route.v3.RouteConfiguration/"
"new_route_config_name";
@ -1213,7 +1207,6 @@ INSTANTIATE_TEST_SUITE_P(
// Sending traffic to both default balancer and authority balancer and checking
// load reporting with each one.
TEST_P(XdsFederationLoadReportingTest, FederationMultipleLoadReportingTest) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_FEDERATION");
const char* kAuthority = "xds.example.com";
const char* kNewServerName = "whee%/server.example.com";
const char* kNewListenerTemplate =

Loading…
Cancel
Save