diff --git a/cache/src/main/java/io/envoyproxy/controlplane/cache/Resources.java b/cache/src/main/java/io/envoyproxy/controlplane/cache/Resources.java index 2f3c2bd9..e124636e 100644 --- a/cache/src/main/java/io/envoyproxy/controlplane/cache/Resources.java +++ b/cache/src/main/java/io/envoyproxy/controlplane/cache/Resources.java @@ -7,6 +7,7 @@ import static io.envoyproxy.controlplane.cache.Resources.ResourceType.EXTENSION_CONFIG; import static io.envoyproxy.controlplane.cache.Resources.ResourceType.LISTENER; import static io.envoyproxy.controlplane.cache.Resources.ResourceType.ROUTE; +import static io.envoyproxy.controlplane.cache.Resources.ResourceType.SCOPED_ROUTE; import static io.envoyproxy.controlplane.cache.Resources.ResourceType.SECRET; import com.google.common.base.Preconditions; @@ -23,6 +24,7 @@ import io.envoyproxy.envoy.config.listener.v3.FilterChain; import io.envoyproxy.envoy.config.listener.v3.Listener; import io.envoyproxy.envoy.config.route.v3.RouteConfiguration; +import io.envoyproxy.envoy.config.route.v3.ScopedRouteConfiguration; import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager; import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.RouteSpecifierCase; import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.Secret; @@ -44,6 +46,7 @@ public enum ResourceType { ENDPOINT, LISTENER, ROUTE, + SCOPED_ROUTE, SECRET, EXTENSION_CONFIG } @@ -67,6 +70,8 @@ public static class V3 { "type.googleapis.com/envoy.config.listener.v3" + ".Listener"; public static final String ROUTE_TYPE_URL = "type.googleapis.com/envoy.config.route.v3" + ".RouteConfiguration"; + public static final String SCOPED_ROUTE_TYPE_URL = + "type.googleapis.com/envoy.config.route.v3" + ".ScopedRouteConfiguration"; public static final String SECRET_TYPE_URL = "type.googleapis.com/envoy.extensions" + ".transport_sockets.tls.v3.Secret"; public static final String EXTENSION_CONFIG_TYPE_URL = @@ -78,12 +83,13 @@ public static class V3 { ENDPOINT_TYPE_URL, LISTENER_TYPE_URL, ROUTE_TYPE_URL, + SCOPED_ROUTE_TYPE_URL, SECRET_TYPE_URL, EXTENSION_CONFIG_TYPE_URL); } public static final List RESOURCE_TYPES_IN_ORDER = - ImmutableList.of(CLUSTER, ENDPOINT, LISTENER, ROUTE, SECRET, EXTENSION_CONFIG); + ImmutableList.of(CLUSTER, ENDPOINT, LISTENER, ROUTE, SCOPED_ROUTE, SECRET, EXTENSION_CONFIG); public static final Map TYPE_URLS_TO_RESOURCE_TYPE = new ImmutableMap.Builder() @@ -91,6 +97,7 @@ public static class V3 { .put(Resources.V3.ENDPOINT_TYPE_URL, ENDPOINT) .put(Resources.V3.LISTENER_TYPE_URL, LISTENER) .put(Resources.V3.ROUTE_TYPE_URL, ROUTE) + .put(Resources.V3.SCOPED_ROUTE_TYPE_URL, SCOPED_ROUTE) .put(Resources.V3.SECRET_TYPE_URL, SECRET) .put(Resources.V3.EXTENSION_CONFIG_TYPE_URL, EXTENSION_CONFIG) .build(); @@ -101,6 +108,7 @@ public static class V3 { .put(Resources.V3.ENDPOINT_TYPE_URL, ClusterLoadAssignment.class) .put(Resources.V3.LISTENER_TYPE_URL, Listener.class) .put(Resources.V3.ROUTE_TYPE_URL, RouteConfiguration.class) + .put(Resources.V3.SCOPED_ROUTE_TYPE_URL, ScopedRouteConfiguration.class) .put(Resources.V3.SECRET_TYPE_URL, Secret.class) .put(Resources.V3.EXTENSION_CONFIG_TYPE_URL, TypedExtensionConfig.class) .build(); @@ -127,6 +135,10 @@ public static String getResourceName(Message resource) { return ((RouteConfiguration) resource).getName(); } + if (resource instanceof ScopedRouteConfiguration) { + return ((ScopedRouteConfiguration) resource).getName(); + } + if (resource instanceof Secret) { return ((Secret) resource).getName(); } @@ -185,6 +197,11 @@ public static Set getResourceReferences(Collection Set getResourceReferences(Collection clusters, Iterable endpoints, Iterable listeners, Iterable routes, + Iterable scopedRoutes, Iterable secrets, String version) { @@ -80,6 +83,8 @@ public static Snapshot create( .create(generateSnapshotResourceIterable(listeners), version), SnapshotResources .create(generateSnapshotResourceIterable(routes), version), + SnapshotResources + .create(generateSnapshotResourceIterable(scopedRoutes), version), SnapshotResources .create(generateSnapshotResourceIterable(secrets), version), SnapshotResources @@ -90,14 +95,16 @@ public static Snapshot create( * Returns a new {@link io.envoyproxy.controlplane.cache.v3.Snapshot} instance that has separate versions for each * resource type. * - * @param clusters the cluster resources in this snapshot - * @param clustersVersion the version of the cluster resources - * @param endpoints the endpoint resources in this snapshot - * @param endpointsVersion the version of the endpoint resources - * @param listeners the listener resources in this snapshot - * @param listenersVersion the version of the listener resources - * @param routes the route resources in this snapshot - * @param routesVersion the version of the route resources + * @param clusters the cluster resources in this snapshot + * @param clustersVersion the version of the cluster resources + * @param endpoints the endpoint resources in this snapshot + * @param endpointsVersion the version of the endpoint resources + * @param listeners the listener resources in this snapshot + * @param listenersVersion the version of the listener resources + * @param routes the route resources in this snapshot + * @param routesVersion the version of the route resources + * @param scopedRoutes the route resources in this snapshot + * @param scopedRoutesVersion the version of the route resources */ public static Snapshot create( Iterable clusters, @@ -108,6 +115,8 @@ public static Snapshot create( String listenersVersion, Iterable routes, String routesVersion, + Iterable scopedRoutes, + String scopedRoutesVersion, Iterable secrets, String secretsVersion) { @@ -156,6 +165,8 @@ public static Snapshot create( listenersVersion), SnapshotResources .create(generateSnapshotResourceIterable(routes), routesVersion), + SnapshotResources + .create(generateSnapshotResourceIterable(scopedRoutes), scopedRoutesVersion), SnapshotResources.create(generateSnapshotResourceIterable(secrets), secretsVersion), SnapshotResources.create(generateSnapshotResourceIterable(extensionConfigs), @@ -169,7 +180,7 @@ public static Snapshot create( */ public static Snapshot createEmpty(String version) { return create(Collections.emptySet(), Collections.emptySet(), - Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), version); + Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), version); } /** @@ -192,6 +203,11 @@ public static Snapshot createEmpty(String version) { */ public abstract SnapshotResources routes(); + /** + * Returns all scoped route items in the SRDS payload. + */ + public abstract SnapshotResources scopedRoutes(); + /** * Returns all secret items in the SDS payload. */ @@ -223,6 +239,14 @@ public void ensureConsistent() throws SnapshotConsistencyException { ensureAllResourceNamesExist(Resources.V3.LISTENER_TYPE_URL, Resources.V3.ROUTE_TYPE_URL, listenerRouteRefs, routes().versionedResources()); + + Set srdsRefs = Resources.getResourceReferences(scopedRoutes().versionedResources().values()); + ensureAllResourceNamesExist( + Resources.V3.SCOPED_ROUTE_TYPE_URL, + Resources.V3.ROUTE_TYPE_URL, + srdsRefs, + routes().versionedResources() + ); } /** @@ -258,6 +282,8 @@ public Map> resources(String typeUrl) { return (Map) listeners().resources(); case ROUTE: return (Map) routes().resources(); + case SCOPED_ROUTE: + return (Map) scopedRoutes().resources(); case SECRET: return (Map) secrets().resources(); case EXTENSION_CONFIG: @@ -282,6 +308,8 @@ public Map> versionedResources(ResourceType resourc return (Map) listeners().versionedResources(); case ROUTE: return (Map) routes().versionedResources(); + case SCOPED_ROUTE: + return (Map) scopedRoutes().versionedResources(); case SECRET: return (Map) secrets().versionedResources(); case EXTENSION_CONFIG: @@ -339,6 +367,8 @@ public String version(ResourceType resourceType, List resourceNames) { return listeners().version(resourceNames); case ROUTE: return routes().version(resourceNames); + case SCOPED_ROUTE: + return scopedRoutes().version(resourceNames); case SECRET: return secrets().version(resourceNames); case EXTENSION_CONFIG: diff --git a/cache/src/test/java/io/envoyproxy/controlplane/cache/ResourcesTest.java b/cache/src/test/java/io/envoyproxy/controlplane/cache/ResourcesTest.java index a3c7522f..14fdc1b9 100644 --- a/cache/src/test/java/io/envoyproxy/controlplane/cache/ResourcesTest.java +++ b/cache/src/test/java/io/envoyproxy/controlplane/cache/ResourcesTest.java @@ -98,7 +98,7 @@ public void getResourceReferencesReturnsExpectedReferencesForValidResourceMessag .put((Collection)ImmutableList.of(ROUTE), ImmutableSet.of()) .put( (Collection) ImmutableList.of(CLUSTER, ENDPOINT, LISTENER, ROUTE), - (Collection) ImmutableSet.of(CLUSTER_NAME, ROUTE_NAME)) + ImmutableSet.of(CLUSTER_NAME, ROUTE_NAME)) .build(); cases.forEach( diff --git a/cache/src/test/java/io/envoyproxy/controlplane/cache/v3/SimpleCacheTest.java b/cache/src/test/java/io/envoyproxy/controlplane/cache/v3/SimpleCacheTest.java index 733916cb..6b7b2a1c 100644 --- a/cache/src/test/java/io/envoyproxy/controlplane/cache/v3/SimpleCacheTest.java +++ b/cache/src/test/java/io/envoyproxy/controlplane/cache/v3/SimpleCacheTest.java @@ -2,6 +2,7 @@ import static io.envoyproxy.controlplane.cache.Resources.V3.CLUSTER_TYPE_URL; import static io.envoyproxy.controlplane.cache.Resources.V3.ROUTE_TYPE_URL; +import static io.envoyproxy.controlplane.cache.Resources.V3.SCOPED_ROUTE_TYPE_URL; import static org.assertj.core.api.Assertions.assertThat; import com.google.common.collect.ImmutableList; @@ -20,6 +21,7 @@ import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment; import io.envoyproxy.envoy.config.listener.v3.Listener; import io.envoyproxy.envoy.config.route.v3.RouteConfiguration; +import io.envoyproxy.envoy.config.route.v3.ScopedRouteConfiguration; import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.Secret; import io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest; import java.util.Collections; @@ -40,6 +42,7 @@ public class SimpleCacheTest { private static final String SECONDARY_CLUSTER_NAME = "cluster1"; private static final String LISTENER_NAME = "listener0"; private static final String ROUTE_NAME = "route0"; + private static final String SCOPED_ROUTE_NAME = "scoped_route0"; private static final String SECRET_NAME = "secret0"; private static final String EXTENSION_CONFIG_NAME = "extensionConfig0"; @@ -51,6 +54,7 @@ public class SimpleCacheTest { ImmutableList.of(ClusterLoadAssignment.getDefaultInstance()), ImmutableList.of(Listener.newBuilder().setName(LISTENER_NAME).build()), ImmutableList.of(RouteConfiguration.newBuilder().setName(ROUTE_NAME).build()), + ImmutableList.of(ScopedRouteConfiguration.newBuilder().setName(SCOPED_ROUTE_NAME).build()), ImmutableList.of(Secret.newBuilder().setName(SECRET_NAME).build()), ImmutableList.of(TypedExtensionConfig.newBuilder().setName(EXTENSION_CONFIG_NAME).build()), VERSION1); @@ -60,6 +64,7 @@ public class SimpleCacheTest { ImmutableList.of(ClusterLoadAssignment.getDefaultInstance()), ImmutableList.of(Listener.newBuilder().setName(LISTENER_NAME).build()), ImmutableList.of(RouteConfiguration.newBuilder().setName(ROUTE_NAME).build()), + ImmutableList.of(ScopedRouteConfiguration.newBuilder().setName(SCOPED_ROUTE_NAME).build()), ImmutableList.of(Secret.newBuilder().setName(SECRET_NAME).build()), ImmutableList.of(TypedExtensionConfig.newBuilder().setName(EXTENSION_CONFIG_NAME).build()), VERSION2); @@ -71,6 +76,7 @@ public class SimpleCacheTest { ClusterLoadAssignment.newBuilder().setClusterName(SECONDARY_CLUSTER_NAME).build()), ImmutableList.of(Listener.newBuilder().setName(LISTENER_NAME).build()), ImmutableList.of(RouteConfiguration.newBuilder().setName(ROUTE_NAME).build()), + ImmutableList.of(ScopedRouteConfiguration.newBuilder().setName(SCOPED_ROUTE_NAME).build()), ImmutableList.of(Secret.newBuilder().setName(SECRET_NAME).build()), ImmutableList.of(TypedExtensionConfig.newBuilder().setName(EXTENSION_CONFIG_NAME).build()), VERSION2); @@ -302,6 +308,7 @@ public void successfullyWatchAllResourceTypesWithSetBeforeWatchWithRequestVersio Resources.V3.CLUSTER_TYPE_URL, Resources.V3.ENDPOINT_TYPE_URL, Resources.V3.ENDPOINT_TYPE_URL, Resources.V3.LISTENER_TYPE_URL, Resources.V3.LISTENER_TYPE_URL, ROUTE_TYPE_URL, ROUTE_TYPE_URL, + SCOPED_ROUTE_TYPE_URL, SCOPED_ROUTE_TYPE_URL, Resources.V3.SECRET_TYPE_URL, Resources.V3.SECRET_TYPE_URL, Resources.V3.EXTENSION_CONFIG_TYPE_URL, Resources.V3.EXTENSION_CONFIG_TYPE_URL); } @@ -466,7 +473,8 @@ public void watchesAreReleasedAfterCancel() { public void watchIsLeftOpenIfNotRespondedImmediately() { SimpleCache cache = new SimpleCache<>(new SingleNodeGroup()); cache.setSnapshot(SingleNodeGroup.GROUP, Snapshot.create( - ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), VERSION1)); + ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), + ImmutableList.of(), VERSION1)); ResponseTracker responseTracker = new ResponseTracker(); Watch watch = cache.createWatch( diff --git a/cache/src/test/java/io/envoyproxy/controlplane/cache/v3/SnapshotTest.java b/cache/src/test/java/io/envoyproxy/controlplane/cache/v3/SnapshotTest.java index 3da2f42a..b986200c 100644 --- a/cache/src/test/java/io/envoyproxy/controlplane/cache/v3/SnapshotTest.java +++ b/cache/src/test/java/io/envoyproxy/controlplane/cache/v3/SnapshotTest.java @@ -5,6 +5,7 @@ import static io.envoyproxy.controlplane.cache.Resources.V3.EXTENSION_CONFIG_TYPE_URL; import static io.envoyproxy.controlplane.cache.Resources.V3.LISTENER_TYPE_URL; import static io.envoyproxy.controlplane.cache.Resources.V3.ROUTE_TYPE_URL; +import static io.envoyproxy.controlplane.cache.Resources.V3.SCOPED_ROUTE_TYPE_URL; import static io.envoyproxy.envoy.config.core.v3.ApiVersion.V3; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; @@ -19,6 +20,7 @@ import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment; import io.envoyproxy.envoy.config.listener.v3.Listener; import io.envoyproxy.envoy.config.route.v3.RouteConfiguration; +import io.envoyproxy.envoy.config.route.v3.ScopedRouteConfiguration; import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.Secret; import java.util.UUID; import java.util.concurrent.ThreadLocalRandom; @@ -30,6 +32,7 @@ public class SnapshotTest { private static final String CLUSTER_NAME = "cluster0"; private static final String LISTENER_NAME = "listener0"; private static final String ROUTE_NAME = "route0"; + private static final String SCOPED_ROUTE_NAME = "scoped_route0"; private static final String SECRET_NAME = "secret0"; private static final String EXTENSION_CONFIG_NAME = "extensionConfig0"; @@ -43,6 +46,8 @@ public class SnapshotTest { LISTENER = TestResources.createListener(ADS, false, V3, V3, LISTENER_NAME, LISTENER_PORT, ROUTE_NAME); private static final RouteConfiguration ROUTE = TestResources.createRoute(ROUTE_NAME, CLUSTER_NAME); + private static final ScopedRouteConfiguration SCOPED_ROUTE = TestResources.createScopedRoute(SCOPED_ROUTE_NAME, + ROUTE_NAME); private static final Secret SECRET = TestResources.createSecret(SECRET_NAME); private static final TypedExtensionConfig EXTENSION_CONFIG = TestResources.createExtensionConfig(EXTENSION_CONFIG_NAME); @@ -56,6 +61,7 @@ public void createSingleVersionSetsResourcesCorrectly() { ImmutableList.of(ENDPOINT), ImmutableList.of(LISTENER), ImmutableList.of(ROUTE), + ImmutableList.of(SCOPED_ROUTE), ImmutableList.of(SECRET), version); @@ -75,10 +81,15 @@ public void createSingleVersionSetsResourcesCorrectly() { .containsEntry(ROUTE_NAME, ROUTE) .hasSize(1); + assertThat(snapshot.scopedRoutes().resources()) + .containsEntry(SCOPED_ROUTE_NAME, SCOPED_ROUTE) + .hasSize(1); + assertThat(snapshot.clusters().version()).isEqualTo(version); assertThat(snapshot.endpoints().version()).isEqualTo(version); assertThat(snapshot.listeners().version()).isEqualTo(version); assertThat(snapshot.routes().version()).isEqualTo(version); + assertThat(snapshot.scopedRoutes().version()).isEqualTo(version); } @Test @@ -87,6 +98,7 @@ public void createSeparateVersionsSetsResourcesCorrectly() { final String endpointsVersion = UUID.randomUUID().toString(); final String listenersVersion = UUID.randomUUID().toString(); final String routesVersion = UUID.randomUUID().toString(); + final String scopedRoutesVersion = UUID.randomUUID().toString(); final String secretsVersion = UUID.randomUUID().toString(); Snapshot snapshot = Snapshot.create( @@ -94,6 +106,7 @@ public void createSeparateVersionsSetsResourcesCorrectly() { ImmutableList.of(ENDPOINT), endpointsVersion, ImmutableList.of(LISTENER), listenersVersion, ImmutableList.of(ROUTE), routesVersion, + ImmutableList.of(SCOPED_ROUTE), scopedRoutesVersion, ImmutableList.of(SECRET), secretsVersion ); @@ -113,10 +126,15 @@ public void createSeparateVersionsSetsResourcesCorrectly() { .containsEntry(ROUTE_NAME, ROUTE) .hasSize(1); + assertThat(snapshot.scopedRoutes().resources()) + .containsEntry(SCOPED_ROUTE_NAME, SCOPED_ROUTE) + .hasSize(1); + assertThat(snapshot.clusters().version()).isEqualTo(clustersVersion); assertThat(snapshot.endpoints().version()).isEqualTo(endpointsVersion); assertThat(snapshot.listeners().version()).isEqualTo(listenersVersion); assertThat(snapshot.routes().version()).isEqualTo(routesVersion); + assertThat(snapshot.scopedRoutes().version()).isEqualTo(scopedRoutesVersion); } @Test @@ -179,6 +197,7 @@ public void resourcesReturnsExpectedResources() { ImmutableList.of(ENDPOINT), ImmutableList.of(LISTENER), ImmutableList.of(ROUTE), + ImmutableList.of(SCOPED_ROUTE), ImmutableList.of(SECRET), UUID.randomUUID().toString()); @@ -202,6 +221,10 @@ public void resourcesReturnsExpectedResources() { .containsEntry(ROUTE_NAME, VersionedResource.create(ROUTE)) .hasSize(1); + assertThat(snapshot.resources(SCOPED_ROUTE_TYPE_URL)) + .containsEntry(SCOPED_ROUTE_NAME, VersionedResource.create(SCOPED_ROUTE)) + .hasSize(1); + String nullString = null; assertThat(snapshot.resources(nullString)).isEmpty(); assertThat(snapshot.resources("")).isEmpty(); @@ -217,6 +240,7 @@ public void versionReturnsExpectedVersion() { ImmutableList.of(ENDPOINT), ImmutableList.of(LISTENER), ImmutableList.of(ROUTE), + ImmutableList.of(SCOPED_ROUTE), ImmutableList.of(SECRET), version); @@ -224,6 +248,7 @@ public void versionReturnsExpectedVersion() { assertThat(snapshot.version(ENDPOINT_TYPE_URL)).isEqualTo(version); assertThat(snapshot.version(LISTENER_TYPE_URL)).isEqualTo(version); assertThat(snapshot.version(ROUTE_TYPE_URL)).isEqualTo(version); + assertThat(snapshot.version(SCOPED_ROUTE_TYPE_URL)).isEqualTo(version); String nullString = null; assertThat(snapshot.resources(nullString)).isEmpty(); @@ -239,6 +264,7 @@ public void ensureConsistentReturnsWithoutExceptionForConsistentSnapshot() ImmutableList.of(ENDPOINT), ImmutableList.of(LISTENER), ImmutableList.of(ROUTE), + ImmutableList.of(SCOPED_ROUTE), ImmutableList.of(SECRET), UUID.randomUUID().toString()); @@ -252,6 +278,7 @@ public void ensureConsistentThrowsIfEndpointOrRouteRefCountMismatch() { ImmutableList.of(), ImmutableList.of(LISTENER), ImmutableList.of(ROUTE), + ImmutableList.of(SCOPED_ROUTE), ImmutableList.of(SECRET), UUID.randomUUID().toString()); @@ -268,6 +295,7 @@ public void ensureConsistentThrowsIfEndpointOrRouteRefCountMismatch() { ImmutableList.of(ENDPOINT), ImmutableList.of(LISTENER), ImmutableList.of(), + ImmutableList.of(SCOPED_ROUTE), ImmutableList.of(SECRET), UUID.randomUUID().toString()); @@ -290,6 +318,7 @@ public void ensureConsistentThrowsIfEndpointOrRouteNamesMismatch() { ImmutableList.of(TestResources.createEndpoint(otherClusterName, ENDPOINT_PORT)), ImmutableList.of(LISTENER), ImmutableList.of(ROUTE), + ImmutableList.of(SCOPED_ROUTE), ImmutableList.of(SECRET), UUID.randomUUID().toString()); @@ -307,6 +336,7 @@ public void ensureConsistentThrowsIfEndpointOrRouteNamesMismatch() { ImmutableList.of(ENDPOINT), ImmutableList.of(LISTENER), ImmutableList.of(TestResources.createRoute(otherRouteName, CLUSTER_NAME)), + ImmutableList.of(SCOPED_ROUTE), ImmutableList.of(SECRET), UUID.randomUUID().toString()); diff --git a/server/src/main/java/io/envoyproxy/controlplane/server/V3DiscoveryServer.java b/server/src/main/java/io/envoyproxy/controlplane/server/V3DiscoveryServer.java index 34004b35..75a36d98 100644 --- a/server/src/main/java/io/envoyproxy/controlplane/server/V3DiscoveryServer.java +++ b/server/src/main/java/io/envoyproxy/controlplane/server/V3DiscoveryServer.java @@ -5,6 +5,7 @@ import static io.envoyproxy.envoy.service.extension.v3.ExtensionConfigDiscoveryServiceGrpc.ExtensionConfigDiscoveryServiceImplBase; import static io.envoyproxy.envoy.service.listener.v3.ListenerDiscoveryServiceGrpc.ListenerDiscoveryServiceImplBase; import static io.envoyproxy.envoy.service.route.v3.RouteDiscoveryServiceGrpc.RouteDiscoveryServiceImplBase; +import static io.envoyproxy.envoy.service.route.v3.ScopedRoutesDiscoveryServiceGrpc.ScopedRoutesDiscoveryServiceImplBase; import static io.envoyproxy.envoy.service.secret.v3.SecretDiscoveryServiceGrpc.SecretDiscoveryServiceImplBase; import com.google.common.base.Preconditions; @@ -165,6 +166,25 @@ public StreamObserver deltaRoutes( }; } + /** + * Returns a SRDS implementation that uses this server's {@link ConfigWatcher}. + */ + public ScopedRoutesDiscoveryServiceImplBase getScopedRoutesDiscoveryServiceImpl() { + return new ScopedRoutesDiscoveryServiceImplBase() { + @Override + public StreamObserver streamScopedRoutes( + StreamObserver responseObserver) { + return createRequestHandler(responseObserver, false, Resources.V3.SCOPED_ROUTE_TYPE_URL); + } + + @Override + public StreamObserver deltaScopedRoutes( + StreamObserver responseObserver) { + return createDeltaRequestHandler(responseObserver, false, Resources.V3.SCOPED_ROUTE_TYPE_URL); + } + }; + } + /** * Returns a SDS implementation that uses this server's {@link ConfigWatcher}. */ diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/TestMain.java b/server/src/test/java/io/envoyproxy/controlplane/server/TestMain.java index 713ff129..6da5279b 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/TestMain.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/TestMain.java @@ -34,6 +34,7 @@ public static void main(String[] arg) throws IOException, InterruptedException { ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), + ImmutableList.of(), "1")); V3DiscoveryServer v3DiscoveryServer = new V3DiscoveryServer(cache); @@ -66,6 +67,7 @@ public static void main(String[] arg) throws IOException, InterruptedException { ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), + ImmutableList.of(), "1")); server.awaitTermination(); diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsAllowDefaultEmptyEdsIT.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsAllowDefaultEmptyEdsIT.java index a631a566..76b94dd7 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsAllowDefaultEmptyEdsIT.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsAllowDefaultEmptyEdsIT.java @@ -14,6 +14,7 @@ import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment; import io.envoyproxy.envoy.config.listener.v3.Listener; import io.envoyproxy.envoy.config.route.v3.RouteConfiguration; +import io.envoyproxy.envoy.config.route.v3.ScopedRouteConfiguration; import io.grpc.netty.NettyServerBuilder; import io.restassured.http.ContentType; import java.util.Collections; @@ -58,6 +59,8 @@ protected void configureServerBuilder(NettyServerBuilder builder) { Listener listener = TestResources.createListener(true, false, V3, V3, "listener0", LISTENER_PORT, "route0"); RouteConfiguration route = TestResources.createRoute("route0", "upstream"); + ScopedRouteConfiguration scopedRoute = TestResources.createScopedRoute("scoped_route0", + "route0"); // Construct a snapshot with no_endpoints clusters which does not have EDS data Snapshot snapshot = Snapshot.create( @@ -65,6 +68,7 @@ protected void configureServerBuilder(NettyServerBuilder builder) { ImmutableList.of(endpoint), ImmutableList.of(listener), ImmutableList.of(route), + ImmutableList.of(scopedRoute), ImmutableList.of(), "1"); diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsDeltaResourcesIT.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsDeltaResourcesIT.java index 7bc4c403..c6a08839 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsDeltaResourcesIT.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsDeltaResourcesIT.java @@ -54,6 +54,7 @@ protected void configureServerBuilder(NettyServerBuilder builder) { "listener0", LISTENER_PORT, "route0", + "scoped_route0", "1"); LOGGER.info("snapshot={}", snapshot); cache.setSnapshot( @@ -123,6 +124,7 @@ public void validateTestRequestToEchoServerViaEnvoy() throws InterruptedExceptio "listener1", LISTENER_PORT, "route0", + "scoped_route0", "2"); LOGGER.info("snapshot={}", snapshot); cache.setSnapshot( @@ -151,6 +153,7 @@ public void validateTestRequestToEchoServerViaEnvoy() throws InterruptedExceptio "listener1", LISTENER_PORT, "route0", + "scoped_route0", "3"); LOGGER.info("snapshot={}", snapshot); cache.setSnapshot( diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsIT.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsIT.java index 98061ef2..15625cfb 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsIT.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsIT.java @@ -49,6 +49,7 @@ protected void configureServerBuilder(NettyServerBuilder builder) { "listener0", LISTENER_PORT, "route0", + "scoped_route0", "1")); V3DiscoveryServer server = new V3DiscoveryServer(callbacks, cache); diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsStreamOpenExceptionIT.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsStreamOpenExceptionIT.java index 49f5db63..3317e00b 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsStreamOpenExceptionIT.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsStreamOpenExceptionIT.java @@ -60,6 +60,7 @@ protected void configureServerBuilder(NettyServerBuilder builder) { "listener0", LISTENER_PORT, "route0", + "scoped_route0", "1")); V3DiscoveryServer server = new V3DiscoveryServer(callbacks, cache); diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsWarmingClusterIT.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsWarmingClusterIT.java index 26eeceb6..ab86d699 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsWarmingClusterIT.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerAdsWarmingClusterIT.java @@ -18,6 +18,7 @@ import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment; import io.envoyproxy.envoy.config.listener.v3.Listener; import io.envoyproxy.envoy.config.route.v3.RouteConfiguration; +import io.envoyproxy.envoy.config.route.v3.ScopedRouteConfiguration; import io.envoyproxy.envoy.extensions.upstreams.http.v3.HttpProtocolOptions; import io.envoyproxy.envoy.service.discovery.v3.DeltaDiscoveryRequest; import io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest; @@ -82,7 +83,8 @@ public void onV3StreamResponse(long streamId, DiscoveryRequest request, EchoContainer.PORT, "listener0", LISTENER_PORT, - "route0")); + "route0", + "scoped_route0")); V3DiscoveryServer server = new V3DiscoveryServer(callbacks, cache); @@ -145,6 +147,7 @@ private static void createSnapshotWithWorkingClusterWithTheSameEdsVersion() { "listener0", LISTENER_PORT, "route0", + "scoped_route0", "2")); } @@ -154,7 +157,8 @@ private static Snapshot createSnapshotWithNotWorkingCluster(boolean ads, int endpointPort, String listenerName, int listenerPort, - String routeName) { + String routeName, + String scopedRouteName) { ConfigSource edsSource = ConfigSource.newBuilder() .setAds(AggregatedConfigSource.getDefaultInstance()) @@ -184,6 +188,7 @@ private static Snapshot createSnapshotWithNotWorkingCluster(boolean ads, Listener listener = TestResources.createListener(ads, false, V3, V3, listenerName, listenerPort, routeName); RouteConfiguration route = TestResources.createRoute(routeName, clusterName); + ScopedRouteConfiguration scopedRoute = TestResources.createScopedRoute(scopedRouteName, routeName); // here we have new version of resources other than CDS. return Snapshot.create( @@ -195,6 +200,8 @@ private static Snapshot createSnapshotWithNotWorkingCluster(boolean ads, "2", ImmutableList.of(route), "2", + ImmutableList.of(scopedRoute), + "2", ImmutableList.of(), "2"); } diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerTest.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerTest.java index 6f1f064b..b10fd404 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerTest.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerTest.java @@ -28,6 +28,7 @@ import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment; import io.envoyproxy.envoy.config.listener.v3.Listener; import io.envoyproxy.envoy.config.route.v3.RouteConfiguration; +import io.envoyproxy.envoy.config.route.v3.ScopedRouteConfiguration; import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.Secret; import io.envoyproxy.envoy.service.cluster.v3.ClusterDiscoveryServiceGrpc; import io.envoyproxy.envoy.service.cluster.v3.ClusterDiscoveryServiceGrpc.ClusterDiscoveryServiceStub; @@ -44,6 +45,8 @@ import io.envoyproxy.envoy.service.listener.v3.ListenerDiscoveryServiceGrpc.ListenerDiscoveryServiceStub; import io.envoyproxy.envoy.service.route.v3.RouteDiscoveryServiceGrpc; import io.envoyproxy.envoy.service.route.v3.RouteDiscoveryServiceGrpc.RouteDiscoveryServiceStub; +import io.envoyproxy.envoy.service.route.v3.ScopedRoutesDiscoveryServiceGrpc; +import io.envoyproxy.envoy.service.route.v3.ScopedRoutesDiscoveryServiceGrpc.ScopedRoutesDiscoveryServiceStub; import io.envoyproxy.envoy.service.secret.v3.SecretDiscoveryServiceGrpc; import io.envoyproxy.envoy.service.secret.v3.SecretDiscoveryServiceGrpc.SecretDiscoveryServiceStub; import io.grpc.Status; @@ -74,10 +77,11 @@ public class V3DiscoveryServerTest { private static final boolean ADS = ThreadLocalRandom.current().nextBoolean(); - private static final String CLUSTER_NAME = "cluster0"; - private static final String LISTENER_NAME = "listener0"; - private static final String ROUTE_NAME = "route0"; - private static final String SECRET_NAME = "secret0"; + private static final String CLUSTER_NAME = "cluster0"; + private static final String LISTENER_NAME = "listener0"; + private static final String ROUTE_NAME = "route0"; + private static final String SCOPED_ROUTE_NAME = "scoped_route0"; + private static final String SECRET_NAME = "secret0"; private static final String EXTENSION_CONFIG_NAME = "extensionConfig0"; private static final int ENDPOINT_PORT = Ports.getAvailablePort(); @@ -98,6 +102,8 @@ public class V3DiscoveryServerTest { ROUTE_NAME); private static final RouteConfiguration ROUTE = TestResources.createRoute(ROUTE_NAME, CLUSTER_NAME); + private static final ScopedRouteConfiguration SCOPED_ROUTE = TestResources.createScopedRoute(SCOPED_ROUTE_NAME, + ROUTE_NAME); private static final Secret SECRET = TestResources.createSecret(SECRET_NAME); private static final TypedExtensionConfig EXTENSION_CONFIG = TestResources.createExtensionConfig(EXTENSION_CONFIG_NAME); @@ -140,6 +146,12 @@ public void testAggregatedHandler() throws InterruptedException { .addResourceNames(ROUTE_NAME) .build()); + requestObserver.onNext(DiscoveryRequest.newBuilder() + .setNode(NODE) + .setTypeUrl(Resources.V3.SCOPED_ROUTE_TYPE_URL) + .addResourceNames(SCOPED_ROUTE_NAME) + .build()); + requestObserver.onNext(DiscoveryRequest.newBuilder() .setNode(NODE) .setTypeUrl(Resources.V3.SECRET_TYPE_URL) @@ -182,6 +194,7 @@ public void testSeparateHandlers() throws InterruptedException { grpcServer.getServiceRegistry().addService(server.getEndpointDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getListenerDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getRouteDiscoveryServiceImpl()); + grpcServer.getServiceRegistry().addService(server.getScopedRoutesDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getSecretDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getExtensionConfigDiscoveryServiceImpl()); @@ -189,6 +202,8 @@ public void testSeparateHandlers() throws InterruptedException { EndpointDiscoveryServiceStub endpointStub = EndpointDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); ListenerDiscoveryServiceStub listenerStub = ListenerDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); RouteDiscoveryServiceStub routeStub = RouteDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); + ScopedRoutesDiscoveryServiceStub scopedRouteStub = ScopedRoutesDiscoveryServiceGrpc.newStub( + grpcServer.getChannel()); SecretDiscoveryServiceStub secretStub = SecretDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); ExtensionConfigDiscoveryServiceStub extensionConfigStub = ExtensionConfigDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); @@ -216,6 +231,10 @@ public void testSeparateHandlers() throws InterruptedException { requestObserver = routeStub.streamRoutes(responseObserver); discoveryRequestBuilder.addResourceNames(ROUTE_NAME); break; + case Resources.V3.SCOPED_ROUTE_TYPE_URL: + requestObserver = scopedRouteStub.streamScopedRoutes(responseObserver); + discoveryRequestBuilder.addResourceNames(ROUTE_NAME); + break; case Resources.V3.SECRET_TYPE_URL: requestObserver = secretStub.streamSecrets(responseObserver); discoveryRequestBuilder.addResourceNames(SECRET_NAME); @@ -390,6 +409,7 @@ public void testSeparateHandlersDefaultRequestType() throws InterruptedException grpcServer.getServiceRegistry().addService(server.getEndpointDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getListenerDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getRouteDiscoveryServiceImpl()); + grpcServer.getServiceRegistry().addService(server.getScopedRoutesDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getSecretDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getExtensionConfigDiscoveryServiceImpl()); @@ -397,6 +417,8 @@ public void testSeparateHandlersDefaultRequestType() throws InterruptedException EndpointDiscoveryServiceStub endpointStub = EndpointDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); ListenerDiscoveryServiceStub listenerStub = ListenerDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); RouteDiscoveryServiceStub routeStub = RouteDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); + ScopedRoutesDiscoveryServiceStub scopedRouteStub = ScopedRoutesDiscoveryServiceGrpc.newStub( + grpcServer.getChannel()); SecretDiscoveryServiceStub secretStub = SecretDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); ExtensionConfigDiscoveryServiceStub extensionConfigStub = ExtensionConfigDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); @@ -419,6 +441,9 @@ public void testSeparateHandlersDefaultRequestType() throws InterruptedException case Resources.V3.ROUTE_TYPE_URL: requestObserver = routeStub.streamRoutes(responseObserver); break; + case Resources.V3.SCOPED_ROUTE_TYPE_URL: + requestObserver = scopedRouteStub.streamScopedRoutes(responseObserver); + break; case Resources.V3.SECRET_TYPE_URL: requestObserver = secretStub.streamSecrets(responseObserver); break; @@ -536,6 +561,12 @@ public void onV3StreamResponse(long streamId, DiscoveryRequest request, .addResourceNames(ROUTE_NAME) .build()); + requestObserver.onNext(DiscoveryRequest.newBuilder() + .setNode(NODE) + .setTypeUrl(Resources.V3.SCOPED_ROUTE_TYPE_URL) + .addResourceNames(SCOPED_ROUTE_NAME) + .build()); + requestObserver.onNext(DiscoveryRequest.newBuilder() .setNode(NODE) .setTypeUrl(Resources.V3.SECRET_TYPE_URL) @@ -590,6 +621,14 @@ public void onV3StreamResponse(long streamId, DiscoveryRequest request, .setVersionInfo(VERSION) .build()); + requestObserver.onNext(DiscoveryRequest.newBuilder() + .setNode(NODE) + .setResponseNonce("3") + .setTypeUrl(Resources.V3.SCOPED_ROUTE_TYPE_URL) + .addResourceNames(SCOPED_ROUTE_NAME) + .setVersionInfo(VERSION) + .build()); + requestObserver.onNext(DiscoveryRequest.newBuilder() .setNode(NODE) .setResponseNonce("4") @@ -697,6 +736,7 @@ public void onV3StreamResponse(long streamId, DiscoveryRequest request, grpcServer.getServiceRegistry().addService(server.getEndpointDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getListenerDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getRouteDiscoveryServiceImpl()); + grpcServer.getServiceRegistry().addService(server.getScopedRoutesDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getSecretDiscoveryServiceImpl()); grpcServer.getServiceRegistry().addService(server.getExtensionConfigDiscoveryServiceImpl()); @@ -704,6 +744,8 @@ public void onV3StreamResponse(long streamId, DiscoveryRequest request, EndpointDiscoveryServiceStub endpointStub = EndpointDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); ListenerDiscoveryServiceStub listenerStub = ListenerDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); RouteDiscoveryServiceStub routeStub = RouteDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); + ScopedRoutesDiscoveryServiceStub scopedRouteStub = ScopedRoutesDiscoveryServiceGrpc.newStub( + grpcServer.getChannel()); SecretDiscoveryServiceStub secretStub = SecretDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); ExtensionConfigDiscoveryServiceStub extensionConfigStub = ExtensionConfigDiscoveryServiceGrpc.newStub(grpcServer.getChannel()); @@ -726,6 +768,9 @@ public void onV3StreamResponse(long streamId, DiscoveryRequest request, case Resources.V3.ROUTE_TYPE_URL: requestObserver = routeStub.streamRoutes(responseObserver); break; + case Resources.V3.SCOPED_ROUTE_TYPE_URL: + requestObserver = scopedRouteStub.streamScopedRoutes(responseObserver); + break; case Resources.V3.SECRET_TYPE_URL: requestObserver = secretStub.streamSecrets(responseObserver); break; @@ -1056,6 +1101,7 @@ private static Table> createRespon .put(Resources.V3.ENDPOINT_TYPE_URL, VERSION, ImmutableList.of(ENDPOINT)) .put(Resources.V3.LISTENER_TYPE_URL, VERSION, ImmutableList.of(LISTENER)) .put(Resources.V3.ROUTE_TYPE_URL, VERSION, ImmutableList.of(ROUTE)) + .put(Resources.V3.SCOPED_ROUTE_TYPE_URL, VERSION, ImmutableList.of(SCOPED_ROUTE)) .put(Resources.V3.SECRET_TYPE_URL, VERSION, ImmutableList.of(SECRET)) .put(Resources.V3.EXTENSION_CONFIG_TYPE_URL, VERSION, ImmutableList.of(EXTENSION_CONFIG)) .build(); diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerXdsDeltaResourcesIT.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerXdsDeltaResourcesIT.java index 15527f30..f875f9c0 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerXdsDeltaResourcesIT.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerXdsDeltaResourcesIT.java @@ -55,6 +55,7 @@ protected void configureServerBuilder(NettyServerBuilder builder) { "listener0", LISTENER_PORT, "route0", + "scoped_route0", "1"); LOGGER.info("snapshot={}", snapshot); cache.setSnapshot( @@ -129,6 +130,7 @@ public void validateTestRequestToEchoServerViaEnvoy() throws InterruptedExceptio "listener1", LISTENER_PORT, "route0", + "scoped_route0", "2"); LOGGER.info("snapshot={}", snapshot); cache.setSnapshot( @@ -157,6 +159,7 @@ public void validateTestRequestToEchoServerViaEnvoy() throws InterruptedExceptio "listener1", LISTENER_PORT, "route0", + "scoped_route0", "2"); LOGGER.info("snapshot={}", snapshot); cache.setSnapshot( diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerXdsIT.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerXdsIT.java index c6cb148c..8c80a070 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerXdsIT.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3DiscoveryServerXdsIT.java @@ -46,6 +46,7 @@ protected void configureServerBuilder(NettyServerBuilder builder) { "listener0", LISTENER_PORT, "route0", + "scoped_route0", "1") ); diff --git a/server/src/test/java/io/envoyproxy/controlplane/server/V3TestSnapshots.java b/server/src/test/java/io/envoyproxy/controlplane/server/V3TestSnapshots.java index 44980eea..0d7f6554 100644 --- a/server/src/test/java/io/envoyproxy/controlplane/server/V3TestSnapshots.java +++ b/server/src/test/java/io/envoyproxy/controlplane/server/V3TestSnapshots.java @@ -9,6 +9,7 @@ import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment; import io.envoyproxy.envoy.config.listener.v3.Listener; import io.envoyproxy.envoy.config.route.v3.RouteConfiguration; +import io.envoyproxy.envoy.config.route.v3.ScopedRouteConfiguration; import org.testcontainers.shaded.com.google.common.collect.ImmutableList; class V3TestSnapshots { @@ -22,6 +23,7 @@ static Snapshot createSnapshot( String listenerName, int listenerPort, String routeName, + String scopedRouteName, String version) { Cluster cluster = TestResources.createCluster(clusterName); @@ -30,12 +32,14 @@ static Snapshot createSnapshot( Listener listener = TestResources.createListener(ads, delta, V3, V3, listenerName, listenerPort, routeName); RouteConfiguration route = TestResources.createRoute(routeName, clusterName); + ScopedRouteConfiguration scopedRoute = TestResources.createScopedRoute(scopedRouteName, routeName); return Snapshot.create( ImmutableList.of(cluster), ImmutableList.of(endpoint), ImmutableList.of(listener), ImmutableList.of(route), + ImmutableList.of(scopedRoute), ImmutableList.of(), version); } @@ -49,9 +53,10 @@ static Snapshot createSnapshotNoEds( String listenerName, int listenerPort, String routeName, + String scopedRouteName, String version) { return createSnapshotNoEds(ads, delta, V3, V3, clusterName, endpointAddress, - endpointPort, listenerName, listenerPort, routeName, version); + endpointPort, listenerName, listenerPort, routeName, scopedRouteName, version); } private static Snapshot createSnapshotNoEds( @@ -65,6 +70,7 @@ private static Snapshot createSnapshotNoEds( String listenerName, int listenerPort, String routeName, + String scopedRouteName, String version) { Cluster cluster = TestResources.createCluster(clusterName, endpointAddress, @@ -73,12 +79,14 @@ private static Snapshot createSnapshotNoEds( .createListener(ads, delta, rdsTransportVersion, rdsResourceVersion, listenerName, listenerPort, routeName); RouteConfiguration route = TestResources.createRoute(routeName, clusterName); + ScopedRouteConfiguration scopedRoute = TestResources.createScopedRoute(scopedRouteName, routeName); return Snapshot.create( ImmutableList.of(cluster), ImmutableList.of(), ImmutableList.of(listener), ImmutableList.of(route), + ImmutableList.of(scopedRoute), ImmutableList.of(), version); }