|
24 | 24 | import com.google.protobuf.Any; |
25 | 25 | import com.google.protobuf.Struct; |
26 | 26 | import com.google.protobuf.Value; |
| 27 | +import io.envoyproxy.envoy.config.cluster.v3.Cluster; |
27 | 28 | import io.envoyproxy.envoy.config.cluster.v3.Cluster.LbPolicy; |
28 | 29 | import io.envoyproxy.envoy.config.cluster.v3.LoadBalancingPolicy; |
29 | 30 | import io.envoyproxy.envoy.config.cluster.v3.LoadBalancingPolicy.Policy; |
| 31 | +import io.envoyproxy.envoy.config.core.v3.Address; |
| 32 | +import io.envoyproxy.envoy.config.core.v3.SocketAddress; |
30 | 33 | import io.envoyproxy.envoy.config.core.v3.TypedExtensionConfig; |
| 34 | +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment; |
| 35 | +import io.envoyproxy.envoy.config.endpoint.v3.Endpoint; |
| 36 | +import io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint; |
| 37 | +import io.envoyproxy.envoy.config.endpoint.v3.LocalityLbEndpoints; |
31 | 38 | import io.envoyproxy.envoy.extensions.load_balancing_policies.wrr_locality.v3.WrrLocality; |
32 | 39 | import io.grpc.CallOptions; |
33 | 40 | import io.grpc.Channel; |
|
42 | 49 | import io.grpc.testing.protobuf.SimpleRequest; |
43 | 50 | import io.grpc.testing.protobuf.SimpleResponse; |
44 | 51 | import io.grpc.testing.protobuf.SimpleServiceGrpc; |
| 52 | +import java.net.InetSocketAddress; |
45 | 53 | import org.junit.Rule; |
46 | 54 | import org.junit.Test; |
47 | 55 | import org.junit.runner.RunWith; |
@@ -179,4 +187,34 @@ public void pingPong_ringHash() { |
179 | 187 | .build(); |
180 | 188 | assertEquals(goldenResponse, blockingStub.unaryRpc(request)); |
181 | 189 | } |
| 190 | + |
| 191 | + @Test |
| 192 | + public void pingPong_logicalDns() { |
| 193 | + InetSocketAddress serverAddress = |
| 194 | + (InetSocketAddress) dataPlane.getServer().getListenSockets().get(0); |
| 195 | + controlPlane.setCdsConfig( |
| 196 | + ControlPlaneRule.buildCluster().toBuilder() |
| 197 | + .setType(Cluster.DiscoveryType.LOGICAL_DNS) |
| 198 | + .setLoadAssignment( |
| 199 | + ClusterLoadAssignment.newBuilder().addEndpoints( |
| 200 | + LocalityLbEndpoints.newBuilder().addLbEndpoints( |
| 201 | + LbEndpoint.newBuilder().setEndpoint( |
| 202 | + Endpoint.newBuilder().setAddress( |
| 203 | + Address.newBuilder().setSocketAddress( |
| 204 | + SocketAddress.newBuilder() |
| 205 | + .setAddress("localhost") |
| 206 | + .setPortValue(serverAddress.getPort())))))) |
| 207 | + .build()) |
| 208 | + .build()); |
| 209 | + |
| 210 | + ManagedChannel channel = dataPlane.getManagedChannel(); |
| 211 | + SimpleServiceGrpc.SimpleServiceBlockingStub blockingStub = SimpleServiceGrpc.newBlockingStub( |
| 212 | + channel); |
| 213 | + SimpleRequest request = SimpleRequest.newBuilder() |
| 214 | + .build(); |
| 215 | + SimpleResponse goldenResponse = SimpleResponse.newBuilder() |
| 216 | + .setResponseMessage("Hi, xDS!") |
| 217 | + .build(); |
| 218 | + assertEquals(goldenResponse, blockingStub.unaryRpc(request)); |
| 219 | + } |
182 | 220 | } |
0 commit comments