summaryrefslogtreecommitdiffstats
path: root/config-model-api
diff options
context:
space:
mode:
Diffstat (limited to 'config-model-api')
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java11
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java14
-rw-r--r--config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java24
-rw-r--r--config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java22
-rw-r--r--config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java13
5 files changed, 71 insertions, 13 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java
index 68f27a21ce4..48a675fa182 100644
--- a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java
+++ b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java
@@ -45,6 +45,7 @@ import java.util.stream.Stream;
*/
public class DeploymentSpecXmlReader {
+ private static final String deploymentTag = "deployment";
private static final String instanceTag = "instance";
private static final String majorVersionTag = "major-version";
private static final String testTag = "test";
@@ -93,6 +94,9 @@ public class DeploymentSpecXmlReader {
/** Reads a deployment spec from XML */
public DeploymentSpec read(String xmlForm) {
Element root = XML.getDocument(xmlForm).getDocumentElement();
+ if ( ! root.getTagName().equals(deploymentTag))
+ throw new IllegalArgumentException("The root tag must be <deployment>");
+
if (isEmptySpec(root))
return DeploymentSpec.empty;
@@ -133,6 +137,13 @@ public class DeploymentSpecXmlReader {
Element instanceTag,
MutableOptional<String> globalServiceId,
Element parentTag) {
+ if (instanceNameString.isBlank())
+ throw new IllegalArgumentException("<instance> attribute 'id' must be specified, and not be blank");
+
+ // If this is an absolutely empty instance, or the implicit "default" instance but without content, ignore it
+ if (XML.getChildren(instanceTag).isEmpty() && (instanceTag.getAttributes().getLength() == 0 || instanceTag == parentTag))
+ return List.of();
+
if (validate)
validateTagOrder(instanceTag);
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
index bc22e90d229..2911eae8d83 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
@@ -13,6 +13,7 @@ import com.yahoo.config.provision.Zone;
import java.io.File;
import java.net.URI;
+import java.time.Duration;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -61,8 +62,8 @@ public interface ModelContext {
// TODO: Only needed for LbServicesProducerTest
default boolean useDedicatedNodeForLogserver() { return true; }
- // TODO Revisit in May or June 2020
- boolean useAdaptiveDispatch();
+ // TODO Remove when 7.225 is last
+ default boolean useAdaptiveDispatch() { return true; }
default Optional<EndpointCertificateSecrets> endpointCertificateSecrets() { return Optional.empty(); }
@@ -81,8 +82,10 @@ public interface ModelContext {
// TODO Revisit in May or June 2020
double defaultSoftStartSeconds();
- // TODO Revisit in May or June 2020
- double defaultTopKProbability();
+ // TODO Remove when 7.225 is last
+ default double defaultTopKProbability() {
+ return 0.9999;
+ }
boolean useDistributorBtreeDb();
@@ -95,6 +98,9 @@ public interface ModelContext {
default boolean useDedicatedNodesWhenUnspecified() { return true; }
Optional<ApplicationRoles> applicationRoles();
+
+ // TODO(bjorncs): Temporary feature flag, revisit July 2020
+ default Duration jdiscHealthCheckProxyClientTimeout() { return Duration.ofSeconds(1); }
}
}
diff --git a/config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java b/config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java
index b7ae6d9dcdf..5b0b11b88b7 100644
--- a/config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java
+++ b/config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java
@@ -6,16 +6,25 @@ import com.yahoo.path.Path;
import com.yahoo.vespa.config.util.ConfigUtils;
import org.junit.Test;
-import java.io.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.StringReader;
import java.util.List;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
*/
public abstract class ApplicationFileTest {
+
protected void writeAppTo(File destFolder) throws IOException {
createFiles(destFolder, "vespa-services.xml", "vespa-hosts.xml");
createFolders(destFolder, "searchdefinitions", "components", "files", "templates");
@@ -34,7 +43,7 @@ public abstract class ApplicationFileTest {
private void createFiles(File destFolder, String ... names) throws IOException {
for (String name : names) {
File f = new File(destFolder, name);
- f.createNewFile();
+ assertTrue(f.createNewFile());
IOUtils.writeFile(f, "foo", false);
}
}
@@ -61,11 +70,11 @@ public abstract class ApplicationFileTest {
ApplicationFile f1 = getApplicationFile(p1);
ApplicationFile f2 = getApplicationFile(p2);
- assertTrue(f1.equals(f1));
- assertFalse(f1.equals(f2));
+ assertEquals(f1, f1);
+ assertNotEquals(f1, f2);
- assertFalse(f2.equals(f1));
- assertTrue(f2.equals(f2));
+ assertNotEquals(f2, f1);
+ assertEquals(f2, f2);
}
@Test
@@ -315,4 +324,5 @@ public abstract class ApplicationFileTest {
}
public abstract ApplicationFile getApplicationFile(Path path) throws Exception;
+
}
diff --git a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java
index 32d903786dc..a793630c8b9 100644
--- a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java
+++ b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecTest.java
@@ -3,6 +3,7 @@ package com.yahoo.config.application.api;
import com.google.common.collect.ImmutableSet;
import com.yahoo.config.provision.Environment;
+import com.yahoo.config.provision.InstanceName;
import com.yahoo.config.provision.RegionName;
import org.junit.Test;
@@ -422,6 +423,23 @@ public class DeploymentSpecTest {
}
@Test
+ public void testOnlyAthenzServiceDefinedInInstance() {
+ StringReader r = new StringReader(
+ "<deployment athenz-domain='domain'>" +
+ " <instance id='default' athenz-service='service' />" +
+ "</deployment>"
+ );
+ DeploymentSpec spec = DeploymentSpec.fromXml(r);
+
+ assertEquals("domain", spec.athenzDomain().get().value());
+ assertEquals(1, spec.instances().size());
+
+ DeploymentInstanceSpec instance = spec.instances().get(0);
+ assertEquals("default", instance.name().value());
+ assertEquals("service", instance.athenzService(Environment.prod, RegionName.defaultName()).get().value());
+ }
+
+ @Test
public void productionSpecWithParallelDeployments() {
StringReader r = new StringReader(
"<deployment>" +
@@ -652,7 +670,7 @@ public class DeploymentSpecTest {
public void deploymentSpecWithIncreasinglyStrictUpgradePoliciesInParallel() {
StringReader r = new StringReader(
"<deployment version='1.0'>" +
- " <instance />" +
+ " <instance id='instance0'/>" +
" <parallel>" +
" <instance id='instance1'>" +
" <upgrade policy='conservative'/>" +
@@ -678,7 +696,7 @@ public class DeploymentSpecTest {
" <upgrade policy='canary'/>" +
" </instance>" +
" </parallel>" +
- " <instance />" +
+ " <instance id='instance3'/>" +
"</deployment>"
);
DeploymentSpec.fromXml(r);
diff --git a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java
index 4a7ef7b43f7..89972773e1c 100644
--- a/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java
+++ b/config-model-api/src/test/java/com/yahoo/config/application/api/DeploymentSpecWithoutInstanceTest.java
@@ -3,6 +3,7 @@ package com.yahoo.config.application.api;
import com.google.common.collect.ImmutableSet;
import com.yahoo.config.provision.Environment;
+import com.yahoo.config.provision.InstanceName;
import com.yahoo.config.provision.RegionName;
import org.junit.Test;
@@ -326,6 +327,18 @@ public class DeploymentSpecWithoutInstanceTest {
}
@Test
+ public void testOnlyAthenzServiceDefined() {
+ StringReader r = new StringReader(
+ "<deployment athenz-domain='domain' athenz-service='service'>" +
+ "</deployment>"
+ );
+ DeploymentSpec spec = DeploymentSpec.fromXml(r);
+
+ assertEquals("domain", spec.athenzDomain().get().value());
+ assertEquals(List.of(), spec.instances());
+ }
+
+ @Test
public void productionSpecWithParallelDeployments() {
StringReader r = new StringReader(
"<deployment>\n" +