Search in sources :

Example 6 with MetadataUpgrader

use of org.opensearch.plugins.MetadataUpgrader in project OpenSearch by opensearch-project.

the class GatewayMetaStateTests method testIndexTemplateValidation.

public void testIndexTemplateValidation() {
    Metadata metadata = randomMetadata();
    MetadataUpgrader metadataUpgrader = new MetadataUpgrader(Collections.singletonList(customs -> {
        throw new IllegalStateException("template is incompatible");
    }));
    String message = expectThrows(IllegalStateException.class, () -> GatewayMetaState.upgradeMetadata(metadata, new MockMetadataIndexUpgradeService(false), metadataUpgrader)).getMessage();
    assertThat(message, equalTo("template is incompatible"));
}
Also used : MetadataUpgrader(org.opensearch.plugins.MetadataUpgrader) Arrays(java.util.Arrays) IndexTemplateMetadata(org.opensearch.cluster.metadata.IndexTemplateMetadata) Metadata(org.opensearch.cluster.metadata.Metadata) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) Version(org.opensearch.Version) Settings(org.opensearch.common.settings.Settings) HashMap(java.util.HashMap) TestCustomMetadata(org.opensearch.test.TestCustomMetadata) MetadataIndexUpgradeService(org.opensearch.cluster.metadata.MetadataIndexUpgradeService) Objects(java.util.Objects) List(java.util.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Collections(java.util.Collections) EnumSet(java.util.EnumSet) IndexTemplateMetadata(org.opensearch.cluster.metadata.IndexTemplateMetadata) Metadata(org.opensearch.cluster.metadata.Metadata) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) TestCustomMetadata(org.opensearch.test.TestCustomMetadata) MetadataUpgrader(org.opensearch.plugins.MetadataUpgrader)

Example 7 with MetadataUpgrader

use of org.opensearch.plugins.MetadataUpgrader in project OpenSearch by opensearch-project.

the class GatewayMetaStateTests method testCustomMetadataValidation.

public void testCustomMetadataValidation() {
    Metadata metadata = randomMetadata(new CustomMetadata1("data"));
    MetadataUpgrader metadataUpgrader = new MetadataUpgrader(Collections.emptyList());
    try {
        GatewayMetaState.upgradeMetadata(metadata, new MockMetadataIndexUpgradeService(false), metadataUpgrader);
    } catch (IllegalStateException e) {
        assertThat(e.getMessage(), equalTo("custom meta data too old"));
    }
}
Also used : IndexTemplateMetadata(org.opensearch.cluster.metadata.IndexTemplateMetadata) Metadata(org.opensearch.cluster.metadata.Metadata) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) TestCustomMetadata(org.opensearch.test.TestCustomMetadata) MetadataUpgrader(org.opensearch.plugins.MetadataUpgrader)

Aggregations

IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)7 IndexTemplateMetadata (org.opensearch.cluster.metadata.IndexTemplateMetadata)7 Metadata (org.opensearch.cluster.metadata.Metadata)7 MetadataUpgrader (org.opensearch.plugins.MetadataUpgrader)7 TestCustomMetadata (org.opensearch.test.TestCustomMetadata)7 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 EnumSet (java.util.EnumSet)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Objects (java.util.Objects)3 Matchers.equalTo (org.hamcrest.Matchers.equalTo)3 Version (org.opensearch.Version)3 MetadataIndexUpgradeService (org.opensearch.cluster.metadata.MetadataIndexUpgradeService)3 Settings (org.opensearch.common.settings.Settings)3 OpenSearchTestCase (org.opensearch.test.OpenSearchTestCase)3