summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo')
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java59
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java15
2 files changed, 74 insertions, 0 deletions
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
index 53456c627a4..a003e0122a5 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
@@ -12,6 +12,7 @@ import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.config.content.core.StorDistributormanagerConfig;
import com.yahoo.vespa.config.content.StorFilestorConfig;
import com.yahoo.vespa.config.content.core.StorServerConfig;
+import com.yahoo.vespa.config.content.AllClustersBucketSpacesConfig;
import com.yahoo.vespa.config.content.FleetcontrollerConfig;
import com.yahoo.vespa.config.content.StorDistributionConfig;
import com.yahoo.metrics.MetricsmanagerConfig;
@@ -29,6 +30,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -823,6 +825,63 @@ public class ContentClusterTest extends ContentBaseTest {
new VespaModelCreatorWithMockPkg(null, xml, sds).create();
}
+ private void assertClusterHasBucketSpaceMappings(AllClustersBucketSpacesConfig config, String clusterId,
+ List<String> defaultSpaceTypes, List<String> globalSpaceTypes) {
+ AllClustersBucketSpacesConfig.Cluster cluster = config.cluster(clusterId);
+ assertNotNull(cluster);
+ assertEquals(defaultSpaceTypes.size() + globalSpaceTypes.size(), cluster.documentType().size());
+ assertClusterHasTypesInBucketSpace(cluster, "default", defaultSpaceTypes);
+ assertClusterHasTypesInBucketSpace(cluster, "global", globalSpaceTypes);
+ }
+
+ private void assertClusterHasTypesInBucketSpace(AllClustersBucketSpacesConfig.Cluster cluster,
+ String bucketSpace, List<String> expectedTypes) {
+ for (String type : expectedTypes) {
+ assertNotNull(cluster.documentType(type));
+ assertEquals(bucketSpace, cluster.documentType(type).bucketSpace());
+ }
+ }
+
+ @Test
+ public void all_clusters_bucket_spaces_config_contains_mappings_across_all_clusters() {
+ String xml =
+ "<services>" +
+ "<admin version=\"2.0\">" +
+ " <adminserver hostalias=\"node0\"/>" +
+ "</admin>" +
+ "<content version=\"1.0\" id=\"foocluster\">" +
+ " <redundancy>1</redundancy>" +
+ " <documents>" +
+ " <document type=\"bunnies\" mode=\"index\"/>" +
+ " <document type=\"hares\" mode=\"index\"/>" +
+ " </documents>" +
+ " <group>" +
+ " <node distribution-key=\"0\" hostalias=\"node0\"/>" +
+ " </group>" +
+ "</content>" +
+ "<content version=\"1.0\" id=\"barcluster\">" +
+ " <redundancy>1</redundancy>" +
+ " <documents>" +
+ " <document type=\"rabbits\" mode=\"index\" global=\"true\"/>" +
+ " </documents>" +
+ " <group>" +
+ " <node distribution-key=\"0\" hostalias=\"node0\"/>" +
+ " </group>" +
+ "</content>" +
+ "</services>";
+ List<String> sds = ApplicationPackageUtils.generateSearchDefinitions("bunnies", "hares", "rabbits");
+ VespaModel model = new VespaModelCreatorWithMockPkg(getHosts(), xml, sds).create();
+
+ AllClustersBucketSpacesConfig.Builder builder = new AllClustersBucketSpacesConfig.Builder();
+ model.getConfig(builder, "client");
+ AllClustersBucketSpacesConfig config = builder.build();
+
+ assertEquals(2, config.cluster().size());
+
+ assertClusterHasBucketSpaceMappings(config, "foocluster", Arrays.asList("bunnies", "hares"), Collections.emptyList());
+ assertClusterHasBucketSpaceMappings(config, "barcluster", Collections.emptyList(), Collections.singletonList("rabbits"));
+ }
+
private ContentCluster createWithZone(String clusterXml, Zone zone) throws Exception {
DeployState.Builder deployStateBuilder = new DeployState.Builder()
.zone(zone)
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java
index 83b4cfebca5..98fa179b219 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentSearchClusterTest.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.model.content;
import com.yahoo.vespa.config.content.FleetcontrollerConfig;
+import com.yahoo.vespa.config.content.AllClustersBucketSpacesConfig;
import com.yahoo.vespa.config.content.core.BucketspacesConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.vespa.model.content.cluster.ContentCluster;
@@ -19,6 +20,7 @@ import static com.yahoo.vespa.model.content.utils.ContentClusterUtils.createClus
import static com.yahoo.vespa.model.content.utils.SearchDefinitionBuilder.createSearchDefinitions;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
@@ -168,6 +170,19 @@ public class ContentSearchClusterTest {
}
@Test
+ public void bucket_space_config_builder_returns_correct_mappings() throws Exception {
+ ContentCluster cluster = createClusterWithGlobalType();
+ BucketspacesConfig expected = getBucketspacesConfig(cluster);
+ AllClustersBucketSpacesConfig.Cluster actual = cluster.clusterBucketSpaceConfigBuilder().build();
+ assertEquals(2, expected.documenttype().size());
+ assertEquals(expected.documenttype().size(), actual.documentType().size());
+ assertNotNull(actual.documentType("global"));
+ assertEquals("global", actual.documentType().get("global").bucketSpace());
+ assertNotNull(actual.documentType("regular"));
+ assertEquals("default", actual.documentType().get("regular").bucketSpace());
+ }
+
+ @Test
public void cluster_with_global_document_types_sets_cluster_controller_global_docs_config_option() throws Exception {
ContentCluster cluster = createClusterWithGlobalType();
assertTrue(getFleetcontrollerConfig(cluster).cluster_has_global_document_types());