use of org.elasticsearch.cluster.metadata.IndexTemplateMetaData in project crate by crate.
the class IndexTemplateUpgraderTest method testArchivedSettingsAreRemovedOnPartitionedTableTemplates.
@Test
public void testArchivedSettingsAreRemovedOnPartitionedTableTemplates() {
IndexTemplateUpgrader upgrader = new IndexTemplateUpgrader();
Settings settings = Settings.builder().put(ARCHIVED_SETTINGS_PREFIX + "some.setting", // archived, must be filtered out
true).put(SETTING_NUMBER_OF_SHARDS, 4).build();
HashMap<String, IndexTemplateMetadata> templates = new HashMap<>();
String partitionTemplateName = PartitionName.templateName("doc", "t1");
IndexTemplateMetadata oldPartitionTemplate = IndexTemplateMetadata.builder(partitionTemplateName).settings(settings).patterns(Collections.singletonList("*")).build();
templates.put(partitionTemplateName, oldPartitionTemplate);
String nonPartitionTemplateName = "non-partition-template";
IndexTemplateMetadata oldNonPartitionTemplate = IndexTemplateMetadata.builder(nonPartitionTemplateName).settings(settings).patterns(Collections.singletonList("*")).build();
templates.put(nonPartitionTemplateName, oldNonPartitionTemplate);
Map<String, IndexTemplateMetadata> upgradedTemplates = upgrader.apply(templates);
IndexTemplateMetadata upgradedTemplate = upgradedTemplates.get(partitionTemplateName);
assertThat(upgradedTemplate.settings().keySet(), contains(SETTING_NUMBER_OF_SHARDS));
// ensure all other attributes remains the same
assertThat(upgradedTemplate.mappings(), is(oldPartitionTemplate.mappings()));
assertThat(upgradedTemplate.patterns(), is(oldPartitionTemplate.patterns()));
assertThat(upgradedTemplate.order(), is(oldPartitionTemplate.order()));
assertThat(upgradedTemplate.aliases(), is(oldPartitionTemplate.aliases()));
// ensure non partitioned table templates are untouched
assertThat(upgradedTemplates.get(nonPartitionTemplateName), is(oldNonPartitionTemplate));
}
use of org.elasticsearch.cluster.metadata.IndexTemplateMetaData in project crate by crate.
the class IndexTemplateUpgraderTest method testDefaultTemplateIsUpgraded.
@Test
public void testDefaultTemplateIsUpgraded() throws IOException {
IndexTemplateUpgrader upgrader = new IndexTemplateUpgrader();
HashMap<String, IndexTemplateMetadata> templates = new HashMap<>();
IndexTemplateMetadata oldTemplate = IndexTemplateMetadata.builder(TEMPLATE_NAME).patterns(Collections.singletonList("*")).build();
templates.put(TEMPLATE_NAME, oldTemplate);
Map<String, IndexTemplateMetadata> upgradedTemplates = upgrader.apply(templates);
assertThat(upgradedTemplates.get(TEMPLATE_NAME), Matchers.nullValue());
}
use of org.elasticsearch.cluster.metadata.IndexTemplateMetaData in project crate by crate.
the class GatewayMetaStateTests method randomMetadataWithIndexTemplates.
private static Metadata randomMetadataWithIndexTemplates(String... templates) {
Metadata.Builder builder = Metadata.builder();
for (String template : templates) {
IndexTemplateMetadata templateMetadata = IndexTemplateMetadata.builder(template).settings(settings(Version.CURRENT).put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), randomIntBetween(0, 3)).put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5))).patterns(randomIndexPatterns()).build();
builder.put(templateMetadata);
}
for (int i = 0; i < randomIntBetween(1, 5); i++) {
builder.put(IndexMetadata.builder(randomAlphaOfLength(10)).settings(settings(Version.CURRENT)).numberOfReplicas(randomIntBetween(0, 3)).numberOfShards(randomIntBetween(1, 5)));
}
return builder.build();
}
use of org.elasticsearch.cluster.metadata.IndexTemplateMetaData in project crate by crate.
the class ElasticsearchAssertions method assertIndexTemplateMissing.
/**
* Assert that an index template is missing
*/
public static void assertIndexTemplateMissing(GetIndexTemplatesResponse templatesResponse, String name) {
List<String> templateNames = new ArrayList<>();
for (IndexTemplateMetadata indexTemplateMetadata : templatesResponse.getIndexTemplates()) {
templateNames.add(indexTemplateMetadata.name());
}
assertThat(templateNames, not(hasItem(name)));
}
Aggregations