Skip to content

Commit

Permalink
Simplify cleanUpPits
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <cwperx@amazon.com>
  • Loading branch information
cwperks committed Jan 3, 2024
1 parent 77b3df7 commit efc4889
Showing 1 changed file with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import org.opensearch.OpenSearchStatusException;
import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.search.CreatePitRequest;
Expand All @@ -33,7 +32,6 @@
import org.opensearch.client.Client;
import org.opensearch.client.RestHighLevelClient;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.search.builder.PointInTimeBuilder;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.test.framework.TestSecurityConfig;
Expand Down Expand Up @@ -136,17 +134,7 @@ public static void createTestData() {
@Before
public void cleanUpPits() throws IOException {
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(ADMIN_USER)) {
GetAllPitNodesResponse existingPitsResponse = restHighLevelClient.getAllPits(DEFAULT);
if (!existingPitsResponse.getPitInfos().isEmpty()) {
try {
restHighLevelClient.deleteAllPits(DEFAULT);
} catch (OpenSearchStatusException ex) {
if (ex.status() != RestStatus.NOT_FOUND) {
throw ex;
}
// tried to remove pits but no pit exists
}
}
restHighLevelClient.deleteAllPits(DEFAULT);
}
}

Expand Down

0 comments on commit efc4889

Please sign in to comment.