mirror of https://github.com/grpc/grpc-java.git
xds: move methods for building test xDS proto messages into a utility class (#6501)
Move helper methods for building xDS protobuf messages into a utility class for code sharing. Tests for gRPC components that use `XdsClient` instance may want to use these methods as well.
This commit is contained in:
parent
718f0369cb
commit
2de5b4e254
|
|
@ -17,6 +17,18 @@
|
|||
package io.grpc.xds;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildCluster;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildClusterLoadAssignment;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildDiscoveryRequest;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildDiscoveryResponse;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildDropOverload;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildLbEndpoint;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildListener;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildLocalityLbEndpoints;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildRouteConfiguration;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildSecureCluster;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildUpstreamTlsContext;
|
||||
import static io.grpc.xds.XdsClientTestHelper.buildVirtualHost;
|
||||
import static org.mockito.AdditionalAnswers.delegatesTo;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
|
|
@ -33,41 +45,22 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.UInt32Value;
|
||||
import io.envoyproxy.envoy.api.v2.Cluster;
|
||||
import io.envoyproxy.envoy.api.v2.Cluster.DiscoveryType;
|
||||
import io.envoyproxy.envoy.api.v2.Cluster.EdsClusterConfig;
|
||||
import io.envoyproxy.envoy.api.v2.Cluster.LbPolicy;
|
||||
import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment;
|
||||
import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment.Policy;
|
||||
import io.envoyproxy.envoy.api.v2.DiscoveryRequest;
|
||||
import io.envoyproxy.envoy.api.v2.DiscoveryResponse;
|
||||
import io.envoyproxy.envoy.api.v2.Listener;
|
||||
import io.envoyproxy.envoy.api.v2.RouteConfiguration;
|
||||
import io.envoyproxy.envoy.api.v2.auth.CommonTlsContext;
|
||||
import io.envoyproxy.envoy.api.v2.auth.SdsSecretConfig;
|
||||
import io.envoyproxy.envoy.api.v2.auth.UpstreamTlsContext;
|
||||
import io.envoyproxy.envoy.api.v2.core.Address;
|
||||
import io.envoyproxy.envoy.api.v2.core.AggregatedConfigSource;
|
||||
import io.envoyproxy.envoy.api.v2.core.ApiConfigSource;
|
||||
import io.envoyproxy.envoy.api.v2.core.ConfigSource;
|
||||
import io.envoyproxy.envoy.api.v2.core.GrpcService;
|
||||
import io.envoyproxy.envoy.api.v2.core.GrpcService.GoogleGrpc;
|
||||
import io.envoyproxy.envoy.api.v2.core.HealthStatus;
|
||||
import io.envoyproxy.envoy.api.v2.core.Node;
|
||||
import io.envoyproxy.envoy.api.v2.core.SelfConfigSource;
|
||||
import io.envoyproxy.envoy.api.v2.core.SocketAddress;
|
||||
import io.envoyproxy.envoy.api.v2.listener.FilterChain;
|
||||
import io.envoyproxy.envoy.api.v2.route.RedirectAction;
|
||||
import io.envoyproxy.envoy.api.v2.route.Route;
|
||||
import io.envoyproxy.envoy.api.v2.route.RouteAction;
|
||||
import io.envoyproxy.envoy.api.v2.route.VirtualHost;
|
||||
import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager;
|
||||
import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.Rds;
|
||||
import io.envoyproxy.envoy.config.listener.v2.ApiListener;
|
||||
import io.envoyproxy.envoy.service.discovery.v2.AggregatedDiscoveryServiceGrpc.AggregatedDiscoveryServiceImplBase;
|
||||
import io.envoyproxy.envoy.type.FractionalPercent;
|
||||
import io.envoyproxy.envoy.type.FractionalPercent.DenominatorType;
|
||||
import io.grpc.Context;
|
||||
import io.grpc.Context.CancellationListener;
|
||||
import io.grpc.ManagedChannel;
|
||||
|
|
@ -100,7 +93,6 @@ import java.util.List;
|
|||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.annotation.Nullable;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
|
@ -256,7 +248,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
List<Any> listeners = ImmutableList.of(
|
||||
|
|
@ -284,7 +276,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0000")));
|
||||
|
||||
ArgumentCaptor<Status> errorStatusCaptor = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -312,7 +304,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
RouteConfiguration routeConfig =
|
||||
|
|
@ -356,7 +348,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
List<Any> listeners = ImmutableList.of(
|
||||
|
|
@ -397,7 +389,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0000")));
|
||||
|
||||
ArgumentCaptor<ConfigUpdate> configUpdateCaptor = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -422,7 +414,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
Rds rdsConfig =
|
||||
|
|
@ -442,12 +434,12 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0000")));
|
||||
|
||||
// Client sends an (first) RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "")));
|
||||
|
||||
// Management server should only sends RouteConfiguration messages with at least one
|
||||
|
|
@ -470,7 +462,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0000")));
|
||||
|
||||
verify(configWatcher, never()).onConfigChanged(any(ConfigUpdate.class));
|
||||
|
|
@ -528,7 +520,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0000")));
|
||||
|
||||
ArgumentCaptor<ConfigUpdate> configUpdateCaptor = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -672,7 +664,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management server sends back an LDS response containing a RouteConfiguration for the
|
||||
|
|
@ -696,7 +688,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0000")));
|
||||
|
||||
// Cluster name is resolved and notified to config watcher.
|
||||
|
|
@ -724,7 +716,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0001")));
|
||||
|
||||
// Updated cluster name is notified to config watcher.
|
||||
|
|
@ -753,12 +745,12 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("2", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "2", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0002")));
|
||||
|
||||
// Client sends an (first) RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "some-route-to-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "some-route-to-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "")));
|
||||
|
||||
// Management server sends back an RDS response containing the RouteConfiguration
|
||||
|
|
@ -777,7 +769,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "some-route-to-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "some-route-to-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0000")));
|
||||
|
||||
// Updated cluster name is notified to config watcher again.
|
||||
|
|
@ -800,7 +792,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "some-route-to-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "some-route-to-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0001")));
|
||||
|
||||
// Updated cluster name is notified to config watcher again.
|
||||
|
|
@ -828,7 +820,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management sends back an LDS response telling client to do RDS.
|
||||
|
|
@ -850,12 +842,12 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0000")));
|
||||
|
||||
// Client sends an (first) RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "")));
|
||||
|
||||
// Management server sends back an RDS response that does not contain RouteConfiguration
|
||||
|
|
@ -872,7 +864,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0000")));
|
||||
|
||||
// Client waits for future RDS responses silently.
|
||||
|
|
@ -894,7 +886,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0001")));
|
||||
|
||||
// Updated cluster name is notified to config watcher.
|
||||
|
|
@ -923,7 +915,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management sends back an LDS response telling client to do RDS.
|
||||
|
|
@ -945,12 +937,12 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0000")));
|
||||
|
||||
// Client sends an (first) RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "route-foo1.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "route-foo1.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "")));
|
||||
|
||||
// Management server sends back an RDS response containing RouteConfigurations
|
||||
|
|
@ -981,7 +973,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "route-foo1.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "route-foo1.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0000")));
|
||||
|
||||
// Resolved cluster name is notified to config watcher.
|
||||
|
|
@ -1009,7 +1001,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0001")));
|
||||
|
||||
// Updated cluster name is notified to config watcher.
|
||||
|
|
@ -1020,7 +1012,7 @@ public class XdsClientImplTest {
|
|||
// At this time, no RDS request is sent as the result can be found in local cache (even if
|
||||
// a request is sent for it, management server does not necessarily reply).
|
||||
verify(requestObserver, times(0))
|
||||
.onNext(eq(buildDiscoveryRequest("0", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0000")));
|
||||
|
||||
verifyNoMoreInteractions(requestObserver);
|
||||
|
|
@ -1040,7 +1032,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "route-foo2.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "route-foo2.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0001")));
|
||||
|
||||
// Updated cluster name is notified to config watcher.
|
||||
|
|
@ -1062,7 +1054,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management sends back an LDS response telling client to do RDS.
|
||||
|
|
@ -1084,12 +1076,12 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0000")));
|
||||
|
||||
// Client sends an (first) RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "")));
|
||||
|
||||
// Management server sends back an RDS response containing RouteConfiguration requested.
|
||||
|
|
@ -1105,7 +1097,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK RDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "0000")));
|
||||
|
||||
// Resolved cluster name is notified to config watcher.
|
||||
|
|
@ -1122,7 +1114,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0001")));
|
||||
|
||||
// Notify config watcher with an error.
|
||||
|
|
@ -1147,7 +1139,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends a CDS request for the only cluster being watched to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
|
||||
// Management server sends back a CDS response without Cluster for the requested resource.
|
||||
|
|
@ -1160,7 +1152,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK CDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0000")));
|
||||
|
||||
ArgumentCaptor<Status> errorStatusCaptor = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -1183,7 +1175,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends a CDS request for the only cluster being watched to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
|
||||
// Management server sends back a CDS response without Cluster for the requested resource.
|
||||
|
|
@ -1197,7 +1189,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK CDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0000")));
|
||||
|
||||
ArgumentCaptor<ClusterUpdate> clusterUpdateCaptor = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -1221,7 +1213,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK CDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0001")));
|
||||
|
||||
verify(clusterWatcher, times(2)).onClusterChanged(clusterUpdateCaptor.capture());
|
||||
|
|
@ -1257,7 +1249,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK CDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0000")));
|
||||
ArgumentCaptor<ClusterUpdate> clusterUpdateCaptor = ArgumentCaptor.forClass(null);
|
||||
verify(clusterWatcher, times(1)).onClusterChanged(clusterUpdateCaptor.capture());
|
||||
|
|
@ -1396,7 +1388,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an CDS request to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
|
||||
// Management server sends back an CDS response with Cluster for the requested
|
||||
|
|
@ -1409,7 +1401,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK CDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0000")));
|
||||
|
||||
ArgumentCaptor<ClusterUpdate> clusterUpdateCaptor1 = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -1450,7 +1442,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an CDS request to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
|
||||
// Management server sends back a CDS response with Cluster for the requested
|
||||
|
|
@ -1463,7 +1455,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK CDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0000")));
|
||||
|
||||
ArgumentCaptor<ClusterUpdate> clusterUpdateCaptor1 = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -1482,7 +1474,7 @@ public class XdsClientImplTest {
|
|||
// Client sent a new CDS request for all interested resources.
|
||||
verify(requestObserver)
|
||||
.onNext(
|
||||
eq(buildDiscoveryRequest("0",
|
||||
eq(buildDiscoveryRequest(NODE, "0",
|
||||
ImmutableList.of("cluster-foo.googleapis.com", "cluster-bar.googleapis.com"),
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0000")));
|
||||
|
||||
|
|
@ -1529,7 +1521,7 @@ public class XdsClientImplTest {
|
|||
// is still interested resource), client sent an new CDS request to unsubscribe from
|
||||
// that cluster.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "cluster-bar.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "cluster-bar.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0001")));
|
||||
|
||||
// Management server has nothing to respond.
|
||||
|
|
@ -1568,7 +1560,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// A CDS request is sent to indicate subscription of "cluster-foo.googleapis.com" only.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("2", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "2", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0002")));
|
||||
|
||||
// Management server sends back a new CDS response for at least newly requested resources
|
||||
|
|
@ -1596,7 +1588,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// A CDS request is sent to re-subscribe the cluster again.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("3", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "3", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "0003")));
|
||||
}
|
||||
|
||||
|
|
@ -1615,7 +1607,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an EDS request for the only cluster being watched to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server sends back an EDS response without ClusterLoadAssignment for the requested
|
||||
|
|
@ -1643,7 +1635,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK EDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "0000")));
|
||||
|
||||
verifyZeroInteractions(endpointWatcher);
|
||||
|
|
@ -1661,7 +1653,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an EDS request for the only cluster being watched to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server sends back an EDS response with ClusterLoadAssignment for the requested
|
||||
|
|
@ -1695,7 +1687,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK EDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "0000")));
|
||||
|
||||
ArgumentCaptor<EndpointUpdate> endpointUpdateCaptor = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -1842,7 +1834,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends first EDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server sends back an EDS response containing ClusterLoadAssignments for
|
||||
|
|
@ -1863,7 +1855,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK EDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "0000")));
|
||||
|
||||
ArgumentCaptor<EndpointUpdate> endpointUpdateCaptor1 = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -1912,7 +1904,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an EDS request to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server sends back an EDS response with ClusterLoadAssignment for the requested
|
||||
|
|
@ -1934,7 +1926,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent an ACK EDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "cluster-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "cluster-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "0000")));
|
||||
|
||||
ArgumentCaptor<EndpointUpdate> endpointUpdateCaptor1 = ArgumentCaptor.forClass(null);
|
||||
|
|
@ -2003,7 +1995,7 @@ public class XdsClientImplTest {
|
|||
// Since the cancelled watcher was the last watcher interested in that cluster, client
|
||||
// sent an new EDS request to unsubscribe from that cluster.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("1", "cluster-bar.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "1", "cluster-bar.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "0001")));
|
||||
|
||||
// Management server should not respond as it had previously sent the requested resource.
|
||||
|
|
@ -2065,7 +2057,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// An EDS request is sent to re-subscribe the cluster again.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("2", "cluster-bar.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "2", "cluster-bar.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "0002")));
|
||||
|
||||
// Management server sends back an EDS response for re-subscribed resource.
|
||||
|
|
@ -2124,7 +2116,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sends an LDS request for the host name (with port) to management server.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management server closes the RPC stream immediately.
|
||||
|
|
@ -2144,7 +2136,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client retried by sending an LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management server closes the RPC stream with an error.
|
||||
|
|
@ -2164,7 +2156,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client retried again by sending an LDS.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management server responses with a listener for the requested resource.
|
||||
|
|
@ -2185,12 +2177,12 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent back an ACK LDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("0", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "0", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "0000")));
|
||||
|
||||
// Client sent an RDS request based on the received listener.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "route-foo.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "route-foo.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_RDS, "")));
|
||||
|
||||
// Management server encounters an error and closes the stream.
|
||||
|
|
@ -2204,7 +2196,7 @@ public class XdsClientImplTest {
|
|||
responseObserver = responseObserverCaptor.getValue();
|
||||
requestObserver = requestObservers.poll();
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// RPC stream closed immediately
|
||||
|
|
@ -2221,7 +2213,7 @@ public class XdsClientImplTest {
|
|||
responseObserver = responseObserverCaptor.getValue();
|
||||
requestObserver = requestObservers.poll();
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management server sends an LDS response.
|
||||
|
|
@ -2254,7 +2246,7 @@ public class XdsClientImplTest {
|
|||
fakeClock.runDueTasks();
|
||||
requestObserver = requestObservers.poll();
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
verifyNoMoreInteractions(backoffPolicyProvider, backoffPolicy1, backoffPolicy2);
|
||||
|
|
@ -2285,7 +2277,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent first CDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
|
||||
// Start watching endpoint information.
|
||||
|
|
@ -2293,7 +2285,7 @@ public class XdsClientImplTest {
|
|||
|
||||
// Client sent first EDS request.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server closes the RPC stream with an error.
|
||||
|
|
@ -2309,13 +2301,13 @@ public class XdsClientImplTest {
|
|||
|
||||
// Retry resumes requests for all wanted resources.
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server becomes unreachable.
|
||||
|
|
@ -2332,13 +2324,13 @@ public class XdsClientImplTest {
|
|||
responseObserver = responseObserverCaptor.getValue();
|
||||
requestObserver = requestObservers.poll();
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server is still not reachable.
|
||||
|
|
@ -2355,13 +2347,13 @@ public class XdsClientImplTest {
|
|||
responseObserver = responseObserverCaptor.getValue();
|
||||
requestObserver = requestObservers.poll();
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server sends back a CDS response.
|
||||
|
|
@ -2385,13 +2377,13 @@ public class XdsClientImplTest {
|
|||
requestObserver = requestObservers.poll();
|
||||
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server becomes unreachable again.
|
||||
|
|
@ -2407,13 +2399,13 @@ public class XdsClientImplTest {
|
|||
.streamAggregatedResources(responseObserverCaptor.capture());
|
||||
requestObserver = requestObservers.poll();
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
verifyNoMoreInteractions(mockedDiscoveryService, backoffPolicyProvider, backoffPolicy1,
|
||||
|
|
@ -2452,7 +2444,7 @@ public class XdsClientImplTest {
|
|||
StreamObserver<DiscoveryRequest> requestObserver = requestObservers.poll();
|
||||
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
|
||||
// Management server becomes unreachable.
|
||||
|
|
@ -2473,10 +2465,10 @@ public class XdsClientImplTest {
|
|||
requestObserver = requestObservers.poll();
|
||||
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
|
||||
// Management server is still unreachable.
|
||||
|
|
@ -2497,13 +2489,13 @@ public class XdsClientImplTest {
|
|||
requestObserver = requestObservers.poll();
|
||||
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server sends back a CDS response.
|
||||
|
|
@ -2526,13 +2518,13 @@ public class XdsClientImplTest {
|
|||
responseObserver = responseObserverCaptor.getValue();
|
||||
requestObserver = requestObservers.poll();
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
// Management server becomes unreachable again.
|
||||
|
|
@ -2553,13 +2545,13 @@ public class XdsClientImplTest {
|
|||
requestObserver = requestObservers.poll();
|
||||
|
||||
verify(requestObserver)
|
||||
.onNext(eq(buildDiscoveryRequest("", "foo.googleapis.com:8080",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "foo.googleapis.com:8080",
|
||||
XdsClientImpl.ADS_TYPE_URL_LDS, "")));
|
||||
verify(requestObserver, never())
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||
verify(requestObserver, never())
|
||||
.onNext(eq(buildDiscoveryRequest("", "cluster.googleapis.com",
|
||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||
|
||||
verifyNoMoreInteractions(mockedDiscoveryService, backoffPolicyProvider, backoffPolicy1,
|
||||
|
|
@ -2645,170 +2637,7 @@ public class XdsClientImplTest {
|
|||
assertThat(XdsClientImpl.matchHostName("foo-bar", pattern)).isTrue();
|
||||
}
|
||||
|
||||
private static DiscoveryResponse buildDiscoveryResponse(String versionInfo,
|
||||
List<com.google.protobuf.Any> resources, String typeUrl, String nonce) {
|
||||
return
|
||||
DiscoveryResponse.newBuilder()
|
||||
.setVersionInfo(versionInfo)
|
||||
.setTypeUrl(typeUrl)
|
||||
.addAllResources(resources)
|
||||
.setNonce(nonce)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static DiscoveryRequest buildDiscoveryRequest(String versionInfo,
|
||||
String resourceName, String typeUrl, String nonce) {
|
||||
return buildDiscoveryRequest(versionInfo, ImmutableList.of(resourceName), typeUrl, nonce);
|
||||
}
|
||||
|
||||
private static DiscoveryRequest buildDiscoveryRequest(String versionInfo,
|
||||
List<String> resourceNames, String typeUrl, String nonce) {
|
||||
return
|
||||
DiscoveryRequest.newBuilder()
|
||||
.setVersionInfo(versionInfo)
|
||||
.setNode(NODE)
|
||||
.setTypeUrl(typeUrl)
|
||||
.addAllResourceNames(resourceNames)
|
||||
.setResponseNonce(nonce)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Listener buildListener(String name, com.google.protobuf.Any apiListener) {
|
||||
return
|
||||
Listener.newBuilder()
|
||||
.setName(name)
|
||||
.setAddress(Address.getDefaultInstance())
|
||||
.addFilterChains(FilterChain.getDefaultInstance())
|
||||
.setApiListener(ApiListener.newBuilder().setApiListener(apiListener))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static RouteConfiguration buildRouteConfiguration(String name,
|
||||
List<VirtualHost> virtualHosts) {
|
||||
return
|
||||
RouteConfiguration.newBuilder()
|
||||
.setName(name)
|
||||
.addAllVirtualHosts(virtualHosts)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static VirtualHost buildVirtualHost(List<String> domains, String clusterName) {
|
||||
return
|
||||
VirtualHost.newBuilder()
|
||||
.setName("virtualhost00.googleapis.com") // don't care
|
||||
.addAllDomains(domains)
|
||||
.addRoutes(Route.newBuilder()
|
||||
.setRoute(RouteAction.newBuilder().setCluster("whatever cluster")))
|
||||
.addRoutes(
|
||||
// Only the last (default) route matters.
|
||||
Route.newBuilder()
|
||||
.setRoute(RouteAction.newBuilder().setCluster(clusterName)))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Cluster buildCluster(String clusterName, @Nullable String edsServiceName,
|
||||
boolean enableLrs) {
|
||||
return buildSecureCluster(clusterName, edsServiceName, enableLrs, null);
|
||||
}
|
||||
|
||||
private static Cluster buildSecureCluster(String clusterName, @Nullable String edsServiceName,
|
||||
boolean enableLrs, @Nullable UpstreamTlsContext upstreamTlsContext) {
|
||||
Cluster.Builder clusterBuilder = Cluster.newBuilder();
|
||||
clusterBuilder.setName(clusterName);
|
||||
clusterBuilder.setType(DiscoveryType.EDS);
|
||||
EdsClusterConfig.Builder edsClusterConfigBuilder = EdsClusterConfig.newBuilder();
|
||||
edsClusterConfigBuilder.setEdsConfig(
|
||||
ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance()));
|
||||
if (edsServiceName != null) {
|
||||
edsClusterConfigBuilder.setServiceName(edsServiceName);
|
||||
}
|
||||
clusterBuilder.setEdsClusterConfig(edsClusterConfigBuilder);
|
||||
clusterBuilder.setLbPolicy(LbPolicy.ROUND_ROBIN);
|
||||
if (enableLrs) {
|
||||
clusterBuilder.setLrsServer(
|
||||
ConfigSource.newBuilder().setSelf(SelfConfigSource.getDefaultInstance()));
|
||||
}
|
||||
if (upstreamTlsContext != null) {
|
||||
clusterBuilder.setTlsContext(upstreamTlsContext);
|
||||
}
|
||||
return clusterBuilder.build();
|
||||
}
|
||||
|
||||
private static ClusterLoadAssignment buildClusterLoadAssignment(String clusterName,
|
||||
List<io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints> localityLbEndpoints,
|
||||
List<Policy.DropOverload> dropOverloads) {
|
||||
return
|
||||
ClusterLoadAssignment.newBuilder()
|
||||
.setClusterName(clusterName)
|
||||
.addAllEndpoints(localityLbEndpoints)
|
||||
.setPolicy(
|
||||
Policy.newBuilder()
|
||||
.setDisableOverprovisioning(true)
|
||||
.addAllDropOverloads(dropOverloads))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Policy.DropOverload buildDropOverload(String category, int dropPerMillion) {
|
||||
return
|
||||
Policy.DropOverload.newBuilder()
|
||||
.setCategory(category)
|
||||
.setDropPercentage(
|
||||
FractionalPercent.newBuilder()
|
||||
.setNumerator(dropPerMillion)
|
||||
.setDenominator(DenominatorType.MILLION))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints buildLocalityLbEndpoints(
|
||||
String region, String zone, String subzone,
|
||||
List<io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint> lbEndpoints,
|
||||
int loadBalancingWeight, int priority) {
|
||||
return
|
||||
io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints.newBuilder()
|
||||
.setLocality(
|
||||
io.envoyproxy.envoy.api.v2.core.Locality.newBuilder()
|
||||
.setRegion(region)
|
||||
.setZone(zone)
|
||||
.setSubZone(subzone))
|
||||
.addAllLbEndpoints(lbEndpoints)
|
||||
.setLoadBalancingWeight(UInt32Value.newBuilder().setValue(loadBalancingWeight))
|
||||
.setPriority(priority)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint buildLbEndpoint(String address,
|
||||
int port, HealthStatus healthStatus, int loadbalancingWeight) {
|
||||
return
|
||||
io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint.newBuilder()
|
||||
.setEndpoint(
|
||||
io.envoyproxy.envoy.api.v2.endpoint.Endpoint.newBuilder().setAddress(
|
||||
Address.newBuilder().setSocketAddress(
|
||||
SocketAddress.newBuilder().setAddress(address).setPortValue(port))))
|
||||
.setHealthStatus(healthStatus).setLoadBalancingWeight(
|
||||
UInt32Value.newBuilder().setValue(loadbalancingWeight))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static UpstreamTlsContext buildUpstreamTlsContext(String secretName, String targetUri) {
|
||||
GrpcService grpcService =
|
||||
GrpcService.newBuilder()
|
||||
.setGoogleGrpc(GoogleGrpc.newBuilder().setTargetUri(targetUri))
|
||||
.build();
|
||||
ConfigSource sdsConfig =
|
||||
ConfigSource.newBuilder()
|
||||
.setApiConfigSource(ApiConfigSource.newBuilder().addGrpcServices(grpcService))
|
||||
.build();
|
||||
SdsSecretConfig validationContextSdsSecretConfig =
|
||||
SdsSecretConfig.newBuilder()
|
||||
.setName(secretName)
|
||||
.setSdsConfig(sdsConfig)
|
||||
.build();
|
||||
return UpstreamTlsContext.newBuilder()
|
||||
.setCommonTlsContext(
|
||||
CommonTlsContext.newBuilder()
|
||||
.setValidationContextSdsSecretConfig(validationContextSdsSecretConfig))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Matcher for DiscoveryRequest without the comparison of error_details field, which is used for
|
||||
|
|
|
|||
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
* Copyright 2019 The gRPC Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.grpc.xds;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.UInt32Value;
|
||||
import io.envoyproxy.envoy.api.v2.Cluster;
|
||||
import io.envoyproxy.envoy.api.v2.Cluster.DiscoveryType;
|
||||
import io.envoyproxy.envoy.api.v2.Cluster.EdsClusterConfig;
|
||||
import io.envoyproxy.envoy.api.v2.Cluster.LbPolicy;
|
||||
import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment;
|
||||
import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment.Policy;
|
||||
import io.envoyproxy.envoy.api.v2.DiscoveryRequest;
|
||||
import io.envoyproxy.envoy.api.v2.DiscoveryResponse;
|
||||
import io.envoyproxy.envoy.api.v2.Listener;
|
||||
import io.envoyproxy.envoy.api.v2.RouteConfiguration;
|
||||
import io.envoyproxy.envoy.api.v2.auth.CommonTlsContext;
|
||||
import io.envoyproxy.envoy.api.v2.auth.SdsSecretConfig;
|
||||
import io.envoyproxy.envoy.api.v2.auth.UpstreamTlsContext;
|
||||
import io.envoyproxy.envoy.api.v2.core.Address;
|
||||
import io.envoyproxy.envoy.api.v2.core.AggregatedConfigSource;
|
||||
import io.envoyproxy.envoy.api.v2.core.ApiConfigSource;
|
||||
import io.envoyproxy.envoy.api.v2.core.ConfigSource;
|
||||
import io.envoyproxy.envoy.api.v2.core.GrpcService;
|
||||
import io.envoyproxy.envoy.api.v2.core.GrpcService.GoogleGrpc;
|
||||
import io.envoyproxy.envoy.api.v2.core.HealthStatus;
|
||||
import io.envoyproxy.envoy.api.v2.core.Node;
|
||||
import io.envoyproxy.envoy.api.v2.core.SelfConfigSource;
|
||||
import io.envoyproxy.envoy.api.v2.core.SocketAddress;
|
||||
import io.envoyproxy.envoy.api.v2.listener.FilterChain;
|
||||
import io.envoyproxy.envoy.api.v2.route.Route;
|
||||
import io.envoyproxy.envoy.api.v2.route.RouteAction;
|
||||
import io.envoyproxy.envoy.api.v2.route.VirtualHost;
|
||||
import io.envoyproxy.envoy.config.listener.v2.ApiListener;
|
||||
import io.envoyproxy.envoy.type.FractionalPercent;
|
||||
import io.envoyproxy.envoy.type.FractionalPercent.DenominatorType;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Helper methods for building protobuf messages with custom data for xDS protocols.
|
||||
*/
|
||||
class XdsClientTestHelper {
|
||||
static DiscoveryResponse buildDiscoveryResponse(String versionInfo,
|
||||
List<Any> resources, String typeUrl, String nonce) {
|
||||
return
|
||||
DiscoveryResponse.newBuilder()
|
||||
.setVersionInfo(versionInfo)
|
||||
.setTypeUrl(typeUrl)
|
||||
.addAllResources(resources)
|
||||
.setNonce(nonce)
|
||||
.build();
|
||||
}
|
||||
|
||||
static DiscoveryRequest buildDiscoveryRequest(Node node, String versionInfo,
|
||||
String resourceName, String typeUrl, String nonce) {
|
||||
return buildDiscoveryRequest(node, versionInfo, ImmutableList.of(resourceName), typeUrl, nonce);
|
||||
}
|
||||
|
||||
static DiscoveryRequest buildDiscoveryRequest(Node node, String versionInfo,
|
||||
List<String> resourceNames, String typeUrl, String nonce) {
|
||||
return
|
||||
DiscoveryRequest.newBuilder()
|
||||
.setVersionInfo(versionInfo)
|
||||
.setNode(node)
|
||||
.setTypeUrl(typeUrl)
|
||||
.addAllResourceNames(resourceNames)
|
||||
.setResponseNonce(nonce)
|
||||
.build();
|
||||
}
|
||||
|
||||
static Listener buildListener(String name, com.google.protobuf.Any apiListener) {
|
||||
return
|
||||
Listener.newBuilder()
|
||||
.setName(name)
|
||||
.setAddress(Address.getDefaultInstance())
|
||||
.addFilterChains(FilterChain.getDefaultInstance())
|
||||
.setApiListener(ApiListener.newBuilder().setApiListener(apiListener))
|
||||
.build();
|
||||
}
|
||||
|
||||
static RouteConfiguration buildRouteConfiguration(String name,
|
||||
List<VirtualHost> virtualHosts) {
|
||||
return
|
||||
RouteConfiguration.newBuilder()
|
||||
.setName(name)
|
||||
.addAllVirtualHosts(virtualHosts)
|
||||
.build();
|
||||
}
|
||||
|
||||
static VirtualHost buildVirtualHost(List<String> domains, String clusterName) {
|
||||
return
|
||||
VirtualHost.newBuilder()
|
||||
.setName("virtualhost00.googleapis.com") // don't care
|
||||
.addAllDomains(domains)
|
||||
.addRoutes(Route.newBuilder()
|
||||
.setRoute(RouteAction.newBuilder().setCluster("whatever cluster")))
|
||||
.addRoutes(
|
||||
// Only the last (default) route matters.
|
||||
Route.newBuilder()
|
||||
.setRoute(RouteAction.newBuilder().setCluster(clusterName)))
|
||||
.build();
|
||||
}
|
||||
|
||||
static Cluster buildCluster(String clusterName, @Nullable String edsServiceName,
|
||||
boolean enableLrs) {
|
||||
return buildSecureCluster(clusterName, edsServiceName, enableLrs, null);
|
||||
}
|
||||
|
||||
static Cluster buildSecureCluster(String clusterName, @Nullable String edsServiceName,
|
||||
boolean enableLrs, @Nullable UpstreamTlsContext upstreamTlsContext) {
|
||||
Cluster.Builder clusterBuilder = Cluster.newBuilder();
|
||||
clusterBuilder.setName(clusterName);
|
||||
clusterBuilder.setType(DiscoveryType.EDS);
|
||||
EdsClusterConfig.Builder edsClusterConfigBuilder = EdsClusterConfig.newBuilder();
|
||||
edsClusterConfigBuilder.setEdsConfig(
|
||||
ConfigSource.newBuilder().setAds(AggregatedConfigSource.getDefaultInstance()));
|
||||
if (edsServiceName != null) {
|
||||
edsClusterConfigBuilder.setServiceName(edsServiceName);
|
||||
}
|
||||
clusterBuilder.setEdsClusterConfig(edsClusterConfigBuilder);
|
||||
clusterBuilder.setLbPolicy(LbPolicy.ROUND_ROBIN);
|
||||
if (enableLrs) {
|
||||
clusterBuilder.setLrsServer(
|
||||
ConfigSource.newBuilder().setSelf(SelfConfigSource.getDefaultInstance()));
|
||||
}
|
||||
if (upstreamTlsContext != null) {
|
||||
clusterBuilder.setTlsContext(upstreamTlsContext);
|
||||
}
|
||||
return clusterBuilder.build();
|
||||
}
|
||||
|
||||
static ClusterLoadAssignment buildClusterLoadAssignment(String clusterName,
|
||||
List<io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints> localityLbEndpoints,
|
||||
List<Policy.DropOverload> dropOverloads) {
|
||||
return
|
||||
ClusterLoadAssignment.newBuilder()
|
||||
.setClusterName(clusterName)
|
||||
.addAllEndpoints(localityLbEndpoints)
|
||||
.setPolicy(
|
||||
Policy.newBuilder()
|
||||
.setDisableOverprovisioning(true)
|
||||
.addAllDropOverloads(dropOverloads))
|
||||
.build();
|
||||
}
|
||||
|
||||
static Policy.DropOverload buildDropOverload(String category, int dropPerMillion) {
|
||||
return
|
||||
Policy.DropOverload.newBuilder()
|
||||
.setCategory(category)
|
||||
.setDropPercentage(
|
||||
FractionalPercent.newBuilder()
|
||||
.setNumerator(dropPerMillion)
|
||||
.setDenominator(DenominatorType.MILLION))
|
||||
.build();
|
||||
}
|
||||
|
||||
static io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints buildLocalityLbEndpoints(
|
||||
String region, String zone, String subzone,
|
||||
List<io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint> lbEndpoints,
|
||||
int loadBalancingWeight, int priority) {
|
||||
return
|
||||
io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints.newBuilder()
|
||||
.setLocality(
|
||||
io.envoyproxy.envoy.api.v2.core.Locality.newBuilder()
|
||||
.setRegion(region)
|
||||
.setZone(zone)
|
||||
.setSubZone(subzone))
|
||||
.addAllLbEndpoints(lbEndpoints)
|
||||
.setLoadBalancingWeight(UInt32Value.newBuilder().setValue(loadBalancingWeight))
|
||||
.setPriority(priority)
|
||||
.build();
|
||||
}
|
||||
|
||||
static io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint buildLbEndpoint(String address,
|
||||
int port, HealthStatus healthStatus, int loadbalancingWeight) {
|
||||
return
|
||||
io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint.newBuilder()
|
||||
.setEndpoint(
|
||||
io.envoyproxy.envoy.api.v2.endpoint.Endpoint.newBuilder().setAddress(
|
||||
Address.newBuilder().setSocketAddress(
|
||||
SocketAddress.newBuilder().setAddress(address).setPortValue(port))))
|
||||
.setHealthStatus(healthStatus).setLoadBalancingWeight(
|
||||
UInt32Value.newBuilder().setValue(loadbalancingWeight))
|
||||
.build();
|
||||
}
|
||||
|
||||
static UpstreamTlsContext buildUpstreamTlsContext(String secretName, String targetUri) {
|
||||
GrpcService grpcService =
|
||||
GrpcService.newBuilder()
|
||||
.setGoogleGrpc(GoogleGrpc.newBuilder().setTargetUri(targetUri))
|
||||
.build();
|
||||
ConfigSource sdsConfig =
|
||||
ConfigSource.newBuilder()
|
||||
.setApiConfigSource(ApiConfigSource.newBuilder().addGrpcServices(grpcService))
|
||||
.build();
|
||||
SdsSecretConfig validationContextSdsSecretConfig =
|
||||
SdsSecretConfig.newBuilder()
|
||||
.setName(secretName)
|
||||
.setSdsConfig(sdsConfig)
|
||||
.build();
|
||||
return UpstreamTlsContext.newBuilder()
|
||||
.setCommonTlsContext(
|
||||
CommonTlsContext.newBuilder()
|
||||
.setValidationContextSdsSecretConfig(validationContextSdsSecretConfig))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue