Search in sources :

Example 1 with ClearIndicesCacheResponse

use of org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse in project fesen-httpclient by codelibs.

the class Elasticsearch7ClientTest method test_clear_cache_indices.

@Test
void test_clear_cache_indices() throws Exception {
    final String index = "test_clear_cache_indices";
    CountDownLatch latch = new CountDownLatch(1);
    client.admin().indices().prepareCreate(index).execute().actionGet();
    client.admin().indices().prepareClearCache(index).execute(wrap(res -> {
        assertTrue(res.getFailedShards() == 0);
        latch.countDown();
    }, e -> {
        e.printStackTrace();
        try {
            fail();
        } finally {
            latch.countDown();
        }
    }));
    latch.await();
    {
        ClearIndicesCacheResponse clearIndicesCacheResponse = client.admin().indices().prepareClearCache(index).execute().actionGet();
        assertTrue(clearIndicesCacheResponse.getFailedShards() == 0);
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ImmutableOpenMap(org.opensearch.common.collect.ImmutableOpenMap) MultiGetResponse(org.opensearch.action.get.MultiGetResponse) DockerImageName(org.testcontainers.utility.DockerImageName) IndexResponse(org.opensearch.action.index.IndexResponse) SimpleFormatter(java.util.logging.SimpleFormatter) ToXContent(org.opensearch.common.xcontent.ToXContent) ClusterRerouteAction(org.opensearch.action.admin.cluster.reroute.ClusterRerouteAction) ByteSizeUnit(org.opensearch.common.unit.ByteSizeUnit) ClusterRerouteRequest(org.opensearch.action.admin.cluster.reroute.ClusterRerouteRequest) ShrinkAction(org.opensearch.action.admin.indices.shrink.ShrinkAction) AfterAll(org.junit.jupiter.api.AfterAll) CloseIndexResponse(org.opensearch.action.admin.indices.close.CloseIndexResponse) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Alias(org.opensearch.action.admin.indices.alias.Alias) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) XContentFactory(org.opensearch.common.xcontent.XContentFactory) SearchRequestBuilder(org.opensearch.action.search.SearchRequestBuilder) GetResponse(org.opensearch.action.get.GetResponse) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings) PendingClusterTasksResponse(org.opensearch.action.admin.cluster.tasks.PendingClusterTasksResponse) TimeValue(org.opensearch.common.unit.TimeValue) GetPipelineResponse(org.opensearch.action.ingest.GetPipelineResponse) SearchHit(org.opensearch.search.SearchHit) GetMappingsResponse(org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse) Result(org.opensearch.action.DocWriteResponse.Result) RolloverResponse(org.opensearch.action.admin.indices.rollover.RolloverResponse) Settings(org.opensearch.common.settings.Settings) Logger(java.util.logging.Logger) RestStatus(org.opensearch.rest.RestStatus) StandardCharsets(java.nio.charset.StandardCharsets) MultiSearchResponse(org.opensearch.action.search.MultiSearchResponse) Test(org.junit.jupiter.api.Test) ValidateQueryResponse(org.opensearch.action.admin.indices.validate.query.ValidateQueryResponse) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterHealthResponse(org.opensearch.action.admin.cluster.health.ClusterHealthResponse) GetIndexResponse(org.opensearch.action.admin.indices.get.GetIndexResponse) GetFieldMappingsResponse(org.opensearch.action.admin.indices.mapping.get.GetFieldMappingsResponse) BytesArray(org.opensearch.common.bytes.BytesArray) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) GetStoredScriptResponse(org.opensearch.action.admin.cluster.storedscripts.GetStoredScriptResponse) RefreshResponse(org.opensearch.action.admin.indices.refresh.RefreshResponse) ResizeResponse(org.opensearch.action.admin.indices.shrink.ResizeResponse) ActionListener.wrap(org.opensearch.action.ActionListener.wrap) XContentType(org.opensearch.common.xcontent.XContentType) CurlResponse(org.codelibs.curl.CurlResponse) RefreshPolicy(org.opensearch.action.support.WriteRequest.RefreshPolicy) Assertions.fail(org.junit.jupiter.api.Assertions.fail) FlushResponse(org.opensearch.action.admin.indices.flush.FlushResponse) MappingMetadata(org.opensearch.cluster.metadata.MappingMetadata) ResizeRequest(org.opensearch.action.admin.indices.shrink.ResizeRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BytesReference(org.opensearch.common.bytes.BytesReference) UpdateResponse(org.opensearch.action.update.UpdateResponse) FieldCapabilitiesResponse(org.opensearch.action.fieldcaps.FieldCapabilitiesResponse) BulkRequestBuilder(org.opensearch.action.bulk.BulkRequestBuilder) Level(java.util.logging.Level) ClusterUpdateSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) AnalyzeAction(org.opensearch.action.admin.indices.analyze.AnalyzeAction) DeleteResponse(org.opensearch.action.delete.DeleteResponse) AliasesExistResponse(org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse) ClearScrollResponse(org.opensearch.action.search.ClearScrollResponse) GenericContainer(org.testcontainers.containers.GenericContainer) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SearchResponse(org.opensearch.action.search.SearchResponse) SyncedFlushResponse(org.opensearch.action.admin.indices.flush.SyncedFlushResponse) OutputStream(java.io.OutputStream) QueryBuilders(org.opensearch.index.query.QueryBuilders) ExplainResponse(org.opensearch.action.explain.ExplainResponse) FieldCapabilities(org.opensearch.action.fieldcaps.FieldCapabilities) GetAliasesResponse(org.opensearch.action.admin.indices.alias.get.GetAliasesResponse) MainAction(org.opensearch.action.main.MainAction) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) CreateIndexResponse(org.opensearch.action.admin.indices.create.CreateIndexResponse) ForceMergeResponse(org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse) MainRequest(org.opensearch.action.main.MainRequest) GetSettingsResponse(org.opensearch.action.admin.indices.settings.get.GetSettingsResponse) Curl(org.codelibs.curl.Curl) AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) XContentHelper(org.opensearch.common.xcontent.XContentHelper) AfterEach(org.junit.jupiter.api.AfterEach) OpenIndexResponse(org.opensearch.action.admin.indices.open.OpenIndexResponse) BulkResponse(org.opensearch.action.bulk.BulkResponse) MainResponse(org.opensearch.action.main.MainResponse) NodesStatsResponse(org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse) HttpNodesStatsAction(org.codelibs.fesen.client.action.HttpNodesStatsAction) ConsoleHandler(java.util.logging.ConsoleHandler) IndicesExistsResponse(org.opensearch.action.admin.indices.exists.indices.IndicesExistsResponse) MultiGetRequestBuilder(org.opensearch.action.get.MultiGetRequestBuilder) ClearIndicesCacheResponse(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) MultiGetRequest(org.opensearch.action.get.MultiGetRequest) ClearIndicesCacheResponse(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.jupiter.api.Test)

