diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-11-09 23:19:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 23:19:52 +0100 |
commit | 02e8bed475c61a69daf4ad66dceb47e1b720b2fe (patch) | |
tree | 9f46cd2e93930101c268e2fae8344b1944d3578f /controller-server/src/test/java/com | |
parent | ab48494712073ed6a4c7d1766bc9769c15b8bee0 (diff) |
Revert "Include application-level endpoints and scope in deploy"
Diffstat (limited to 'controller-server/src/test/java/com')
5 files changed, 36 insertions, 101 deletions
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 1e8e444896f..e2bc1fa305d 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 @@ -12,7 +12,6 @@ import com.yahoo.config.provision.CloudName; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.HostName; -import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.zone.RoutingMethod; @@ -21,17 +20,16 @@ import com.yahoo.path.Path; import com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificateMetadata; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.ContainerEndpoint; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.dns.LatencyAliasTarget; import com.yahoo.vespa.hosted.controller.api.integration.dns.Record; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName; import com.yahoo.vespa.hosted.controller.api.integration.dns.WeightedAliasTarget; +import com.yahoo.vespa.hosted.controller.application.pkg.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.DeploymentMetrics; import com.yahoo.vespa.hosted.controller.application.Endpoint; -import com.yahoo.vespa.hosted.controller.application.pkg.ApplicationPackage; import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.DeploymentContext; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester; @@ -46,7 +44,6 @@ import java.time.Duration; import java.time.Instant; import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.function.Function; @@ -247,7 +244,7 @@ public class ControllerTest { assertEquals("Rotation names are passed to config server in " + deployment.zone(), Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(deployment.zone()))); + tester.configServer().containerEndpoints().get(context.deploymentIdIn(deployment.zone()))); } context.flushDnsUpdates(); @@ -258,7 +255,7 @@ public class ControllerTest { assertEquals("app1--tenant1.global.vespa.oath.cloud", record.get().name().asString()); assertEquals("rotation-fqdn-01.", record.get().data().asString()); - List<String> globalDnsNames = tester.controller().routing().readDeclaredEndpointsOf(context.instanceId()) + List<String> globalDnsNames = tester.controller().routing().endpointsOf(context.instanceId()) .scope(Endpoint.Scope.global) .mapToList(Endpoint::dnsName); assertEquals(List.of("app1--tenant1.global.vespa.oath.cloud"), globalDnsNames); @@ -282,7 +279,7 @@ public class ControllerTest { "app1--tenant1.global.vespa.oath.cloud", "app1.tenant1.global.vespa.yahooapis.com", "app1--tenant1.global.vespa.yahooapis.com"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(deployment.zone()))); + tester.configServer().containerEndpoints().get(context.deploymentIdIn(deployment.zone()))); } context.flushDnsUpdates(); assertEquals(3, tester.controllerTester().nameService().records().size()); @@ -302,7 +299,7 @@ public class ControllerTest { assertEquals("app1.tenant1.global.vespa.yahooapis.com", record.get().name().asString()); assertEquals("rotation-fqdn-01.", record.get().data().asString()); - List<String> globalDnsNames = tester.controller().routing().readDeclaredEndpointsOf(context.instanceId()) + List<String> globalDnsNames = tester.controller().routing().endpointsOf(context.instanceId()) .scope(Endpoint.Scope.global) .mapToList(Endpoint::dnsName); assertEquals(List.of("app1--tenant1.global.vespa.oath.cloud", @@ -337,7 +334,7 @@ public class ControllerTest { for (Deployment deployment : deployments) { assertEquals("Rotation names are passed to config server in " + deployment.zone(), ZoneId.from("prod.us-west-1").equals(deployment.zone()) ? west : notWest, - tester.configServer().containerEndpointNames(context.deploymentIdIn(deployment.zone()))); + tester.configServer().containerEndpoints().get(context.deploymentIdIn(deployment.zone()))); } context.flushDnsUpdates(); @@ -384,7 +381,7 @@ public class ControllerTest { assertEquals( "Zone " + zone + " is a member of global endpoint", Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(zone)) + tester.configServer().containerEndpoints().get(context.deploymentIdIn(zone)) ); } @@ -402,13 +399,13 @@ public class ControllerTest { assertEquals( "Zone " + zone + " is a member of global endpoint", Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(zone)) + tester.configServer().containerEndpoints().get(context.deploymentIdIn(zone)) ); } assertEquals( "Zone " + east + " is a member of global endpoint", Set.of("rotation-id-02", "east--app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(east)) + tester.configServer().containerEndpoints().get(context.deploymentIdIn(east)) ); // Application is deployed with default endpoint pointing to 3/3 zones @@ -427,7 +424,7 @@ public class ControllerTest { ? Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud", "rotation-id-02", "east--app1--tenant1.global.vespa.oath.cloud") : Set.of("rotation-id-01", "app1--tenant1.global.vespa.oath.cloud"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(zone)) + tester.configServer().containerEndpoints().get(context.deploymentIdIn(zone)) ); } @@ -595,59 +592,6 @@ public class ControllerTest { } @Test - public void testDnsUpdatesForApplicationEndpoint() { - var context = tester.newDeploymentContext("tenant1", "app1", "beta"); - ApplicationPackage applicationPackage = new ApplicationPackageBuilder() - .instances("beta,main") - .region("us-west-1") - .region("us-east-3") - .applicationEndpoint("a", "qrs", "us-west-1", - Map.of(InstanceName.from("beta"), 2, - InstanceName.from("main"), 8)) - .applicationEndpoint("b", "qrs", "us-west-1", - Map.of(InstanceName.from("beta"), 1, - InstanceName.from("main"), 1)) - .applicationEndpoint("c", "qrs", "us-east-3", - Map.of(InstanceName.from("beta"), 4, - InstanceName.from("main"), 6)) - .build(); - context.submit(applicationPackage).deploy(); - - // Endpoint names are passed to each deployment - DeploymentId usWest = context.deploymentIdIn(ZoneId.from("prod", "us-west-1")); - DeploymentId usEast = context.deploymentIdIn(ZoneId.from("prod", "us-east-3")); - Map<DeploymentId, List<String>> deploymentEndpoints = Map.of(usWest, List.of("a--app1--tenant1.us-west-1-r.vespa.oath.cloud", "b--app1--tenant1.us-west-1-r.vespa.oath.cloud"), - usEast, List.of("c--app1--tenant1.us-east-3-r.vespa.oath.cloud")); - deploymentEndpoints.forEach((zone, endpointNames) -> { - assertEquals("Endpoint names are passed to config server in " + zone, - Set.of(new ContainerEndpoint("qrs", "application", - endpointNames)), - tester.configServer().containerEndpoints().get(zone)); - }); - context.flushDnsUpdates(); - - // DNS records are created for each endpoint - Set<Record> records = tester.controllerTester().nameService().records(); - assertEquals(Set.of(new Record(Record.Type.CNAME, - RecordName.from("a--app1--tenant1.us-west-1-r.vespa.oath.cloud"), - RecordData.from("vip.prod.us-west-1.")), - new Record(Record.Type.CNAME, - RecordName.from("b--app1--tenant1.us-west-1-r.vespa.oath.cloud"), - RecordData.from("vip.prod.us-west-1.")), - new Record(Record.Type.CNAME, - RecordName.from("c--app1--tenant1.us-east-3-r.vespa.oath.cloud"), - RecordData.from("vip.prod.us-east-3."))), - records); - List<String> endpointDnsNames = tester.controller().routing().declaredEndpointsOf(context.application()) - .scope(Endpoint.Scope.application) - .mapToList(Endpoint::dnsName); - assertEquals(List.of("a--app1--tenant1.us-west-1-r.vespa.oath.cloud", - "b--app1--tenant1.us-west-1-r.vespa.oath.cloud", - "c--app1--tenant1.us-east-3-r.vespa.oath.cloud"), - endpointDnsNames); - } - - @Test public void testDevDeployment() { ApplicationPackage applicationPackage = new ApplicationPackageBuilder().build(); @@ -666,7 +610,7 @@ public class ControllerTest { assertEquals("DeploymentSpec is not stored", DeploymentSpec.empty, context.application().deploymentSpec()); // Verify zone supports shared layer 4 and shared routing methods - Set<RoutingMethod> routingMethods = tester.controller().routing().readEndpointsOf(context.deploymentIdIn(zone)) + Set<RoutingMethod> routingMethods = tester.controller().routing().endpointsOf(context.deploymentIdIn(zone)) .asList() .stream() .map(Endpoint::routingMethod) @@ -912,12 +856,12 @@ public class ControllerTest { Set.of("application.tenant.global.vespa.oath.cloud", "foo.application.tenant.global.vespa.oath.cloud", "us.application.tenant.global.vespa.oath.cloud"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(zone))); + tester.configServer().containerEndpoints().get(context.deploymentIdIn(zone))); } assertEquals("Expected container endpoints in " + zone3, Set.of("application.tenant.global.vespa.oath.cloud", "foo.application.tenant.global.vespa.oath.cloud"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(zone3))); + tester.configServer().containerEndpoints().get(context.deploymentIdIn(zone3))); } @Test @@ -931,7 +875,7 @@ public class ControllerTest { tester.controllerTester().zoneRegistry() .setRoutingMethod(ZoneApiMock.from(zone1), RoutingMethod.shared, RoutingMethod.sharedLayer4) .setRoutingMethod(ZoneApiMock.from(zone2), RoutingMethod.shared, RoutingMethod.sharedLayer4); - Supplier<Set<RoutingMethod>> routingMethods = () -> tester.controller().routing().readEndpointsOf(context.deploymentIdIn(zone1)) + Supplier<Set<RoutingMethod>> routingMethods = () -> tester.controller().routing().endpointsOf(context.deploymentIdIn(zone1)) .asList() .stream() .map(Endpoint::routingMethod) @@ -955,9 +899,9 @@ public class ControllerTest { assertEquals(Set.of("rotation-id-01", "application.tenant.global.vespa.oath.cloud", "application--tenant.global.vespa.oath.cloud"), - tester.configServer().containerEndpointNames(context.deploymentIdIn(zone))); + tester.configServer().containerEndpoints().get(context.deploymentIdIn(zone))); } - List<String> zoneDnsNames = tester.controller().routing().readEndpointsOf(context.deploymentIdIn(zone1)) + List<String> zoneDnsNames = tester.controller().routing().endpointsOf(context.deploymentIdIn(zone1)) .scope(Endpoint.Scope.zone) .mapToList(Endpoint::dnsName); assertEquals(List.of("application--tenant.us-west-1.vespa.oath.cloud", diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java index a3674fa27bd..37f9b66d5fe 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ConfigServerMock.java @@ -40,8 +40,8 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.TestReport; import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud; import com.yahoo.vespa.hosted.controller.api.integration.noderepository.RestartFilter; import com.yahoo.vespa.hosted.controller.api.integration.secrets.TenantSecretStore; -import com.yahoo.vespa.hosted.controller.application.SystemApplication; import com.yahoo.vespa.hosted.controller.application.pkg.ApplicationPackage; +import com.yahoo.vespa.hosted.controller.application.SystemApplication; import com.yahoo.vespa.serviceview.bindings.ApplicationView; import com.yahoo.vespa.serviceview.bindings.ClusterView; import com.yahoo.vespa.serviceview.bindings.ServiceView; @@ -90,7 +90,7 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer private final Map<ZoneId, Set<LoadBalancer>> loadBalancers = new HashMap<>(); private final Set<Environment> deferLoadBalancerProvisioning = new HashSet<>(); private final Map<DeploymentId, List<Log>> warnings = new HashMap<>(); - private final Map<DeploymentId, Set<ContainerEndpoint>> containerEndpoints = new HashMap<>(); + private final Map<DeploymentId, Set<String>> containerEndpoints = new HashMap<>(); private final Map<DeploymentId, List<ClusterMetrics>> clusterMetrics = new HashMap<>(); private final Map<DeploymentId, TestReport> testReport = new HashMap<>(); private List<ProtonMetrics> protonMetrics; @@ -280,17 +280,10 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer warnings.put(deployment, List.copyOf(logs)); } - public Map<DeploymentId, Set<ContainerEndpoint>> containerEndpoints() { + public Map<DeploymentId, Set<String>> containerEndpoints() { return Collections.unmodifiableMap(containerEndpoints); } - public Set<String> containerEndpointNames(DeploymentId deployment) { - return containerEndpoints.getOrDefault(deployment, Set.of()).stream() - .map(ContainerEndpoint::names) - .flatMap(Collection::stream) - .collect(Collectors.toUnmodifiableSet()); - } - public void setMetrics(DeploymentId deployment, ClusterMetrics clusterMetrics) { setMetrics(deployment, List.of(clusterMetrics)); } @@ -393,7 +386,13 @@ public class ConfigServerMock extends AbstractComponent implements ConfigServer if (nodeRepository().list(id.zoneId(), NodeFilter.all().applications(id.applicationId())).isEmpty()) provision(id.zoneId(), id.applicationId(), cluster); - this.containerEndpoints.put(id, deployment.containerEndpoints()); + this.containerEndpoints.put( + id, + deployment.containerEndpoints().stream() + .map(ContainerEndpoint::names) + .flatMap(Collection::stream) + .collect(Collectors.toSet()) + ); if (!deferLoadBalancerProvisioning.contains(id.zoneId().environment())) { putLoadBalancers(id.zoneId(), List.of(new LoadBalancer(UUID.randomUUID().toString(), 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 23ab91aaf8c..2ef98ec6d2a 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 @@ -230,14 +230,6 @@ public class ZoneRegistryMock extends AbstractComponent implements ZoneRegistry } @Override - public Optional<String> getVipHostname(ZoneId zoneId) { - if (routingMethods(zoneId).stream().anyMatch(RoutingMethod::isShared)) { - return Optional.of("vip." + zoneId.value()); - } - return Optional.empty(); - } - - @Override public Optional<Duration> getDeploymentTimeToLive(ZoneId zoneId) { return Optional.ofNullable(deploymentTimeToLive.get(zoneId)); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java index b767e8a791f..910e5943989 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/rotation/RotationRepositoryTest.java @@ -63,7 +63,7 @@ public class RotationRepositoryTest { assertEquals(List.of(expected.id()), rotationIds(application.instance().rotations())); assertEquals(URI.create("https://app1--tenant1.global.vespa.oath.cloud:4443/"), - tester.controller().routing().readDeclaredEndpointsOf(application.instanceId()).primary().get().url()); + tester.controller().routing().endpointsOf(application.instanceId()).primary().get().url()); try (RotationLock lock = repository.lock()) { List<AssignedRotation> rotations = repository.getOrAssignRotations(application.application().deploymentSpec(), application.instance(), @@ -158,7 +158,7 @@ public class RotationRepositoryTest { application2.submit(applicationPackage); assertEquals(List.of(new RotationId("foo-1")), rotationIds(application2.instance().rotations())); assertEquals("https://cd--app2--tenant2.global.vespa.oath.cloud:4443/", - tester.controller().routing().readDeclaredEndpointsOf(application2.instanceId()).primary().get().url().toString()); + tester.controller().routing().endpointsOf(application2.instanceId()).primary().get().url().toString()); } @Test @@ -174,9 +174,9 @@ public class RotationRepositoryTest { assertEquals(List.of(new RotationId("foo-1")), rotationIds(instance1.instance().rotations())); assertEquals(List.of(new RotationId("foo-2")), rotationIds(instance2.instance().rotations())); assertEquals(URI.create("https://instance1--application1--tenant1.global.vespa.oath.cloud:4443/"), - tester.controller().routing().readDeclaredEndpointsOf(instance1.instanceId()).primary().get().url()); + tester.controller().routing().endpointsOf(instance1.instanceId()).primary().get().url()); assertEquals(URI.create("https://instance2--application1--tenant1.global.vespa.oath.cloud:4443/"), - tester.controller().routing().readDeclaredEndpointsOf(instance2.instanceId()).primary().get().url()); + tester.controller().routing().endpointsOf(instance2.instanceId()).primary().get().url()); } @Test @@ -194,9 +194,9 @@ public class RotationRepositoryTest { assertEquals(List.of(new RotationId("foo-2")), rotationIds(instance2.instance().rotations())); assertEquals(URI.create("https://instance1--application1--tenant1.global.vespa.oath.cloud:4443/"), - tester.controller().routing().readDeclaredEndpointsOf(instance1.instanceId()).primary().get().url()); + tester.controller().routing().endpointsOf(instance1.instanceId()).primary().get().url()); assertEquals(URI.create("https://instance2--application1--tenant1.global.vespa.oath.cloud:4443/"), - tester.controller().routing().readDeclaredEndpointsOf(instance2.instanceId()).primary().get().url()); + tester.controller().routing().endpointsOf(instance2.instanceId()).primary().get().url()); } private void assertSingleRotation(Rotation expected, List<AssignedRotation> assignedRotations, RotationRepository repository) { 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 c777b659461..afcc5e14d82 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 @@ -789,7 +789,7 @@ public class RoutingPoliciesTest { Map.of(betaZone1, 1)); assertTrue("Endpoint removed", tester.controllerTester().controller().routing() - .readDeclaredEndpointsOf(application) + .endpointsOf(application) .named(EndpointId.of("a1")).isEmpty()); } @@ -916,7 +916,7 @@ public class RoutingPoliciesTest { int loadBalancerId, Map<DeploymentId, Integer> deploymentWeights) { Map<String, List<DeploymentId>> deploymentsByDnsName = new HashMap<>(); for (var deployment : deploymentWeights.keySet()) { - EndpointList applicationEndpoints = tester.controller().routing().readDeclaredEndpointsOf(application) + EndpointList applicationEndpoints = tester.controller().routing().endpointsOf(application) .named(endpointId) .targets(deployment) .cluster(cluster); @@ -944,7 +944,7 @@ public class RoutingPoliciesTest { Map<String, List<ZoneId>> zonesByRegionEndpoint = new HashMap<>(); for (var zone : zoneWeights.keySet()) { DeploymentId deployment = new DeploymentId(instance, zone); - EndpointList regionEndpoints = tester.controller().routing().readEndpointsOf(deployment) + EndpointList regionEndpoints = tester.controller().routing().endpointsOf(deployment) .cluster(cluster) .scope(Endpoint.Scope.weighted); Endpoint regionEndpoint = regionEndpoints.first().orElseThrow(() -> new IllegalArgumentException("No region endpoint found for " + cluster + " in " + deployment)); @@ -965,7 +965,7 @@ public class RoutingPoliciesTest { latencyTargets.add(latencyTarget); }); List<DeploymentId> deployments = zoneWeights.keySet().stream().map(z -> new DeploymentId(instance, z)).collect(Collectors.toList()); - String globalEndpoint = tester.controller().routing().readDeclaredEndpointsOf(instance) + String globalEndpoint = tester.controller().routing().endpointsOf(instance) .named(endpointId) .targets(deployments) .primary() |