diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-01-30 12:10:27 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-01-30 12:35:11 +0100 |
commit | d6bc119e2b074e07ffa9f340cb289bd912300d26 (patch) | |
tree | d0aeb4b64579dff1971653deaf1befa2574e20a2 /controller-server | |
parent | 2533470181c45a877fdc884f1c6742e0934aa6bb (diff) |
Query routing generator when zone explicitly supports shared routing
Diffstat (limited to 'controller-server')
10 files changed, 114 insertions, 76 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java index 32b87b8f92b..29d6de858dc 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java @@ -5,6 +5,7 @@ import com.yahoo.config.application.api.DeploymentInstanceSpec; import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.InstanceName; +import com.yahoo.config.provision.zone.RoutingMethod; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; @@ -72,18 +73,10 @@ public class RoutingController { /** Returns all known endpoint URLs for given deployment, including global, in the shared routing layer */ public List<URI> legacyEndpointsOf(DeploymentId deployment) { - if (controller.zoneRegistry().zones().directlyRouted().ids().contains(deployment.zoneId())) { - return List.of(); // No shared routing layer in this zone. - } - try { - return routingGenerator.endpoints(deployment).stream() - .map(RoutingEndpoint::endpoint) - .map(URI::create) - .collect(Collectors.toUnmodifiableList()); - } catch (RuntimeException e) { - log.log(Level.WARNING, "Failed to get endpoints for " + deployment, e); - return List.of(); - } + return routingEndpointsOf(deployment).stream() + .map(RoutingEndpoint::endpoint) + .map(URI::create) + .collect(Collectors.toUnmodifiableList()); } /** Returns all non-global endpoint URLs for given deployment, grouped by their cluster ID */ @@ -146,9 +139,9 @@ public class RoutingController { /** Find the global endpoints of given deployment */ private List<RoutingEndpoint> legacyGlobalEndpointsOf(DeploymentId deployment) { - return controller.serviceRegistry().routingGenerator().endpoints(deployment).stream() - .filter(RoutingEndpoint::isGlobal) - .collect(Collectors.toUnmodifiableList()); + return routingEndpointsOf(deployment).stream() + .filter(RoutingEndpoint::isGlobal) + .collect(Collectors.toUnmodifiableList()); } /** @@ -222,4 +215,16 @@ public class RoutingController { }); } + private List<RoutingEndpoint> routingEndpointsOf(DeploymentId deployment) { + if (!controller.zoneRegistry().zones().routingMethod(RoutingMethod.shared).ids().contains(deployment.zoneId())) { + return List.of(); // No rotations/shared routing layer in this zone. + } + try { + return routingGenerator.endpoints(deployment); + } catch (RuntimeException e) { + log.log(Level.WARNING, "Failed to get endpoints for " + deployment, e); + return List.of(); + } + } + } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index bd59fc45c96..a3458073fc0 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller; import com.google.common.collect.Sets; @@ -178,7 +178,7 @@ public class ControllerTest { public void testGlobalRotations() { // Setup ControllerTester tester = this.tester.controllerTester(); - ZoneId zone = ZoneId.from(Environment.defaultEnvironment(), RegionName.defaultName()); + ZoneId zone = ZoneId.from("prod", "us-west-1"); ApplicationId app = ApplicationId.from("tenant", "app1", "default"); DeploymentId deployment = new DeploymentId(app, zone); tester.serviceRegistry().routingGeneratorMock().putEndpoints(deployment, List.of( @@ -705,7 +705,7 @@ public class ControllerTest { // Create app1 var context1 = tester.newDeploymentContext("tenant1", "app1", "default"); var prodZone = ZoneId.from("prod", "us-west-1"); - tester.controllerTester().zoneRegistry().setDirectlyRouted(ZoneApiMock.from(prodZone)); + tester.controllerTester().zoneRegistry().exclusiveRoutingIn(ZoneApiMock.from(prodZone)); var applicationPackage = new ApplicationPackageBuilder().environment(prodZone.environment()) .region(prodZone.region()) .build(); @@ -732,8 +732,7 @@ public class ControllerTest { var context2 = tester.newDeploymentContext("tenant1", "app2", "default"); var devZone = ZoneId.from("dev", "us-east-1"); - // Deploy app2, after "removing" direct routing everywhere - tester.controllerTester().zoneRegistry().setDirectlyRouted(); + // Deploy app2 in a zone with shared routing tester.controller().applications().deploy(context2.instanceId(), devZone, Optional.of(applicationPackage), DeployOptions.none()); assertTrue("Application deployed and activated", tester.configServer().application(context2.instanceId(), devZone).get().activated()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java index c90abe5ed5c..d656c4d9f18 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentContext.java @@ -8,6 +8,7 @@ import com.yahoo.config.provision.AthenzService; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; +import com.yahoo.config.provision.zone.RoutingMethod; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.security.KeyAlgorithm; import com.yahoo.security.KeyUtils; @@ -524,7 +525,7 @@ public class DeploymentContext { /** Sets a single endpoint in the routing layer; this matches that required for the tester */ private DeploymentContext setEndpoints(ZoneId zone, boolean tester) { - if (isDirectlyRouted(zone)) return this; + if (!supportsRoutingMethod(RoutingMethod.shared, zone)) return this; var id = instanceId; if (tester) { id = testerId.id(); @@ -615,11 +616,12 @@ public class DeploymentContext { /** Returns whether a load balancer is expected to be provisioned in given zone */ private boolean provisionLoadBalancerIn(ZoneId zone) { - return !deferLoadBalancerProvisioning.contains(zone.environment()) && isDirectlyRouted(zone); + return !deferLoadBalancerProvisioning.contains(zone.environment()) && + supportsRoutingMethod(RoutingMethod.exclusive, zone); } - private boolean isDirectlyRouted(ZoneId zone) { - return tester.controller().zoneRegistry().zones().directlyRouted().ids().contains(zone); + private boolean supportsRoutingMethod(RoutingMethod method, ZoneId zone) { + return tester.controller().zoneRegistry().zones().routingMethod(method).ids().contains(zone); } private JobId jobId(JobType type) { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java index 830643b215a..9688e98009a 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java @@ -8,6 +8,7 @@ import com.yahoo.config.provision.AthenzDomain; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.NodeResources; import com.yahoo.config.provision.SystemName; +import com.yahoo.config.provision.zone.RoutingMethod; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.slime.ArrayTraverser; import com.yahoo.slime.Inspector; @@ -260,7 +261,7 @@ public class InternalStepRunnerTest { public void alternativeEndpointsAreDetected() { var systemTestZone = JobType.systemTest.zone(system()); var stagingZone = JobType.stagingTest.zone(system()); - tester.controllerTester().zoneRegistry().setDirectlyRouted(ZoneApiMock.from(systemTestZone), ZoneApiMock.from(stagingZone)); + tester.controllerTester().zoneRegistry().exclusiveRoutingIn(ZoneApiMock.from(systemTestZone), ZoneApiMock.from(stagingZone)); app.newRun(JobType.systemTest); tester.runner().run();; tester.configServer().convergeServices(app.instanceId(), JobType.systemTest.zone(system())); @@ -426,9 +427,12 @@ public class InternalStepRunnerTest { @Test public void certificateTimeoutAbortsJob() { tester.controllerTester().zoneRegistry().setSystemName(SystemName.PublicCd); - tester.controllerTester().zoneRegistry().setZones(ZoneApiMock.fromId("test.aws-us-east-1c"), - ZoneApiMock.fromId("staging.aws-us-east-1c"), - ZoneApiMock.fromId("prod.aws-us-east-1c")); + var zones = List.of(ZoneApiMock.fromId("test.aws-us-east-1c"), + ZoneApiMock.fromId("staging.aws-us-east-1c"), + ZoneApiMock.fromId("prod.aws-us-east-1c")); + tester.controllerTester().zoneRegistry() + .setZones(zones) + .setRoutingMethod(zones, RoutingMethod.shared); tester.configServer().bootstrap(tester.controllerTester().zoneRegistry().zones().all().ids(), SystemApplication.values()); RunId id = app.startSystemTestTests(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/endpointcertificates/EndpointCertificateManagerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/endpointcertificates/EndpointCertificateManagerTest.java index 808d9ca05c4..270f83ea26b 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/endpointcertificates/EndpointCertificateManagerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/endpointcertificates/EndpointCertificateManagerTest.java @@ -13,7 +13,6 @@ import org.junit.Test; import java.time.Clock; import java.util.Optional; -import java.util.Set; import static org.junit.Assert.assertTrue; @@ -26,7 +25,7 @@ public class EndpointCertificateManagerTest { public void getEndpointCertificate() { SecretStoreMock secretStore = new SecretStoreMock(); ZoneRegistryMock zoneRegistryMock = new ZoneRegistryMock(SystemName.main); - zoneRegistryMock.setDirectlyRouted(Set.copyOf(zoneRegistryMock.zones().all().zones())); + zoneRegistryMock.exclusiveRoutingIn(zoneRegistryMock.zones().all().zones()); MockCuratorDb mockCuratorDb = new MockCuratorDb(); ApplicationCertificateMock applicationCertificateMock = new ApplicationCertificateMock(); Clock clock = Clock.systemUTC(); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java index bd82807342e..2dfeb7b8b02 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java @@ -1,4 +1,4 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.integration; import com.google.inject.Inject; @@ -42,7 +42,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg private final ConfigServerMock configServerMock; private final MemoryNameService memoryNameService = new MemoryNameService(); private final MemoryGlobalRoutingService memoryGlobalRoutingService = new MemoryGlobalRoutingService(); - private final RoutingGeneratorMock routingGeneratorMock = new RoutingGeneratorMock(RoutingGeneratorMock.TEST_ENDPOINTS); + private final RoutingGeneratorMock routingGeneratorMock; private final MockMailer mockMailer = new MockMailer(); private final ApplicationCertificateMock applicationCertificateMock = new ApplicationCertificateMock(); private final MockMeteringClient mockMeteringClient = new MockMeteringClient(); @@ -64,6 +64,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg public ServiceRegistryMock(SystemName system) { this.zoneRegistryMock = new ZoneRegistryMock(system); this.configServerMock = new ConfigServerMock(zoneRegistryMock); + this.routingGeneratorMock = new RoutingGeneratorMock(RoutingGeneratorMock.TEST_ENDPOINTS, zoneRegistryMock); } @Inject diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneFilterMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneFilterMock.java index 4cd50625ca3..764c2003c46 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneFilterMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneFilterMock.java @@ -1,9 +1,10 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.integration; import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; +import com.yahoo.config.provision.zone.RoutingMethod; import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.config.provision.zone.ZoneFilter; import com.yahoo.config.provision.zone.ZoneId; @@ -11,6 +12,7 @@ import com.yahoo.config.provision.zone.ZoneList; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -23,22 +25,22 @@ import java.util.stream.Collectors; public class ZoneFilterMock implements ZoneList { private final List<ZoneApi> zones; - private final Set<ZoneApi> directlyRouted; + private final Map<ZoneApi, Set<RoutingMethod>> zoneRoutingMethods; private final boolean negate; - private ZoneFilterMock(List<ZoneApi> zones, Set<ZoneApi> directlyRouted, boolean negate) { + private ZoneFilterMock(List<ZoneApi> zones, Map<ZoneApi, Set<RoutingMethod>> zoneRoutingMethods, boolean negate) { this.zones = zones; - this.directlyRouted = directlyRouted; + this.zoneRoutingMethods = zoneRoutingMethods; this.negate = negate; } - public static ZoneFilter from(Collection<ZoneApi> zones, Set<ZoneApi> directlyRouted) { - return new ZoneFilterMock(List.copyOf(zones), Set.copyOf(directlyRouted), false); + public static ZoneFilter from(Collection<? extends ZoneApi> zones, Map<ZoneApi, Set<RoutingMethod>> routingMethods) { + return new ZoneFilterMock(List.copyOf(zones), Map.copyOf(routingMethods), false); } @Override public ZoneList not() { - return new ZoneFilterMock(zones, directlyRouted, ! negate); + return new ZoneFilterMock(zones, zoneRoutingMethods, ! negate); } @Override @@ -53,7 +55,12 @@ public class ZoneFilterMock implements ZoneList { @Override public ZoneList directlyRouted() { - return filter(directlyRouted::contains); + return routingMethod(RoutingMethod.exclusive); + } + + @Override + public ZoneList routingMethod(RoutingMethod method) { + return filter(zone -> zoneRoutingMethods.getOrDefault(zone, Set.of()).contains(method)); } @Override @@ -93,7 +100,7 @@ public class ZoneFilterMock implements ZoneList { condition.negate().test(zone) : condition.test(zone)) .collect(Collectors.toList()), - directlyRouted, false); + zoneRoutingMethods, false); } } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java index 3cb7a13dd54..a5e054d6068 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ZoneRegistryMock.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.integration; import com.yahoo.component.AbstractComponent; @@ -9,6 +9,7 @@ import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.SystemName; +import com.yahoo.config.provision.zone.RoutingMethod; import com.yahoo.config.provision.zone.UpgradePolicy; import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.config.provision.zone.ZoneFilter; @@ -34,11 +35,12 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry private final Map<ZoneId, Duration> deploymentTimeToLive = new HashMap<>(); private final Map<Environment, RegionName> defaultRegionForEnvironment = new HashMap<>(); - private List<ZoneApi> zones = List.of(); + private final Map<CloudName, UpgradePolicy> osUpgradePolicies = new HashMap<>(); + private final Map<ZoneApi, Set<RoutingMethod>> zoneRoutingMethods = new HashMap<>(); + + private List<? extends ZoneApi> zones; private SystemName system; private UpgradePolicy upgradePolicy = null; - private Map<CloudName, UpgradePolicy> osUpgradePolicies = new HashMap<>(); - private Set<ZoneApi> directlyRouted = Set.of(); /** * This sets the default list of zones contained in this. If your test need a particular set of zones, use @@ -46,20 +48,21 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry */ public ZoneRegistryMock(SystemName system) { this.system = system; - setZones(List.of( - ZoneApiMock.fromId("test.us-east-1"), - ZoneApiMock.fromId("staging.us-east-3"), - ZoneApiMock.fromId("dev.us-east-1"), - ZoneApiMock.fromId("dev.aws-us-east-2a"), - ZoneApiMock.fromId("perf.us-east-3"), - ZoneApiMock.fromId("prod.aws-us-east-1a"), - ZoneApiMock.fromId("prod.ap-northeast-1"), - ZoneApiMock.fromId("prod.ap-northeast-2"), - ZoneApiMock.fromId("prod.ap-southeast-1"), - ZoneApiMock.fromId("prod.us-east-3"), - ZoneApiMock.fromId("prod.us-west-1"), - ZoneApiMock.fromId("prod.us-central-1"), - ZoneApiMock.fromId("prod.eu-west-1"))); + this.zones = List.of(ZoneApiMock.fromId("test.us-east-1"), + ZoneApiMock.fromId("staging.us-east-3"), + ZoneApiMock.fromId("dev.us-east-1"), + ZoneApiMock.fromId("dev.aws-us-east-2a"), + ZoneApiMock.fromId("perf.us-east-3"), + ZoneApiMock.fromId("prod.aws-us-east-1a"), + ZoneApiMock.fromId("prod.ap-northeast-1"), + ZoneApiMock.fromId("prod.ap-northeast-2"), + ZoneApiMock.fromId("prod.ap-southeast-1"), + ZoneApiMock.fromId("prod.us-east-3"), + ZoneApiMock.fromId("prod.us-west-1"), + ZoneApiMock.fromId("prod.us-central-1"), + ZoneApiMock.fromId("prod.eu-west-1")); + // All zones use a shared routing method by default + setRoutingMethod(this.zones, RoutingMethod.shared); } public ZoneRegistryMock setDeploymentTimeToLive(ZoneId zone, Duration duration) { @@ -72,7 +75,7 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry return this; } - public ZoneRegistryMock setZones(List<ZoneApi> zones) { + public ZoneRegistryMock setZones(List<? extends ZoneApi> zones) { this.zones = zones; return this; } @@ -96,12 +99,25 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry return this; } - public ZoneRegistryMock setDirectlyRouted(ZoneApi... zones) { - return setDirectlyRouted(Set.of(zones)); + public ZoneRegistryMock exclusiveRoutingIn(ZoneApi... zones) { + return exclusiveRoutingIn(List.of(zones)); + } + + public ZoneRegistryMock exclusiveRoutingIn(List<? extends ZoneApi> zones) { + return setRoutingMethod(zones, RoutingMethod.exclusive); + } + + public ZoneRegistryMock setRoutingMethod(ZoneApi zone, RoutingMethod... routingMethods) { + return setRoutingMethod(zone, Set.of(routingMethods)); + } + + public ZoneRegistryMock setRoutingMethod(List<? extends ZoneApi> zones, RoutingMethod... routingMethods) { + zones.forEach(zone -> setRoutingMethod(zone, Set.of(routingMethods))); + return this; } - public ZoneRegistryMock setDirectlyRouted(Set<ZoneApi> zones) { - directlyRouted = zones; + public ZoneRegistryMock setRoutingMethod(ZoneApi zone, Set<RoutingMethod> routingMethods) { + this.zoneRoutingMethods.put(zone, Set.copyOf(routingMethods)); return this; } @@ -112,7 +128,7 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry @Override public ZoneFilter zones() { - return ZoneFilterMock.from(zones, directlyRouted); + return ZoneFilterMock.from(zones, zoneRoutingMethods); } @Override diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java index e5670139b0f..635adc73d1d 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/routing/RoutingApiTest.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.controller.restapi.routing; import com.yahoo.application.container.handler.Request; +import com.yahoo.config.provision.zone.RoutingMethod; import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.ControllerTester; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; @@ -34,14 +35,13 @@ public class RoutingApiTest extends ControllerContainerTest { } @Test - public void policy_based_routing() { + public void exclusive_routing() { var context = deploymentTester.newDeploymentContext(); // Zones support direct routing var westZone = ZoneId.from("prod", "us-west-1"); var eastZone = ZoneId.from("prod", "us-east-3"); - deploymentTester.controllerTester().zoneRegistry().setDirectlyRouted(ZoneApiMock.from(westZone), - ZoneApiMock.from(eastZone)); - + deploymentTester.controllerTester().zoneRegistry().exclusiveRoutingIn(ZoneApiMock.from(westZone), + ZoneApiMock.from(eastZone)); // Deploy application var applicationPackage = new ApplicationPackageBuilder() .region(westZone.region()) @@ -96,7 +96,7 @@ public class RoutingApiTest extends ControllerContainerTest { } @Test - public void rotation_based_routing() { + public void shared_routing() { // Deploy application var context = deploymentTester.newDeploymentContext(); var westZone = ZoneId.from("prod", "us-west-1"); @@ -156,10 +156,16 @@ public class RoutingApiTest extends ControllerContainerTest { // TODO(mpolden): Remove this once a zone supports either of routing policy and rotation @Test public void mixed_routing() { - // Deploy application - var context = deploymentTester.newDeploymentContext(); var westZone = ZoneId.from("prod", "us-west-1"); var eastZone = ZoneId.from("prod", "us-east-3"); + + // One zone supports multiple routing methods + deploymentTester.controllerTester().zoneRegistry().setRoutingMethod(ZoneApiMock.from(westZone), + RoutingMethod.shared, + RoutingMethod.exclusive); + + // Deploy application + var context = deploymentTester.newDeploymentContext(); var applicationPackage = new ApplicationPackageBuilder() .region(westZone.region()) .region(eastZone.region()) @@ -168,7 +174,6 @@ public class RoutingApiTest extends ControllerContainerTest { context.submit(applicationPackage).deploy(); // Assign policy in one zone - deploymentTester.controllerTester().zoneRegistry().setDirectlyRouted(ZoneApiMock.from(westZone)); context.addRoutingPolicy(westZone, true); // GET status with both policy and rotation assigned diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java index 2b196b9127f..d81b836cad8 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/routing/RoutingPoliciesTest.java @@ -266,7 +266,7 @@ public class RoutingPoliciesTest { var zoneApi = ZoneApiMock.from(zone.environment(), zone.region()); tester.controllerTester().serviceRegistry().zoneRegistry() .setZones(zoneApi) - .setDirectlyRouted(zoneApi); + .exclusiveRoutingIn(zoneApi); tester.provisionLoadBalancers(1, context.instanceId(), zone); // Deploy to dev @@ -289,7 +289,7 @@ public class RoutingPoliciesTest { var zoneApi = ZoneApiMock.from(zone.environment(), zone.region()); tester.controllerTester().serviceRegistry().zoneRegistry() .setZones(zoneApi) - .setDirectlyRouted(zoneApi); + .exclusiveRoutingIn(zoneApi); var prodRecords = Set.of("app1.tenant1.us-central-1.vespa.oath.cloud", "app1.tenant1.us-west-1.vespa.oath.cloud"); assertEquals(prodRecords, tester.recordNames()); @@ -523,7 +523,7 @@ public class RoutingPoliciesTest { public RoutingPoliciesTester(DeploymentTester tester) { this.tester = tester; // Make all zones directly routed - tester.controllerTester().zoneRegistry().setDirectlyRouted(Set.copyOf(tester.controllerTester().zoneRegistry().zones().all().zones())); + tester.controllerTester().zoneRegistry().exclusiveRoutingIn(tester.controllerTester().zoneRegistry().zones().all().zones()); } private void provisionLoadBalancers(int clustersPerZone, ApplicationId application, ZoneId... zones) { |