Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration test to create and delete PIT with AwsSdk2Transport #522

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
import org.opensearch.client.opensearch.OpenSearchAsyncClient;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch._types.OpenSearchException;
import org.opensearch.client.opensearch._types.Time;
import org.opensearch.client.opensearch.core.IndexRequest;
import org.opensearch.client.opensearch.core.IndexResponse;
import org.opensearch.client.opensearch.core.SearchResponse;
import org.opensearch.client.opensearch.core.pit.CreatePitRequest;
import org.opensearch.client.opensearch.core.pit.CreatePitResponse;
import org.opensearch.client.opensearch.core.pit.DeletePitRequest;
import org.opensearch.client.opensearch.core.pit.DeletePitResponse;
import org.opensearch.client.opensearch.indices.CreateIndexRequest;
import org.opensearch.client.opensearch.indices.OpenSearchIndicesClient;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;

Expand All @@ -44,6 +50,20 @@ public void testAsyncAsyncClient() throws Exception {
testClientAsync(true);
}

@Test
public void testCreateDeletePit() throws Exception {
final OpenSearchClient client = getClient(false, null, null);

final CreatePitResponse createPitResponse = client.createPit(CreatePitRequest.of(createPitRequest -> createPitRequest
.keepAlive(new Time.Builder().time("10m").build())
.targetIndexes(Collections.singletonList(TEST_INDEX))));
Assert.assertNotNull(createPitResponse);
Assert.assertNotNull(createPitResponse.pitId());

final DeletePitResponse deletePitResponse = client.deletePit(DeletePitRequest.of(deletePitBuilder -> deletePitBuilder.pitId(Collections.singletonList(createPitResponse.pitId()))));
Assert.assertNotNull(deletePitResponse);
}

void testClient(boolean async) throws Exception {
resetTestIndex(async);
final OpenSearchClient client = getClient(async, null, null);
Expand Down