Search in sources :

Example 1 with IndicesLifecycle

use of org.elasticsearch.indices.IndicesLifecycle in project crate by crate.

the class BlobIndicesServiceTest method testBlobComponentsAreNotCreatedForNonBlobIndex.

@Test
public void testBlobComponentsAreNotCreatedForNonBlobIndex() throws Exception {
    CompletableFuture<IndicesLifecycle.Listener> listenerFuture = new CompletableFuture<>();
    BlobIndicesService blobIndicesService = new BlobIndicesService(Settings.EMPTY, new NoopClusterService(), new IndicesLifecycle() {

        @Override
        public void addListener(Listener listener) {
            listenerFuture.complete(listener);
        }

        @Override
        public void removeListener(Listener listener) {
        }
    });
    IndicesLifecycle.Listener listener = listenerFuture.get(30, TimeUnit.SECONDS);
    IndexService indexService = mock(IndexService.class);
    when(indexService.index()).thenReturn(new Index("dummy"));
    listener.afterIndexCreated(indexService);
    IndexShard indexShard = mock(IndexShard.class);
    when(indexShard.indexService()).thenReturn(indexService);
    listener.afterIndexShardCreated(indexShard);
    assertThat(blobIndicesService.indices.keySet(), Matchers.empty());
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) IndexService(org.elasticsearch.index.IndexService) IndexShard(org.elasticsearch.index.shard.IndexShard) Index(org.elasticsearch.index.Index) IndicesLifecycle(org.elasticsearch.indices.IndicesLifecycle) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Index (org.elasticsearch.index.Index)1 IndexService (org.elasticsearch.index.IndexService)1 IndexShard (org.elasticsearch.index.shard.IndexShard)1 IndicesLifecycle (org.elasticsearch.indices.IndicesLifecycle)1 NoopClusterService (org.elasticsearch.test.cluster.NoopClusterService)1 Test (org.junit.Test)1