mirror of https://github.com/grpc/grpc-java.git
xds: Add test that uses real DnsNR with ClusterResolverLB
This can detect failures like the UnsupportedOperationException from
ebffb0a6
.
This commit is contained in:
parent
cc1cbe9871
commit
9bc1a93f6e
|
@ -24,10 +24,17 @@ import com.github.xds.type.v3.TypedStruct;
|
|||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.Struct;
|
||||
import com.google.protobuf.Value;
|
||||
import io.envoyproxy.envoy.config.cluster.v3.Cluster;
|
||||
import io.envoyproxy.envoy.config.cluster.v3.Cluster.LbPolicy;
|
||||
import io.envoyproxy.envoy.config.cluster.v3.LoadBalancingPolicy;
|
||||
import io.envoyproxy.envoy.config.cluster.v3.LoadBalancingPolicy.Policy;
|
||||
import io.envoyproxy.envoy.config.core.v3.Address;
|
||||
import io.envoyproxy.envoy.config.core.v3.SocketAddress;
|
||||
import io.envoyproxy.envoy.config.core.v3.TypedExtensionConfig;
|
||||
import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment;
|
||||
import io.envoyproxy.envoy.config.endpoint.v3.Endpoint;
|
||||
import io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint;
|
||||
import io.envoyproxy.envoy.config.endpoint.v3.LocalityLbEndpoints;
|
||||
import io.envoyproxy.envoy.extensions.load_balancing_policies.wrr_locality.v3.WrrLocality;
|
||||
import io.grpc.CallOptions;
|
||||
import io.grpc.Channel;
|
||||
|
@ -42,6 +49,7 @@ import io.grpc.MethodDescriptor;
|
|||
import io.grpc.testing.protobuf.SimpleRequest;
|
||||
import io.grpc.testing.protobuf.SimpleResponse;
|
||||
import io.grpc.testing.protobuf.SimpleServiceGrpc;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -179,4 +187,34 @@ public class FakeControlPlaneXdsIntegrationTest {
|
|||
.build();
|
||||
assertEquals(goldenResponse, blockingStub.unaryRpc(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pingPong_logicalDns() {
|
||||
InetSocketAddress serverAddress =
|
||||
(InetSocketAddress) dataPlane.getServer().getListenSockets().get(0);
|
||||
controlPlane.setCdsConfig(
|
||||
ControlPlaneRule.buildCluster().toBuilder()
|
||||
.setType(Cluster.DiscoveryType.LOGICAL_DNS)
|
||||
.setLoadAssignment(
|
||||
ClusterLoadAssignment.newBuilder().addEndpoints(
|
||||
LocalityLbEndpoints.newBuilder().addLbEndpoints(
|
||||
LbEndpoint.newBuilder().setEndpoint(
|
||||
Endpoint.newBuilder().setAddress(
|
||||
Address.newBuilder().setSocketAddress(
|
||||
SocketAddress.newBuilder()
|
||||
.setAddress("localhost")
|
||||
.setPortValue(serverAddress.getPort()))))))
|
||||
.build())
|
||||
.build());
|
||||
|
||||
ManagedChannel channel = dataPlane.getManagedChannel();
|
||||
SimpleServiceGrpc.SimpleServiceBlockingStub blockingStub = SimpleServiceGrpc.newBlockingStub(
|
||||
channel);
|
||||
SimpleRequest request = SimpleRequest.newBuilder()
|
||||
.build();
|
||||
SimpleResponse goldenResponse = SimpleResponse.newBuilder()
|
||||
.setResponseMessage("Hi, xDS!")
|
||||
.build();
|
||||
assertEquals(goldenResponse, blockingStub.unaryRpc(request));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue