Search in sources :

Example 1 with Index

use of org.opensearch.cluster.metadata.IndexAbstraction.Index in project OpenSearch by opensearch-project.

the class TransportBulkActionTests method testOnlySystem.

public void testOnlySystem() {
    SortedMap<String, IndexAbstraction> indicesLookup = new TreeMap<>();
    Settings settings = Settings.builder().put("index.version.created", Version.CURRENT).build();
    indicesLookup.put(".foo", new Index(IndexMetadata.builder(".foo").settings(settings).system(true).numberOfShards(1).numberOfReplicas(0).build()));
    indicesLookup.put(".bar", new Index(IndexMetadata.builder(".bar").settings(settings).system(true).numberOfShards(1).numberOfReplicas(0).build()));
    SystemIndices systemIndices = new SystemIndices(singletonMap("plugin", singletonList(new SystemIndexDescriptor(".test", ""))));
    List<String> onlySystem = Arrays.asList(".foo", ".bar");
    assertTrue(bulkAction.isOnlySystem(buildBulkRequest(onlySystem), indicesLookup, systemIndices));
    onlySystem = Arrays.asList(".foo", ".bar", ".test");
    assertTrue(bulkAction.isOnlySystem(buildBulkRequest(onlySystem), indicesLookup, systemIndices));
    List<String> nonSystem = Arrays.asList("foo", "bar");
    assertFalse(bulkAction.isOnlySystem(buildBulkRequest(nonSystem), indicesLookup, systemIndices));
    List<String> mixed = Arrays.asList(".foo", ".test", "other");
    assertFalse(bulkAction.isOnlySystem(buildBulkRequest(mixed), indicesLookup, systemIndices));
}
Also used : IndexAbstraction(org.opensearch.cluster.metadata.IndexAbstraction) SystemIndexDescriptor(org.opensearch.indices.SystemIndexDescriptor) Index(org.opensearch.cluster.metadata.IndexAbstraction.Index) AutoCreateIndex(org.opensearch.action.support.AutoCreateIndex) TreeMap(java.util.TreeMap) SystemIndices(org.opensearch.indices.SystemIndices) Settings(org.opensearch.common.settings.Settings)

Example 2 with Index

use of org.opensearch.cluster.metadata.IndexAbstraction.Index in project OpenSearch by opensearch-project.

the class TransportBulkActionTests method testIncludesSystem.

public void testIncludesSystem() {
    SortedMap<String, IndexAbstraction> indicesLookup = new TreeMap<>();
    Settings settings = Settings.builder().put("index.version.created", Version.CURRENT).build();
    indicesLookup.put(".foo", new Index(IndexMetadata.builder(".foo").settings(settings).system(true).numberOfShards(1).numberOfReplicas(0).build()));
    indicesLookup.put(".bar", new Index(IndexMetadata.builder(".bar").settings(settings).system(true).numberOfShards(1).numberOfReplicas(0).build()));
    SystemIndices systemIndices = new SystemIndices(org.opensearch.common.collect.Map.of("plugin", org.opensearch.common.collect.List.of(new SystemIndexDescriptor(".test", ""))));
    List<String> onlySystem = org.opensearch.common.collect.List.of(".foo", ".bar");
    assertTrue(bulkAction.includesSystem(buildBulkRequest(onlySystem), indicesLookup, systemIndices));
    onlySystem = org.opensearch.common.collect.List.of(".foo", ".bar", ".test");
    assertTrue(bulkAction.includesSystem(buildBulkRequest(onlySystem), indicesLookup, systemIndices));
    List<String> nonSystem = org.opensearch.common.collect.List.of("foo", "bar");
    assertFalse(bulkAction.includesSystem(buildBulkRequest(nonSystem), indicesLookup, systemIndices));
    List<String> mixed = org.opensearch.common.collect.List.of(".foo", ".test", "other");
    assertTrue(bulkAction.includesSystem(buildBulkRequest(mixed), indicesLookup, systemIndices));
}
Also used : IndexAbstraction(org.opensearch.cluster.metadata.IndexAbstraction) SystemIndexDescriptor(org.opensearch.indices.SystemIndexDescriptor) Index(org.opensearch.cluster.metadata.IndexAbstraction.Index) AutoCreateIndex(org.opensearch.action.support.AutoCreateIndex) TreeMap(java.util.TreeMap) SystemIndices(org.opensearch.indices.SystemIndices) Settings(org.opensearch.common.settings.Settings)

Aggregations

TreeMap (java.util.TreeMap)2 AutoCreateIndex (org.opensearch.action.support.AutoCreateIndex)2 IndexAbstraction (org.opensearch.cluster.metadata.IndexAbstraction)2 Index (org.opensearch.cluster.metadata.IndexAbstraction.Index)2 Settings (org.opensearch.common.settings.Settings)2 SystemIndexDescriptor (org.opensearch.indices.SystemIndexDescriptor)2 SystemIndices (org.opensearch.indices.SystemIndices)2