From 8ed9680583458ce24545d850a82fab9df7ab41a6 Mon Sep 17 00:00:00 2001 From: apolcyn Date: Fri, 26 Feb 2021 11:35:57 -0800 Subject: [PATCH] Allow C2P resolver's server_uri to be overridden for testing (#25551) * Allow C2P resolver's server_uri to be overridden for testing --- .../resolver/google_c2p/google_c2p_resolver.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc b/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc index d3b9e676916..3488ebc5922 100644 --- a/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc @@ -308,11 +308,18 @@ void GoogleCloud2ProdResolver::StartXdsResolver() { {"TRAFFICDIRECTOR_DIRECTPATH_C2P_IPV6_CAPABLE", true}, }; } + // Allow the TD server uri to be overridden for testing purposes. + UniquePtr override_server( + gpr_getenv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI")); + const char* server_uri = + override_server != nullptr && strlen(override_server.get()) > 0 + ? override_server.get() + : "directpath-trafficdirector.googleapis.com"; Json bootstrap = Json::Object{ {"xds_servers", Json::Array{ Json::Object{ - {"server_uri", "directpath-trafficdirector.googleapis.com"}, + {"server_uri", server_uri}, {"channel_creds", Json::Array{ Json::Object{