Example 2 with ClearIndicesCacheResponse

use of org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse in project OpenSearch by opensearch-project.

the class DocumentActionsIT method testIndexActions.

public void testIndexActions() throws Exception {
    createIndex();
    NumShards numShards = getNumShards(getConcreteIndexName());
    logger.info("Running Cluster Health");
    ensureGreen();
    logger.info("Indexing [type1/1]");
    IndexResponse indexResponse = client().prepareIndex().setIndex("test").setId("1").setSource(source("1", "test")).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get();
    assertThat(indexResponse.getIndex(), equalTo(getConcreteIndexName()));
    assertThat(indexResponse.getId(), equalTo("1"));
    logger.info("Refreshing");
    RefreshResponse refreshResponse = refresh();
    assertThat(refreshResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
    logger.info("--> index exists?");
    assertThat(indexExists(getConcreteIndexName()), equalTo(true));
    logger.info("--> index exists?, fake index");
    assertThat(indexExists("test1234565"), equalTo(false));
    logger.info("Clearing cache");
    ClearIndicesCacheResponse clearIndicesCacheResponse = client().admin().indices().clearCache(clearIndicesCacheRequest("test").fieldDataCache(true).queryCache(true)).actionGet();
    assertNoFailures(clearIndicesCacheResponse);
    assertThat(clearIndicesCacheResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
    logger.info("Force Merging");
    waitForRelocation(ClusterHealthStatus.GREEN);
    ForceMergeResponse mergeResponse = forceMerge();
    assertThat(mergeResponse.getSuccessfulShards(), equalTo(numShards.totalNumShards));
    GetResponse getResult;
    logger.info("Get [type1/1]");
    for (int i = 0; i < 5; i++) {
        getResult = client().prepareGet("test", "1").execute().actionGet();
        assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
        assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test"))));
        assertThat("cycle(map) #" + i, (String) getResult.getSourceAsMap().get("name"), equalTo("test"));
        getResult = client().get(getRequest("test").id("1")).actionGet();
        assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test"))));
        assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
    }
    logger.info("Get [type1/1] with script");
    for (int i = 0; i < 5; i++) {
        getResult = client().prepareGet("test", "1").setStoredFields("name").execute().actionGet();
        assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
        assertThat(getResult.isExists(), equalTo(true));
        assertThat(getResult.getSourceAsBytes(), nullValue());
        assertThat(getResult.getField("name").getValues().get(0).toString(), equalTo("test"));
    }
    logger.info("Get [type1/2] (should be empty)");
    for (int i = 0; i < 5; i++) {
        getResult = client().get(getRequest("test").id("2")).actionGet();
        assertThat(getResult.isExists(), equalTo(false));
    }
    logger.info("Delete [type1/1]");
    DeleteResponse deleteResponse = client().prepareDelete("test", "1").execute().actionGet();
    assertThat(deleteResponse.getIndex(), equalTo(getConcreteIndexName()));
    assertThat(deleteResponse.getId(), equalTo("1"));
    logger.info("Refreshing");
    client().admin().indices().refresh(refreshRequest("test")).actionGet();
    logger.info("Get [type1/1] (should be empty)");
    for (int i = 0; i < 5; i++) {
        getResult = client().get(getRequest("test").id("1")).actionGet();
        assertThat(getResult.isExists(), equalTo(false));
    }
    logger.info("Index [type1/1]");
    client().index(indexRequest("test").id("1").source(source("1", "test"))).actionGet();
    logger.info("Index [type1/2]");
    client().index(indexRequest("test").id("2").source(source("2", "test2"))).actionGet();
    logger.info("Flushing");
    FlushResponse flushResult = client().admin().indices().prepareFlush("test").execute().actionGet();
    assertThat(flushResult.getSuccessfulShards(), equalTo(numShards.totalNumShards));
    assertThat(flushResult.getFailedShards(), equalTo(0));
    logger.info("Refreshing");
    client().admin().indices().refresh(refreshRequest("test")).actionGet();
    logger.info("Get [type1/1] and [type1/2]");
    for (int i = 0; i < 5; i++) {
        getResult = client().get(getRequest("test").id("1")).actionGet();
        assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
        assertThat("cycle #" + i, getResult.getSourceAsString(), equalTo(Strings.toString(source("1", "test"))));
        getResult = client().get(getRequest("test").id("2")).actionGet();
        String ste1 = getResult.getSourceAsString();
        String ste2 = Strings.toString(source("2", "test2"));
        assertThat("cycle #" + i, ste1, equalTo(ste2));
        assertThat(getResult.getIndex(), equalTo(getConcreteIndexName()));
    }
    logger.info("Count");
    // check count
    for (int i = 0; i < 5; i++) {
        // test successful
        SearchResponse countResponse = client().prepareSearch("test").setSize(0).setQuery(matchAllQuery()).execute().actionGet();
        assertNoFailures(countResponse);
        assertThat(countResponse.getHits().getTotalHits().value, equalTo(2L));
        assertThat(countResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
        assertThat(countResponse.getFailedShards(), equalTo(0));
        // count with no query is a match all one
        countResponse = client().prepareSearch("test").setSize(0).execute().actionGet();
        assertThat("Failures " + countResponse.getShardFailures(), countResponse.getShardFailures() == null ? 0 : countResponse.getShardFailures().length, equalTo(0));
        assertThat(countResponse.getHits().getTotalHits().value, equalTo(2L));
        assertThat(countResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries));
        assertThat(countResponse.getFailedShards(), equalTo(0));
    }
}
Also used : ClearIndicesCacheResponse(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) ForceMergeResponse(org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse) FlushResponse(org.opensearch.action.admin.indices.flush.FlushResponse) RefreshResponse(org.opensearch.action.admin.indices.refresh.RefreshResponse) DeleteResponse(org.opensearch.action.delete.DeleteResponse) IndexResponse(org.opensearch.action.index.IndexResponse) GetResponse(org.opensearch.action.get.GetResponse) SearchResponse(org.opensearch.action.search.SearchResponse)

Example 3 with ClearIndicesCacheResponse

use of org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse in project fesen-httpclient by codelibs.

the class HttpClearIndicesCacheAction method execute.

public void execute(final ClearIndicesCacheRequest request, final ActionListener<ClearIndicesCacheResponse> listener) {
    getCurlRequest(request).execute(response -> {
        try (final XContentParser parser = createParser(response)) {
            final ClearIndicesCacheResponse clearIndicesCacheResponse = ClearIndicesCacheResponse.fromXContent(parser);
            listener.onResponse(clearIndicesCacheResponse);
        } catch (final Exception e) {
            listener.onFailure(toOpenSearchException(response, e));
        }
    }, e -> unwrapOpenSearchException(listener, e));
}
Also used : ClearIndicesCacheResponse(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) XContentParser(org.opensearch.common.xcontent.XContentParser)

Example 4 with ClearIndicesCacheResponse

use of org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse in project fesen-httpclient by codelibs.

the class Elasticsearch8ClientTest method test_clear_cache_indices.

@Test
void test_clear_cache_indices() throws Exception {
    final String index = "test_clear_cache_indices";
    CountDownLatch latch = new CountDownLatch(1);
    client.admin().indices().prepareCreate(index).execute().actionGet();
    client.admin().indices().prepareClearCache(index).execute(wrap(res -> {
        assertTrue(res.getFailedShards() == 0);
        latch.countDown();
    }, e -> {
        e.printStackTrace();
        try {
            fail();
        } finally {
            latch.countDown();
        }
    }));
    latch.await();
    {
        ClearIndicesCacheResponse clearIndicesCacheResponse = client.admin().indices().prepareClearCache(index).execute().actionGet();
        assertTrue(clearIndicesCacheResponse.getFailedShards() == 0);
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ImmutableOpenMap(org.opensearch.common.collect.ImmutableOpenMap) MultiGetResponse(org.opensearch.action.get.MultiGetResponse) DockerImageName(org.testcontainers.utility.DockerImageName) IndexResponse(org.opensearch.action.index.IndexResponse) SimpleFormatter(java.util.logging.SimpleFormatter) ToXContent(org.opensearch.common.xcontent.ToXContent) ClusterRerouteAction(org.opensearch.action.admin.cluster.reroute.ClusterRerouteAction) ByteSizeUnit(org.opensearch.common.unit.ByteSizeUnit) ClusterRerouteRequest(org.opensearch.action.admin.cluster.reroute.ClusterRerouteRequest) OpenSearchException(org.opensearch.OpenSearchException) ShrinkAction(org.opensearch.action.admin.indices.shrink.ShrinkAction) AfterAll(org.junit.jupiter.api.AfterAll) CloseIndexResponse(org.opensearch.action.admin.indices.close.CloseIndexResponse) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Alias(org.opensearch.action.admin.indices.alias.Alias) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) XContentFactory(org.opensearch.common.xcontent.XContentFactory) SearchRequestBuilder(org.opensearch.action.search.SearchRequestBuilder) GetResponse(org.opensearch.action.get.GetResponse) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings) PendingClusterTasksResponse(org.opensearch.action.admin.cluster.tasks.PendingClusterTasksResponse) TimeValue(org.opensearch.common.unit.TimeValue) GetPipelineResponse(org.opensearch.action.ingest.GetPipelineResponse) SearchHit(org.opensearch.search.SearchHit) GetMappingsResponse(org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse) Result(org.opensearch.action.DocWriteResponse.Result) RolloverResponse(org.opensearch.action.admin.indices.rollover.RolloverResponse) Settings(org.opensearch.common.settings.Settings) Logger(java.util.logging.Logger) RestStatus(org.opensearch.rest.RestStatus) StandardCharsets(java.nio.charset.StandardCharsets) MultiSearchResponse(org.opensearch.action.search.MultiSearchResponse) Test(org.junit.jupiter.api.Test) ValidateQueryResponse(org.opensearch.action.admin.indices.validate.query.ValidateQueryResponse) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterHealthResponse(org.opensearch.action.admin.cluster.health.ClusterHealthResponse) GetIndexResponse(org.opensearch.action.admin.indices.get.GetIndexResponse) GetFieldMappingsResponse(org.opensearch.action.admin.indices.mapping.get.GetFieldMappingsResponse) BytesArray(org.opensearch.common.bytes.BytesArray) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) GetStoredScriptResponse(org.opensearch.action.admin.cluster.storedscripts.GetStoredScriptResponse) RefreshResponse(org.opensearch.action.admin.indices.refresh.RefreshResponse) ResizeResponse(org.opensearch.action.admin.indices.shrink.ResizeResponse) ActionListener.wrap(org.opensearch.action.ActionListener.wrap) XContentType(org.opensearch.common.xcontent.XContentType) CurlResponse(org.codelibs.curl.CurlResponse) RefreshPolicy(org.opensearch.action.support.WriteRequest.RefreshPolicy) Assertions.fail(org.junit.jupiter.api.Assertions.fail) FlushResponse(org.opensearch.action.admin.indices.flush.FlushResponse) MappingMetadata(org.opensearch.cluster.metadata.MappingMetadata) ResizeRequest(org.opensearch.action.admin.indices.shrink.ResizeRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BytesReference(org.opensearch.common.bytes.BytesReference) UpdateResponse(org.opensearch.action.update.UpdateResponse) FieldCapabilitiesResponse(org.opensearch.action.fieldcaps.FieldCapabilitiesResponse) BulkRequestBuilder(org.opensearch.action.bulk.BulkRequestBuilder) Level(java.util.logging.Level) ClusterUpdateSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) AnalyzeAction(org.opensearch.action.admin.indices.analyze.AnalyzeAction) DeleteResponse(org.opensearch.action.delete.DeleteResponse) AliasesExistResponse(org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse) ClearScrollResponse(org.opensearch.action.search.ClearScrollResponse) GenericContainer(org.testcontainers.containers.GenericContainer) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SearchResponse(org.opensearch.action.search.SearchResponse) SyncedFlushResponse(org.opensearch.action.admin.indices.flush.SyncedFlushResponse) OutputStream(java.io.OutputStream) QueryBuilders(org.opensearch.index.query.QueryBuilders) ExplainResponse(org.opensearch.action.explain.ExplainResponse) FieldCapabilities(org.opensearch.action.fieldcaps.FieldCapabilities) GetAliasesResponse(org.opensearch.action.admin.indices.alias.get.GetAliasesResponse) MainAction(org.opensearch.action.main.MainAction) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) CreateIndexResponse(org.opensearch.action.admin.indices.create.CreateIndexResponse) ForceMergeResponse(org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse) MainRequest(org.opensearch.action.main.MainRequest) GetSettingsResponse(org.opensearch.action.admin.indices.settings.get.GetSettingsResponse) Curl(org.codelibs.curl.Curl) AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) XContentHelper(org.opensearch.common.xcontent.XContentHelper) AfterEach(org.junit.jupiter.api.AfterEach) OpenIndexResponse(org.opensearch.action.admin.indices.open.OpenIndexResponse) BulkResponse(org.opensearch.action.bulk.BulkResponse) MainResponse(org.opensearch.action.main.MainResponse) NodesStatsResponse(org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse) HttpNodesStatsAction(org.codelibs.fesen.client.action.HttpNodesStatsAction) ConsoleHandler(java.util.logging.ConsoleHandler) IndicesExistsResponse(org.opensearch.action.admin.indices.exists.indices.IndicesExistsResponse) MultiGetRequestBuilder(org.opensearch.action.get.MultiGetRequestBuilder) ClearIndicesCacheResponse(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) MultiGetRequest(org.opensearch.action.get.MultiGetRequest) ClearIndicesCacheResponse(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.jupiter.api.Test)

