diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-07-27 12:21:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-27 12:21:14 +0200 |
commit | 2921d5bc1358b094db2e131970c969dcad481502 (patch) | |
tree | 2ffff84602408dd610cc27b56bcca024ad33ccbf /config-model/src/test/java | |
parent | 2b43a46817cc779dccedd82ea8460802367a448a (diff) |
Revert "Remove global-service-id"
Diffstat (limited to 'config-model/src/test/java')
5 files changed, 83 insertions, 25 deletions
diff --git a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java index e975421002e..c00b2846021 100644 --- a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.model; +import com.google.common.io.Files; import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.UnparsedConfigDefinition; @@ -34,12 +35,7 @@ import java.util.Map; import java.util.Set; import java.util.jar.JarEntry; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.*; public class ApplicationDeployTest { @@ -198,7 +194,7 @@ public class ApplicationDeployTest { void testThatAppWithInvalidParallelDeploymentFails() throws IOException { String expectedMessage = """ 4: <staging/> - 5: <prod> + 5: <prod global-service-id="query"> 6: <parallel> 7: <instance id="hello" /> 8: </parallel> diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/DeploymentSpecValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/DeploymentSpecValidatorTest.java index 9ce853ad0f2..dba8205c0e7 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/DeploymentSpecValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/DeploymentSpecValidatorTest.java @@ -19,12 +19,25 @@ import static org.junit.jupiter.api.Assertions.fail; public class DeploymentSpecValidatorTest { @Test + void testDeploymentWithNonExistentGlobalId() { + var deploymentXml = "<?xml version='1.0' encoding='UTF-8'?>" + + "<deployment version='1.0'>" + + " <test />" + + " <prod global-service-id='non-existing'>" + + " <region active='true'>us-east</region>" + + " </prod>" + + "</deployment>"; + assertValidationError("Attribute 'globalServiceId' in instance default: 'non-existing' specified in " + + "deployment.xml does not match any container cluster ID", deploymentXml); + } + + @Test void testEndpointNonExistentContainerId() { var deploymentXml = "<?xml version='1.0' encoding='UTF-8'?>" + "<deployment version='1.0'>" + " <test />" + " <prod>" + - " <region>us-east</region>" + + " <region active='true'>us-east</region>" + " </prod>" + " <endpoints>" + " <endpoint container-id='non-existing'/>" + diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java index 94d98f526a0..f0c39ecc920 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java @@ -790,6 +790,42 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase { } } + @Test + void logs_deployment_spec_deprecations() throws Exception { + String containerService = joinLines("<container id='foo' version='1.0'>", + " <nodes>", + " <node hostalias='host1' />", + " </nodes>", + "</container>"); + String deploymentXml = joinLines("<deployment version='1.0'>", + " <prod global-service-id='foo'>", + " <region active='true'>us-east-1</region>", + " </prod>", + "</deployment>"); + + ApplicationPackage applicationPackage = new MockApplicationPackage.Builder() + .withServices(containerService) + .withDeploymentSpec(deploymentXml) + .build(); + + TestLogger logger = new TestLogger(); + DeployState deployState = new DeployState.Builder() + .applicationPackage(applicationPackage) + .zone(new Zone(Environment.prod, RegionName.from("us-east-1"))) + .properties(new TestProperties().setHostedVespa(true)) + .deployLogger(logger) + .build(); + + createModel(root, deployState, null, DomBuilderTest.parse(containerService)); + assertFalse(logger.msgs.isEmpty()); + assertEquals(Level.WARNING, logger.msgs.get(0).getFirst()); + assertEquals(Level.WARNING, logger.msgs.get(1).getFirst()); + assertEquals("Element 'prod' contains attribute 'global-service-id' deprecated since major version 7. See https://cloud.vespa.ai/en/reference/routing#deprecated-syntax", + logger.msgs.get(0).getSecond()); + assertEquals("Element 'region' contains attribute 'active' deprecated since major version 7. See https://cloud.vespa.ai/en/reference/routing#deprecated-syntax", + logger.msgs.get(1).getSecond()); + } + private void assertComponentConfigured(ApplicationContainer container, String id) { assertTrue(container.getComponents().getComponents().stream().anyMatch(component -> id.equals(component.getComponentId().getName()))); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/IdentityBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/IdentityBuilderTest.java index 08877b3d3a9..78269d00cf3 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/IdentityBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/IdentityBuilderTest.java @@ -24,7 +24,7 @@ public class IdentityBuilderTest extends ContainerModelBuilderTestBase { String deploymentXml = "<deployment version='1.0' athenz-domain='domain' athenz-service='service'>\n" + " <test/>\n" + " <prod>\n" + - " <region>default</region>\n" + + " <region active='true'>default</region>\n" + " </prod>\n" + "</deployment>\n"; diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/RoutingBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/RoutingBuilderTest.java index 2bf50103b10..58b9462978f 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/RoutingBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/RoutingBuilderTest.java @@ -10,12 +10,14 @@ import com.yahoo.config.model.test.MockRoot; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.Zone; -import com.yahoo.vespa.model.container.ApplicationContainer; import com.yahoo.vespa.model.container.ApplicationContainerCluster; +import com.yahoo.vespa.model.container.ApplicationContainer; import org.junit.jupiter.api.Test; import org.w3c.dom.Element; +import org.xml.sax.SAXException; -import java.util.List; +import java.io.IOException; +import java.util.Arrays; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -25,32 +27,43 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class RoutingBuilderTest extends ContainerModelBuilderTestBase { @Test - void setsRotationActive() { + void setsRotationActiveAccordingToDeploymentSpec() throws IOException, SAXException { Element clusterElem = DomBuilderTest.parse( "<container id='default' version='1.0'><search /></container>"); - String deploymentSpec = """ - <deployment> - <prod> - <region>us-north-1</region> - <parallel> - <region>us-north-2</region> - <region>us-north-3</region> - </parallel> - <region>us-north-4</region> - </prod> - </deployment>"""; + String deploymentSpec = "<deployment>\n" + + " <prod> \n" + + " <region active='true'>us-north-1</region>\n" + + " <parallel>\n" + + " <region active='false'>us-north-2</region>\n" + + " <region active='true'>us-north-3</region>\n" + + " </parallel>\n" + + " <region active='false'>us-north-4</region>\n" + + " </prod>\n" + + "</deployment>"; ApplicationPackage applicationPackage = new MockApplicationPackage.Builder() .withDeploymentSpec(deploymentSpec) .build(); - - for (String region : List.of("us-north-1", "us-north-2", "us-north-3", "us-north-4")) { + //root = new MockRoot("root", applicationPackage); + for (String region : Arrays.asList("us-north-1", "us-north-3")) { ApplicationContainer container = getContainer(applicationPackage, region, clusterElem); + assertEquals("true", container.getServicePropertyString("activeRotation"), "Region " + region + " is active"); } + for (String region : Arrays.asList("us-north-2", "us-north-4")) { + ApplicationContainer container = getContainer(applicationPackage, region, clusterElem); + + assertEquals("false", + container.getServicePropertyString("activeRotation"), + "Region " + region + " is inactive"); + } + ApplicationContainer container = getContainer(applicationPackage, "unknown", clusterElem); + assertEquals("false", + container.getServicePropertyString("activeRotation"), + "Unknown region is inactive"); } |