summaryrefslogtreecommitdiffstats
path: root/config-model/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test')
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java6
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java30
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidatorTest.java61
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidatorTest.java16
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java90
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java21
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java41
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java14
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/StructFieldAttributeChangeValidatorTestCase.java53
9 files changed, 189 insertions, 143 deletions
diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
index 1be58564d1b..26d8a9b0eca 100644
--- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
@@ -444,12 +444,14 @@ public class ModelProvisioningTest {
// Check container cluster
assertEquals(1, model.getContainerClusters().size());
- Set<com.yahoo.vespa.model.Host> containerHosts = model.getContainerClusters().get("foo").getContainers().stream().map(Container::getHost).collect(Collectors.toSet());
+ Set<HostResource> containerHosts = model.getContainerClusters().get("foo").getContainers().stream()
+ .map(Container::getHost)
+ .collect(Collectors.toSet());
assertEquals(10, containerHosts.size());
// Check admin clusters
Admin admin = model.getAdmin();
- Set<com.yahoo.vespa.model.Host> slobrokHosts = admin.getSlobroks().stream().map(Slobrok::getHost).collect(Collectors.toSet());
+ Set<HostResource> slobrokHosts = admin.getSlobroks().stream().map(Slobrok::getHost).collect(Collectors.toSet());
assertEquals(3, slobrokHosts.size());
assertTrue("Slobroks are assigned from container nodes", containerHosts.containsAll(slobrokHosts));
assertTrue("Logserver is assigned from container nodes", containerHosts.contains(admin.getLogserver().getHost()));
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java
index 65ac6c7625e..4fd2609eb67 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ConfigChangeTestUtils.java
@@ -4,8 +4,10 @@ package com.yahoo.vespa.model.application.validation.change;
import com.yahoo.config.model.api.ConfigChangeAction;
import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.application.api.ValidationOverrides;
+import com.yahoo.config.provision.ClusterSpec;
import java.time.Instant;
+import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -14,25 +16,25 @@ import static org.junit.Assert.assertThat;
public class ConfigChangeTestUtils {
- public static VespaConfigChangeAction newRestartAction(String message) {
- return new VespaRestartAction(message);
+ public static VespaConfigChangeAction newRestartAction(ClusterSpec.Id id, String message) {
+ return new VespaRestartAction(id, message);
}
- public static VespaConfigChangeAction newRestartAction(String message, List<ServiceInfo> services) {
- return new VespaRestartAction(message, services);
+ public static VespaConfigChangeAction newRestartAction(ClusterSpec.Id id, String message, List<ServiceInfo> services) {
+ return new VespaRestartAction(id, message, services);
}
- public static VespaConfigChangeAction newRefeedAction(String name, String message) {
- return VespaRefeedAction.of(name, ValidationOverrides.empty, message, Instant.now());
+ public static VespaConfigChangeAction newRefeedAction(ClusterSpec.Id id, String name, String message) {
+ return VespaRefeedAction.of(id, name, ValidationOverrides.empty, message, Instant.now());
}
- public static VespaConfigChangeAction newRefeedAction(String name, ValidationOverrides overrides, String message, Instant now) {
- return VespaRefeedAction.of(name, overrides, message, now);
+ public static VespaConfigChangeAction newRefeedAction(ClusterSpec.Id id, String name, ValidationOverrides overrides, String message, Instant now) {
+ return VespaRefeedAction.of(id, name, overrides, message, now);
}
- public static VespaConfigChangeAction newRefeedAction(String name, ValidationOverrides overrides, String message,
+ public static VespaConfigChangeAction newRefeedAction(ClusterSpec.Id id, String name, ValidationOverrides overrides, String message,
List<ServiceInfo> services, String documentType, Instant now) {
- return VespaRefeedAction.of(name, overrides, message, services, documentType, now);
+ return VespaRefeedAction.of(id, name, overrides, message, services, documentType, now);
}
public static List<ConfigChangeAction> normalizeServicesInActions(List<ConfigChangeAction> result) {
@@ -53,9 +55,11 @@ public class ConfigChangeTestUtils {
}
public static void assertEqualActions(List<ConfigChangeAction> exp, List<ConfigChangeAction> act) {
- exp.sort((lhs, rhs) -> lhs.getMessage().compareTo(rhs.getMessage()));
- act.sort((lhs, rhs) -> lhs.getMessage().compareTo(rhs.getMessage()));
- assertThat(act, equalTo(exp));
+ var mutableExp = new ArrayList<>(exp);
+ var mutableAct = new ArrayList<>(act);
+ mutableExp.sort((lhs, rhs) -> lhs.getMessage().compareTo(rhs.getMessage()));
+ mutableAct.sort((lhs, rhs) -> lhs.getMessage().compareTo(rhs.getMessage()));
+ assertThat(mutableAct, equalTo(mutableExp));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidatorTest.java
index 80127ac6854..8d365f24c7f 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidatorTest.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.model.application.validation.change;
import com.yahoo.config.model.api.ConfigChangeAction;
import com.yahoo.config.model.api.ServiceInfo;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.config.application.api.ValidationOverrides;
import com.yahoo.vespa.model.content.utils.ApplicationPackageBuilder;
@@ -11,15 +12,13 @@ import com.yahoo.vespa.model.content.utils.SchemaBuilder;
import org.junit.Test;
import java.time.Instant;
-import java.util.Arrays;
import java.util.List;
import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.assertEqualActions;
import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.newRefeedAction;
import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.newRestartAction;
import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTestUtils.normalizeServicesInActions;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public class IndexedSearchClusterChangeValidatorTest {
@@ -40,9 +39,9 @@ public class IndexedSearchClusterChangeValidatorTest {
public static VespaModel newOneDocModel(String sdContent) {
return new ApplicationPackageBuilder().
- addCluster(new ContentClusterBuilder().name("foo").docTypes("d1")).
- addSchemas(new SchemaBuilder().
- name("d1").content(sdContent).build()).buildCreator().create();
+ addCluster(new ContentClusterBuilder().name("foo").docTypes("d1"))
+ .addSchemas(new SchemaBuilder().name("d1").content(sdContent).build())
+ .buildCreator().create();
}
public static Fixture newTwoDocFixture(String currentSd, String nextSd) {
@@ -51,11 +50,9 @@ public class IndexedSearchClusterChangeValidatorTest {
public static VespaModel newTwoDocModel(String d1Content, String d2Content) {
return new ApplicationPackageBuilder().
- addCluster(new ContentClusterBuilder().name("foo").docTypes("d1", "d2")).
- addSchemas(new SchemaBuilder().
- name("d1").content(d1Content).build()).
- addSchemas(new SchemaBuilder().
- name("d2").content(d2Content).build()).
+ addCluster(new ContentClusterBuilder().name("foo").docTypes("d1", "d2"))
+ .addSchemas(new SchemaBuilder().name("d1").content(d1Content).build())
+ .addSchemas(new SchemaBuilder().name("d2").content(d2Content).build()).
buildCreator().create();
}
@@ -66,25 +63,23 @@ public class IndexedSearchClusterChangeValidatorTest {
public static VespaModel newTwoClusterModel(String d1Content, String d2Content) {
return new ApplicationPackageBuilder().
addCluster(new ContentClusterBuilder().name("foo").docTypes("d1")).
- addCluster(new ContentClusterBuilder().name("bar").docTypes("d2")).
- addSchemas(new SchemaBuilder().
- name("d1").content(d1Content).build()).
- addSchemas(new SchemaBuilder().
- name("d2").content(d2Content).build()).
+ addCluster(new ContentClusterBuilder().name("bar").docTypes("d2"))
+ .addSchemas(new SchemaBuilder().name("d1").content(d1Content).build())
+ .addSchemas(new SchemaBuilder().name("d2").content(d2Content).build()).
buildCreator().create();
}
private List<ConfigChangeAction> validate() {
return normalizeServicesInActions(validator.validate(currentModel, nextModel,
- ValidationOverrides.empty, Instant.now()));
+ ValidationOverrides.empty, Instant.now()));
}
public void assertValidation() {
- assertThat(validate().size(), is(0));
+ assertTrue(validate().isEmpty());
}
public void assertValidation(ConfigChangeAction exp) {
- assertValidation(Arrays.asList(exp));
+ assertValidation(List.of(exp));
}
public void assertValidation(List<ConfigChangeAction> exp) {
@@ -97,31 +92,34 @@ public class IndexedSearchClusterChangeValidatorTest {
static String ATTRIBUTE_CHANGE_MSG = "Field 'f1' changed: add attribute aspect";
static String INT_FIELD = "field f1 type int { indexing: summary }";
static String FIELD_TYPE_CHANGE_MSG = "Field 'f1' changed: data type: 'string' -> 'int'";
- private static List<ServiceInfo> FOO_SERVICE = Arrays.asList(
+ private static final List<ServiceInfo> FOO_SERVICE = List.of(
new ServiceInfo("searchnode", "null", null, null, "foo/search/cluster.foo/0", "null"));
- private static List<ServiceInfo> BAR_SERVICE = Arrays.asList(
+ private static final List<ServiceInfo> BAR_SERVICE = List.of(
new ServiceInfo("searchnode2", "null", null, null, "bar/search/cluster.bar/0", "null"));
@Test
public void requireThatDocumentDatabaseChangeIsDiscovered() {
Fixture.newOneDocFixture(STRING_FIELD, ATTRIBUTE_FIELD).
- assertValidation(newRestartAction("Document type 'd1': " + ATTRIBUTE_CHANGE_MSG, FOO_SERVICE));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Document type 'd1': " + ATTRIBUTE_CHANGE_MSG, FOO_SERVICE));
}
@Test
public void requireThatChangeInSeveralDocumentDatabasesAreDiscovered() {
Fixture.newTwoDocFixture(STRING_FIELD, ATTRIBUTE_FIELD).
- assertValidation(Arrays.asList(newRestartAction("Document type 'd1': "
- + ATTRIBUTE_CHANGE_MSG, FOO_SERVICE),
- newRestartAction("Document type 'd2': " + ATTRIBUTE_CHANGE_MSG, FOO_SERVICE)));
+ assertValidation(List.of(newRestartAction(ClusterSpec.Id.from("test"),
+ "Document type 'd1': " + ATTRIBUTE_CHANGE_MSG, FOO_SERVICE),
+ newRestartAction(ClusterSpec.Id.from("test"),
+ "Document type 'd2': " + ATTRIBUTE_CHANGE_MSG, FOO_SERVICE)));
}
@Test
public void requireThatChangeInSeveralContentClustersAreDiscovered() {
Fixture.newTwoClusterFixture(STRING_FIELD, ATTRIBUTE_FIELD).
- assertValidation(Arrays.asList(newRestartAction("Document type 'd1': "
- + ATTRIBUTE_CHANGE_MSG, FOO_SERVICE),
- newRestartAction("Document type 'd2': " + ATTRIBUTE_CHANGE_MSG, BAR_SERVICE)));
+ assertValidation(List.of(newRestartAction(ClusterSpec.Id.from("test"),
+ "Document type 'd1': " + ATTRIBUTE_CHANGE_MSG, FOO_SERVICE),
+ newRestartAction(ClusterSpec.Id.from("test"),
+ "Document type 'd2': " + ATTRIBUTE_CHANGE_MSG, BAR_SERVICE)));
}
@Test
@@ -147,9 +145,10 @@ public class IndexedSearchClusterChangeValidatorTest {
@Test
public void requireThatChangingFieldTypeIsDiscovered() {
Fixture f = Fixture.newOneDocFixture(STRING_FIELD, INT_FIELD);
- f.assertValidation(Arrays.asList(newRefeedAction("field-type-change",
- ValidationOverrides.empty,
- "Document type 'd1': " + FIELD_TYPE_CHANGE_MSG, FOO_SERVICE, "d1", Instant.now())));
+ f.assertValidation(List.of(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
+ ValidationOverrides.empty,
+ "Document type 'd1': " + FIELD_TYPE_CHANGE_MSG, FOO_SERVICE, "d1", Instant.now())));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidatorTest.java
index 8edbc964bfb..f5ef50ee3a4 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidatorTest.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.model.application.validation.change;
import com.yahoo.config.model.api.ConfigChangeAction;
import com.yahoo.config.model.api.ServiceInfo;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.config.application.api.ValidationOverrides;
import com.yahoo.vespa.model.content.utils.ApplicationPackageBuilder;
@@ -162,18 +163,23 @@ public class StreamingSearchClusterChangeValidatorTest {
}
private static VespaConfigChangeAction createFieldTypeChangeRefeedAction(String docType, List<ServiceInfo> service) {
- return ConfigChangeTestUtils.newRefeedAction("field-type-change",
- ValidationOverrides.empty,
+ return ConfigChangeTestUtils.newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
+ ValidationOverrides.empty,
"Document type '" + docType + "': Field 'f1' changed: data type: 'string' -> 'int'",
- service, docType, Instant.now());
+ service, docType, Instant.now());
}
private static VespaConfigChangeAction createAddFastAccessRestartAction() {
- return ConfigChangeTestUtils.newRestartAction("Document type 'd1': Field 'f1' changed: add fast-access attribute", FOO_SERVICE);
+ return ConfigChangeTestUtils.newRestartAction(ClusterSpec.Id.from("test"),
+ "Document type 'd1': Field 'f1' changed: add fast-access attribute",
+ FOO_SERVICE);
}
private static VespaConfigChangeAction createRemoveFastAccessRestartAction() {
- return ConfigChangeTestUtils.newRestartAction("Document type 'd1': Field 'f1' changed: remove fast-access attribute", FOO_SERVICE);
+ return ConfigChangeTestUtils.newRestartAction(ClusterSpec.Id.from("test"),
+ "Document type 'd1': Field 'f1' changed: remove fast-access attribute",
+ FOO_SERVICE);
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java
index e00b34d4a79..168ee797fbf 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/AttributeChangeValidatorTest.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.model.application.validation.change.search;
import com.yahoo.config.application.api.ValidationOverrides;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.model.application.validation.change.VespaConfigChangeAction;
import org.junit.Test;
@@ -18,12 +19,13 @@ public class AttributeChangeValidatorTest {
public Fixture(String currentSd, String nextSd) throws Exception {
super(currentSd, nextSd);
- validator = new AttributeChangeValidator(currentDb().getDerivedConfiguration().getAttributeFields(),
- currentDb().getDerivedConfiguration().getIndexSchema(),
- currentDocType(),
- nextDb().getDerivedConfiguration().getAttributeFields(),
- nextDb().getDerivedConfiguration().getIndexSchema(),
- nextDocType());
+ validator = new AttributeChangeValidator(ClusterSpec.Id.from("test"),
+ currentDb().getDerivedConfiguration().getAttributeFields(),
+ currentDb().getDerivedConfiguration().getIndexSchema(),
+ currentDocType(),
+ nextDb().getDerivedConfiguration().getAttributeFields(),
+ nextDb().getDerivedConfiguration().getIndexSchema(),
+ nextDocType());
}
@Override
@@ -37,16 +39,16 @@ public class AttributeChangeValidatorTest {
public void adding_attribute_aspect_require_restart() throws Exception {
Fixture f = new Fixture("field f1 type string { indexing: summary }",
"field f1 type string { indexing: attribute | summary }");
- f.assertValidation(newRestartAction(
- "Field 'f1' changed: add attribute aspect"));
+ f.assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: add attribute aspect"));
}
@Test
public void removing_attribute_aspect_require_restart() throws Exception {
Fixture f = new Fixture("field f1 type string { indexing: attribute | summary }",
"field f1 type string { indexing: summary }");
- f.assertValidation(newRestartAction(
- "Field 'f1' changed: remove attribute aspect"));
+ f.assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: remove attribute aspect"));
}
@Test
@@ -65,24 +67,24 @@ public class AttributeChangeValidatorTest {
public void changing_fast_search_require_restart() throws Exception {
new Fixture("field f1 type string { indexing: attribute }",
"field f1 type string { indexing: attribute \n attribute: fast-search }").
- assertValidation(newRestartAction(
- "Field 'f1' changed: add attribute 'fast-search'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: add attribute 'fast-search'"));
}
@Test
public void changing_fast_access_require_restart() throws Exception {
new Fixture("field f1 type string { indexing: attribute \n attribute: fast-access }",
"field f1 type string { indexing: attribute }").
- assertValidation(newRestartAction(
- "Field 'f1' changed: remove attribute 'fast-access'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: remove attribute 'fast-access'"));
}
@Test
public void changing_huge_require_restart() throws Exception {
new Fixture("field f1 type string { indexing: attribute }",
"field f1 type string { indexing: attribute \n attribute: huge }").
- assertValidation(newRestartAction(
- "Field 'f1' changed: add attribute 'huge'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: add attribute 'huge'"));
}
@Test
@@ -90,8 +92,8 @@ public class AttributeChangeValidatorTest {
new Fixture(
"field f1 type predicate { indexing: attribute \n index { arity: 8 \n dense-posting-list-threshold: 0.2 } }",
"field f1 type predicate { indexing: attribute \n index { arity: 8 \n dense-posting-list-threshold: 0.4 } }").
- assertValidation(newRestartAction(
- "Field 'f1' changed: change property 'dense-posting-list-threshold' from '0.2' to '0.4'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: change property 'dense-posting-list-threshold' from '0.2' to '0.4'"));
}
@Test
@@ -113,18 +115,18 @@ public class AttributeChangeValidatorTest {
new Fixture(
"field f1 type tensor(x[2]) { indexing: attribute }",
"field f1 type tensor(x[3]) { indexing: attribute }")
- .assertValidation(newRefeedAction(
- "tensor-type-change",
- ValidationOverrides.empty,
- "Field 'f1' changed: tensor type: 'tensor(x[2])' -> 'tensor(x[3])'", Instant.now()));
+ .assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "tensor-type-change",
+ ValidationOverrides.empty,
+ "Field 'f1' changed: tensor type: 'tensor(x[2])' -> 'tensor(x[3])'", Instant.now()));
new Fixture(
"field f1 type tensor(x[5]) { indexing: attribute }",
"field f1 type tensor(x[3]) { indexing: attribute }")
- .assertValidation(newRefeedAction(
- "tensor-type-change",
- ValidationOverrides.empty,
- "Field 'f1' changed: tensor type: 'tensor(x[5])' -> 'tensor(x[3])'", Instant.now()));
+ .assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "tensor-type-change",
+ ValidationOverrides.empty,
+ "Field 'f1' changed: tensor type: 'tensor(x[5])' -> 'tensor(x[3])'", Instant.now()));
}
@Test
@@ -139,32 +141,32 @@ public class AttributeChangeValidatorTest {
public void adding_rank_filter_requires_restart() throws Exception {
new Fixture("field f1 type string { indexing: attribute }",
"field f1 type string { indexing: attribute \n rank: filter }").
- assertValidation(newRestartAction(
- "Field 'f1' changed: add attribute 'rank: filter'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: add attribute 'rank: filter'"));
}
@Test
public void removing_rank_filter_requires_restart() throws Exception {
new Fixture("field f1 type string { indexing: attribute \n rank: filter }",
"field f1 type string { indexing: attribute }").
- assertValidation(newRestartAction(
- "Field 'f1' changed: remove attribute 'rank: filter'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: remove attribute 'rank: filter'"));
}
@Test
public void adding_hnsw_index_requires_restart() throws Exception {
new Fixture("field f1 type tensor(x[2]) { indexing: attribute }",
"field f1 type tensor(x[2]) { indexing: attribute | index \n index { hnsw } }").
- assertValidation(newRestartAction(
- "Field 'f1' changed: add attribute 'indexing: index'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: add attribute 'indexing: index'"));
}
@Test
public void removing_hnsw_index_requres_restart() throws Exception {
new Fixture("field f1 type tensor(x[2]) { indexing: attribute | index \n index { hnsw } }",
"field f1 type tensor(x[2]) { indexing: attribute }").
- assertValidation(newRestartAction(
- "Field 'f1' changed: remove attribute 'indexing: index'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: remove attribute 'indexing: index'"));
}
@Test
@@ -172,8 +174,9 @@ public class AttributeChangeValidatorTest {
new Fixture("field f1 type tensor(x[2]) { indexing: attribute }",
"field f1 type tensor(x[2]) { indexing: attribute \n attribute { " +
"distance-metric: geodegrees \n } }").
- assertValidation(newRestartAction("Field 'f1' changed: change property " +
- "'distance-metric' from 'EUCLIDEAN' to 'GEODEGREES'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: change property " +
+ "'distance-metric' from 'EUCLIDEAN' to 'GEODEGREES'"));
}
@Test
@@ -181,8 +184,9 @@ public class AttributeChangeValidatorTest {
new Fixture("field f1 type tensor(x[2]) { indexing: attribute | index \n index { hnsw } }",
"field f1 type tensor(x[2]) { indexing: attribute | index \n attribute { " +
"distance-metric: geodegrees \n } }").
- assertValidation(newRestartAction("Field 'f1' changed: change property " +
- "'distance-metric' from 'EUCLIDEAN' to 'GEODEGREES'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: change property " +
+ "'distance-metric' from 'EUCLIDEAN' to 'GEODEGREES'"));
}
@Test
@@ -190,8 +194,9 @@ public class AttributeChangeValidatorTest {
new Fixture("field f1 type tensor(x[2]) { indexing: attribute | index \n index { hnsw } }",
"field f1 type tensor(x[2]) { indexing: attribute | index \n index { " +
"hnsw { max-links-per-node: 4 } } }").
- assertValidation(newRestartAction("Field 'f1' changed: change hnsw index property " +
- "'max-links-per-node' from '16' to '4'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: change hnsw index property " +
+ "'max-links-per-node' from '16' to '4'"));
}
@Test
@@ -199,7 +204,8 @@ public class AttributeChangeValidatorTest {
new Fixture("field f1 type tensor(x[2]) { indexing: attribute | index \n index { hnsw } }",
"field f1 type tensor(x[2]) { indexing: attribute | index \n index { " +
"hnsw { neighbors-to-explore-at-insert: 100 } } }").
- assertValidation(newRestartAction("Field 'f1' changed: change hnsw index property " +
- "'neighbors-to-explore-at-insert' from '200' to '100'"));
+ assertValidation(newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: change hnsw index property " +
+ "'neighbors-to-explore-at-insert' from '200' to '100'"));
}
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java
index c24b5250a5d..60b17142340 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentDatabaseChangeValidatorTest.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.model.application.validation.change.search;
import com.yahoo.config.application.api.ValidationOverrides;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.model.application.validation.change.VespaConfigChangeAction;
import org.junit.Test;
@@ -19,7 +20,11 @@ public class DocumentDatabaseChangeValidatorTest {
public Fixture(String currentSd, String nextSd) throws Exception {
super(currentSd, nextSd);
- validator = new DocumentDatabaseChangeValidator(currentDb(), currentDocType(), nextDb(), nextDocType());
+ validator = new DocumentDatabaseChangeValidator(ClusterSpec.Id.from("test"),
+ currentDb(),
+ currentDocType(),
+ nextDb(),
+ nextDocType());
}
@Override
@@ -42,13 +47,17 @@ public class DocumentDatabaseChangeValidatorTest {
"field f3 type string { indexing: summary } " +
"field f4 type array<s> { struct-field s1 { indexing: attribute } }");
f.assertValidation(Arrays.asList(
- newRestartAction("Field 'f1' changed: add attribute aspect"),
- newRestartAction("Field 'f4.s1' changed: add attribute aspect"),
- newRefeedAction("indexing-change",
+ newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f1' changed: add attribute aspect"),
+ newRestartAction(ClusterSpec.Id.from("test"),
+ "Field 'f4.s1' changed: add attribute aspect"),
+ newRefeedAction(ClusterSpec.Id.from("test"),
+ "indexing-change",
ValidationOverrides.empty,
"Field 'f2' changed: add index aspect, indexing script: '{ input f2 | summary f2; }' -> " +
"'{ input f2 | tokenize normalize stem:\"BEST\" | index f2 | summary f2; }'", Instant.now()),
- newRefeedAction("field-type-change",
+ newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f3' changed: data type: 'int' -> 'string'", Instant.now())));
}
@@ -56,7 +65,7 @@ public class DocumentDatabaseChangeValidatorTest {
@Test
public void requireThatRemovingAttributeAspectFromIndexFieldIsOk() throws Exception {
Fixture f = new Fixture("field f1 type string { indexing: index | attribute }",
- "field f1 type string { indexing: index }");
+ "field f1 type string { indexing: index }");
f.assertValidation();
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java
index 4bba66f0fb3..190c2c8c645 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation.change.search;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.document.DocumentType;
import com.yahoo.document.Field;
import com.yahoo.document.ReferenceDataType;
@@ -34,7 +35,9 @@ public class DocumentTypeChangeValidatorTest {
public Fixture(String currentSd, String nextSd) throws Exception {
super(currentSd, nextSd);
- validator = new DocumentTypeChangeValidator(currentDocType(), nextDocType());
+ validator = new DocumentTypeChangeValidator(ClusterSpec.Id.from("test"),
+ currentDocType(),
+ nextDocType());
}
@Override
@@ -62,7 +65,8 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatDataTypeChangeIsNotOK() throws Exception {
Fixture f = new Fixture("field f1 type string { indexing: summary }",
"field f1 type int { indexing: summary }");
- f.assertValidation(newRefeedAction("field-type-change",
+ f.assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f1' changed: data type: 'string' -> 'int'",
Instant.now()));
@@ -72,7 +76,8 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatAddingCollectionTypeIsNotOK() throws Exception {
Fixture f = new Fixture("field f1 type string { indexing: summary }",
"field f1 type array<string> { indexing: summary }");
- f.assertValidation(newRefeedAction("field-type-change",
+ f.assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f1' changed: data type: 'string' -> 'Array<string>'", Instant.now()));
}
@@ -89,7 +94,8 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatNestedDataTypeChangeIsNotOK() throws Exception {
Fixture f = new Fixture("field f1 type array<string> { indexing: summary }",
"field f1 type array<int> { indexing: summary }");
- f.assertValidation(newRefeedAction("field-type-change",
+ f.assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f1' changed: data type: 'Array<string>' -> 'Array<int>'", Instant.now()));
}
@@ -98,7 +104,8 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatChangedCollectionTypeIsNotOK() throws Exception {
Fixture f = new Fixture("field f1 type array<string> { indexing: summary }",
"field f1 type weightedset<string> { indexing: summary }");
- f.assertValidation(newRefeedAction("field-type-change",
+ f.assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f1' changed: data type: 'Array<string>' -> 'WeightedSet<string>'", Instant.now()));
}
@@ -107,10 +114,12 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatMultipleDataTypeChangesIsNotOK() throws Exception {
Fixture f = new Fixture("field f1 type string { indexing: summary } field f2 type int { indexing: summary }" ,
"field f2 type string { indexing: summary } field f1 type int { indexing: summary }");
- f.assertValidation(Arrays.asList(newRefeedAction("field-type-change",
+ f.assertValidation(Arrays.asList(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f1' changed: data type: 'string' -> 'int'", Instant.now()),
- newRefeedAction("field-type-change",
+ newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f2' changed: data type: 'int' -> 'string'", Instant.now())));
}
@@ -147,7 +156,8 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatDataTypeChangeInStructFieldIsNotOK() throws Exception {
Fixture f = new Fixture("struct s1 { field f1 type string {} } field f2 type s1 { indexing: summary }",
"struct s1 { field f1 type int {} } field f2 type s1 { indexing: summary }");
- f.assertValidation(newRefeedAction("field-type-change",
+ f.assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f2' changed: data type: 's1:{f1:string}' -> 's1:{f1:int}'", Instant.now()));
}
@@ -156,7 +166,8 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatNestedDataTypeChangeInStructFieldIsNotOK() throws Exception {
Fixture f = new Fixture("struct s1 { field f1 type array<string> {} } field f2 type s1 { indexing: summary }",
"struct s1 { field f1 type array<int> {} } field f2 type s1 { indexing: summary }");
- f.assertValidation(newRefeedAction("field-type-change",
+ f.assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f2' changed: data type: 's1:{f1:Array<string>}' -> 's1:{f1:Array<int>}'", Instant.now()));
}
@@ -165,7 +176,8 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatDataTypeChangeInNestedStructFieldIsNotOK() throws Exception {
Fixture f = new Fixture("struct s1 { field f1 type string {} } struct s2 { field f2 type s1 {} } field f3 type s2 { indexing: summary }",
"struct s1 { field f1 type int {} } struct s2 { field f2 type s1 {} } field f3 type s2 { indexing: summary }");
- f.assertValidation(newRefeedAction("field-type-change",
+ f.assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f3' changed: data type: 's2:{s1:{f1:string}}' -> 's2:{s1:{f1:int}}'", Instant.now()));
}
@@ -174,16 +186,17 @@ public class DocumentTypeChangeValidatorTest {
public void requireThatMultipleDataTypeChangesInStructFieldIsNotOK() throws Exception {
Fixture f = new Fixture("struct s1 { field f1 type string {} field f2 type int {} } field f3 type s1 { indexing: summary }",
"struct s1 { field f1 type int {} field f2 type string {} } field f3 type s1 { indexing: summary }");
- f.assertValidation(newRefeedAction("field-type-change",
+ f.assertValidation(newRefeedAction(ClusterSpec.Id.from("test"),
+ "field-type-change",
ValidationOverrides.empty,
"Field 'f3' changed: data type: 's1:{f1:string,f2:int}' -> 's1:{f1:int,f2:string}'", Instant.now()));
}
@Test
public void requireThatChangingTargetTypeOfReferenceFieldIsNotOK() {
- DocumentTypeChangeValidator validator = new DocumentTypeChangeValidator(
- createDocumentTypeWithReferenceField("oldDoc"),
- createDocumentTypeWithReferenceField("newDoc"));
+ var validator = new DocumentTypeChangeValidator(ClusterSpec.Id.from("test"),
+ createDocumentTypeWithReferenceField("oldDoc"),
+ createDocumentTypeWithReferenceField("newDoc"));
List<VespaConfigChangeAction> result = validator.validate(ValidationOverrides.empty, Instant.now());
assertEquals(1, result.size());
VespaConfigChangeAction action = result.get(0);
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java
index 7a5b235737a..8ffd02a4381 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidatorTest.java
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation.change.search;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression;
import com.yahoo.config.application.api.ValidationOverrides;
import com.yahoo.vespa.model.application.validation.change.VespaConfigChangeAction;
@@ -20,8 +21,9 @@ public class IndexingScriptChangeValidatorTest {
public Fixture(String currentSd, String nextSd) throws Exception {
super(currentSd, nextSd);
- validator = new IndexingScriptChangeValidator(currentDb().getDerivedConfiguration().getSearch(),
- nextDb().getDerivedConfiguration().getSearch());
+ validator = new IndexingScriptChangeValidator(ClusterSpec.Id.from("test"),
+ currentDb().getDerivedConfiguration().getSearch(),
+ nextDb().getDerivedConfiguration().getSearch());
}
@Override
@@ -31,6 +33,7 @@ public class IndexingScriptChangeValidatorTest {
}
private static class ScriptFixture {
+
private final ScriptExpression currentScript;
private final ScriptExpression nextScript;
@@ -44,15 +47,16 @@ public class IndexingScriptChangeValidatorTest {
}
}
- private static String FIELD = "field f1 type string";
- private static String FIELD_F2 = "field f2 type string";
+ private static final String FIELD = "field f1 type string";
+ private static final String FIELD_F2 = "field f2 type string";
private static VespaConfigChangeAction expectedAction(String changedMsg, String fromScript, String toScript) {
return expectedAction("f1", changedMsg, fromScript, toScript);
}
private static VespaConfigChangeAction expectedAction(String field, String changedMsg, String fromScript, String toScript) {
- return VespaRefeedAction.of("indexing-change",
+ return VespaRefeedAction.of(ClusterSpec.Id.from("test"),
+ "indexing-change",
ValidationOverrides.empty,
"Field '" + field + "' changed: " +
(changedMsg.isEmpty() ? "" : changedMsg + ", ") +
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/StructFieldAttributeChangeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/StructFieldAttributeChangeValidatorTestCase.java
index 2d68284c9a5..04efffab438 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/StructFieldAttributeChangeValidatorTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/StructFieldAttributeChangeValidatorTestCase.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.model.application.validation.change.search;
import com.yahoo.config.application.api.ValidationOverrides;
+import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.model.application.validation.change.VespaConfigChangeAction;
import org.junit.Test;
@@ -17,16 +18,18 @@ import static com.yahoo.vespa.model.application.validation.change.ConfigChangeTe
public class StructFieldAttributeChangeValidatorTestCase {
private static class Fixture extends ContentClusterFixture {
- private StructFieldAttributeChangeValidator structFieldAttributeValidator;
- private DocumentTypeChangeValidator docTypeValidator;
+
+ private final StructFieldAttributeChangeValidator structFieldAttributeValidator;
+ private final DocumentTypeChangeValidator docTypeValidator;
public Fixture(String currentSd, String nextSd) throws Exception {
super(currentSd, nextSd);
- structFieldAttributeValidator = new StructFieldAttributeChangeValidator(currentDocType(),
- currentDb().getDerivedConfiguration().getAttributeFields(),
- nextDocType(),
- nextDb().getDerivedConfiguration().getAttributeFields());
- docTypeValidator = new DocumentTypeChangeValidator(currentDocType(), nextDocType());
+ structFieldAttributeValidator = new StructFieldAttributeChangeValidator(ClusterSpec.Id.from("test"),
+ currentDocType(),
+ currentDb().getDerivedConfiguration().getAttributeFields(),
+ nextDocType(),
+ nextDb().getDerivedConfiguration().getAttributeFields());
+ docTypeValidator = new DocumentTypeChangeValidator(ClusterSpec.Id.from("test"), currentDocType(), nextDocType());
}
@Override
@@ -49,34 +52,34 @@ public class StructFieldAttributeChangeValidatorTestCase {
@Test
public void adding_attribute_aspect_to_struct_field_requires_restart() throws Exception {
validate(arrayOfStruct(oneFieldStruct(), ""),
- arrayOfStruct(oneFieldStruct(), structAttribute("s1")),
- newRestartAction("Field 'f1.s1' changed: add attribute aspect"));
+ arrayOfStruct(oneFieldStruct(), structAttribute("s1")),
+ newRestartAction(ClusterSpec.Id.from("test"), "Field 'f1.s1' changed: add attribute aspect"));
validate(mapOfStruct(oneFieldStruct(), ""),
- mapOfStruct(oneFieldStruct(), structAttribute("key")),
- newRestartAction("Field 'f1.key' changed: add attribute aspect"));
+ mapOfStruct(oneFieldStruct(), structAttribute("key")),
+ newRestartAction(ClusterSpec.Id.from("test"), "Field 'f1.key' changed: add attribute aspect"));
validate(mapOfStruct(oneFieldStruct(), ""),
- mapOfStruct(oneFieldStruct(), structAttribute("value.s1")),
- newRestartAction("Field 'f1.value.s1' changed: add attribute aspect"));
+ mapOfStruct(oneFieldStruct(), structAttribute("value.s1")),
+ newRestartAction(ClusterSpec.Id.from("test"), "Field 'f1.value.s1' changed: add attribute aspect"));
validate(mapOfPrimitive(""), mapOfPrimitive(structAttribute("key")),
- newRestartAction("Field 'f1.key' changed: add attribute aspect"));
+ newRestartAction(ClusterSpec.Id.from("test"), "Field 'f1.key' changed: add attribute aspect"));
validate(mapOfPrimitive(""), mapOfPrimitive(structAttribute("value")),
- newRestartAction("Field 'f1.value' changed: add attribute aspect"));
+ newRestartAction(ClusterSpec.Id.from("test"), "Field 'f1.value' changed: add attribute aspect"));
}
@Test
public void removing_attribute_aspect_from_struct_field_is_ok() throws Exception {
validate(arrayOfStruct(oneFieldStruct(), structAttribute("s1")),
- arrayOfStruct(oneFieldStruct(), ""));
+ arrayOfStruct(oneFieldStruct(), ""));
validate(mapOfStruct(oneFieldStruct(), structAttribute("key")),
- mapOfStruct(oneFieldStruct(), ""));
+ mapOfStruct(oneFieldStruct(), ""));
validate(mapOfStruct(oneFieldStruct(), structAttribute("value.s1")),
- mapOfStruct(oneFieldStruct(), ""));
+ mapOfStruct(oneFieldStruct(), ""));
validate(mapOfPrimitive(structAttribute("key")), mapOfPrimitive(""));
@@ -89,34 +92,34 @@ public class StructFieldAttributeChangeValidatorTestCase {
arrayOfStruct(twoFieldStruct(), structAttribute("s2")));
validate(mapOfStruct(oneFieldStruct(), ""),
- mapOfStruct(twoFieldStruct(), structAttribute("value.s2")));
+ mapOfStruct(twoFieldStruct(), structAttribute("value.s2")));
}
@Test
public void removing_struct_field_with_attribute_aspect_is_ok() throws Exception {
validate(arrayOfStruct(twoFieldStruct(), structAttribute("s2")),
- arrayOfStruct(oneFieldStruct(), ""));
+ arrayOfStruct(oneFieldStruct(), ""));
validate(mapOfStruct(twoFieldStruct(), structAttribute("value.s2")),
- mapOfStruct(oneFieldStruct(), ""));
+ mapOfStruct(oneFieldStruct(), ""));
}
@Test
public void adding_struct_field_without_attribute_aspect_is_ok() throws Exception {
validate(arrayOfStruct(oneFieldStruct(), ""),
- arrayOfStruct(twoFieldStruct(), ""));
+ arrayOfStruct(twoFieldStruct(), ""));
validate(mapOfStruct(oneFieldStruct(), ""),
- mapOfStruct(twoFieldStruct(), ""));
+ mapOfStruct(twoFieldStruct(), ""));
}
@Test
public void removing_struct_field_without_attribute_aspect_is_ok() throws Exception {
validate(arrayOfStruct(twoFieldStruct(), ""),
- arrayOfStruct(oneFieldStruct(), ""));
+ arrayOfStruct(oneFieldStruct(), ""));
validate(mapOfStruct(twoFieldStruct(), ""),
- mapOfStruct(oneFieldStruct(), ""));
+ mapOfStruct(oneFieldStruct(), ""));
}
private static String oneFieldStruct() {