Example 5 with ClearIndicesCacheResponse

use of org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse in project fesen-httpclient by codelibs.

the class OpenSearchClientTest method test_clear_cache_indices.

@Test
void test_clear_cache_indices() throws Exception {
    final String index = "test_clear_cache_indices";
    CountDownLatch latch = new CountDownLatch(1);
    client.admin().indices().prepareCreate(index).execute().actionGet();
    client.admin().indices().prepareClearCache(index).execute(wrap(res -> {
        assertTrue(res.getFailedShards() == 0);
        latch.countDown();
    }, e -> {
        e.printStackTrace();
        try {
            fail();
        } finally {
            latch.countDown();
        }
    }));
    latch.await();
    {
        ClearIndicesCacheResponse clearIndicesCacheResponse = client.admin().indices().prepareClearCache(index).execute().actionGet();
        assertTrue(clearIndicesCacheResponse.getFailedShards() == 0);
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) ImmutableOpenMap(org.opensearch.common.collect.ImmutableOpenMap) MultiGetResponse(org.opensearch.action.get.MultiGetResponse) DockerImageName(org.testcontainers.utility.DockerImageName) IndexResponse(org.opensearch.action.index.IndexResponse) SimpleFormatter(java.util.logging.SimpleFormatter) ToXContent(org.opensearch.common.xcontent.ToXContent) ClusterRerouteAction(org.opensearch.action.admin.cluster.reroute.ClusterRerouteAction) ByteSizeUnit(org.opensearch.common.unit.ByteSizeUnit) ClusterRerouteRequest(org.opensearch.action.admin.cluster.reroute.ClusterRerouteRequest) FieldMappingMetadata(org.opensearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetadata) ShrinkAction(org.opensearch.action.admin.indices.shrink.ShrinkAction) AfterAll(org.junit.jupiter.api.AfterAll) CloseIndexResponse(org.opensearch.action.admin.indices.close.CloseIndexResponse) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Alias(org.opensearch.action.admin.indices.alias.Alias) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) XContentFactory(org.opensearch.common.xcontent.XContentFactory) SearchRequestBuilder(org.opensearch.action.search.SearchRequestBuilder) GetResponse(org.opensearch.action.get.GetResponse) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings) PendingClusterTasksResponse(org.opensearch.action.admin.cluster.tasks.PendingClusterTasksResponse) TimeValue(org.opensearch.common.unit.TimeValue) GetPipelineResponse(org.opensearch.action.ingest.GetPipelineResponse) SearchHit(org.opensearch.search.SearchHit) GetMappingsResponse(org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse) Result(org.opensearch.action.DocWriteResponse.Result) RolloverResponse(org.opensearch.action.admin.indices.rollover.RolloverResponse) Settings(org.opensearch.common.settings.Settings) Logger(java.util.logging.Logger) RestStatus(org.opensearch.rest.RestStatus) StandardCharsets(java.nio.charset.StandardCharsets) MultiSearchResponse(org.opensearch.action.search.MultiSearchResponse) Test(org.junit.jupiter.api.Test) ValidateQueryResponse(org.opensearch.action.admin.indices.validate.query.ValidateQueryResponse) CountDownLatch(java.util.concurrent.CountDownLatch) ClusterHealthResponse(org.opensearch.action.admin.cluster.health.ClusterHealthResponse) GetIndexResponse(org.opensearch.action.admin.indices.get.GetIndexResponse) GetFieldMappingsResponse(org.opensearch.action.admin.indices.mapping.get.GetFieldMappingsResponse) BytesArray(org.opensearch.common.bytes.BytesArray) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) GetStoredScriptResponse(org.opensearch.action.admin.cluster.storedscripts.GetStoredScriptResponse) RefreshResponse(org.opensearch.action.admin.indices.refresh.RefreshResponse) ResizeResponse(org.opensearch.action.admin.indices.shrink.ResizeResponse) ActionListener.wrap(org.opensearch.action.ActionListener.wrap) XContentType(org.opensearch.common.xcontent.XContentType) CurlResponse(org.codelibs.curl.CurlResponse) RefreshPolicy(org.opensearch.action.support.WriteRequest.RefreshPolicy) Assertions.fail(org.junit.jupiter.api.Assertions.fail) FlushResponse(org.opensearch.action.admin.indices.flush.FlushResponse) MappingMetadata(org.opensearch.cluster.metadata.MappingMetadata) ResizeRequest(org.opensearch.action.admin.indices.shrink.ResizeRequest) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BytesReference(org.opensearch.common.bytes.BytesReference) UpdateResponse(org.opensearch.action.update.UpdateResponse) FieldCapabilitiesResponse(org.opensearch.action.fieldcaps.FieldCapabilitiesResponse) BulkRequestBuilder(org.opensearch.action.bulk.BulkRequestBuilder) Level(java.util.logging.Level) ClusterUpdateSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) AnalyzeAction(org.opensearch.action.admin.indices.analyze.AnalyzeAction) DeleteResponse(org.opensearch.action.delete.DeleteResponse) AliasesExistResponse(org.opensearch.action.admin.indices.alias.exists.AliasesExistResponse) ClearScrollResponse(org.opensearch.action.search.ClearScrollResponse) GenericContainer(org.testcontainers.containers.GenericContainer) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SearchResponse(org.opensearch.action.search.SearchResponse) SyncedFlushResponse(org.opensearch.action.admin.indices.flush.SyncedFlushResponse) OutputStream(java.io.OutputStream) QueryBuilders(org.opensearch.index.query.QueryBuilders) ExplainResponse(org.opensearch.action.explain.ExplainResponse) FieldCapabilities(org.opensearch.action.fieldcaps.FieldCapabilities) GetAliasesResponse(org.opensearch.action.admin.indices.alias.get.GetAliasesResponse) MainAction(org.opensearch.action.main.MainAction) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) CreateIndexResponse(org.opensearch.action.admin.indices.create.CreateIndexResponse) ForceMergeResponse(org.opensearch.action.admin.indices.forcemerge.ForceMergeResponse) MainRequest(org.opensearch.action.main.MainRequest) GetSettingsResponse(org.opensearch.action.admin.indices.settings.get.GetSettingsResponse) Curl(org.codelibs.curl.Curl) AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) XContentHelper(org.opensearch.common.xcontent.XContentHelper) AfterEach(org.junit.jupiter.api.AfterEach) OpenIndexResponse(org.opensearch.action.admin.indices.open.OpenIndexResponse) BulkResponse(org.opensearch.action.bulk.BulkResponse) MainResponse(org.opensearch.action.main.MainResponse) NodesStatsResponse(org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse) HttpNodesStatsAction(org.codelibs.fesen.client.action.HttpNodesStatsAction) ConsoleHandler(java.util.logging.ConsoleHandler) IndicesExistsResponse(org.opensearch.action.admin.indices.exists.indices.IndicesExistsResponse) MultiGetRequestBuilder(org.opensearch.action.get.MultiGetRequestBuilder) ClearIndicesCacheResponse(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) MultiGetRequest(org.opensearch.action.get.MultiGetRequest) ClearIndicesCacheResponse(org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.jupiter.api.Test)

Aggregations

ClearIndicesCacheResponse (org.opensearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse)5 FlushResponse (org.opensearch.action.admin.indices.flush.FlushResponse)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 OutputStream (java.io.OutputStream)3 StandardCharsets (java.nio.charset.StandardCharsets)3 Map (java.util.Map)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ConsoleHandler (java.util.logging.ConsoleHandler)3 Level (java.util.logging.Level)3 Logger (java.util.logging.Logger)3 SimpleFormatter (java.util.logging.SimpleFormatter)3 Curl (org.codelibs.curl.Curl)3 CurlResponse (org.codelibs.curl.CurlResponse)3 HttpNodesStatsAction (org.codelibs.fesen.client.action.HttpNodesStatsAction)3 AfterAll (org.junit.jupiter.api.AfterAll)3 AfterEach (org.junit.jupiter.api.AfterEach)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)3 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)3 Assertions.fail (org.junit.jupiter.api.Assertions.fail)3