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

[Backport 2.x] Re-enable disabled PIT integration tests #3914

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
Re-enable disabled PIT integration tests (#3871)
### Description

Re-enables 2 PIT integration tests that were previously disabled. This
adds a @before method to clean up all PITs created from previous test
cases to ensure each test case runs pristinely.

* Category (Enhancement, New feature, Bug fix, Test fix, Refactoring,
Maintenance, Documentation)

Test fix

### Issues Resolved

- #3424

Is this a backport? If so, please add backport PR # and/or commits #

### Testing
[Please provide details of testing done: unit testing, integration
testing and manual testing]

### Check List
- [ ] New functionality includes testing
- [ ] New functionality has been documented
- [ ] Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and
signing off your commits, please check
[here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).

---------

Signed-off-by: Craig Perkins <[email protected]>
(cherry picked from commit f216743)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Jan 4, 2024
commit 7991da0a34d45ea3e1d0e1abf5bc7d86e174c08a
Original file line number Diff line number Diff line change
@@ -14,13 +14,12 @@
import com.carrotsearch.randomizedtesting.RandomizedRunner;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Ignore;
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;
@@ -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;
@@ -133,6 +131,13 @@ public static void createTestData() {
}
}

@Before
public void cleanUpPits() throws IOException {
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(ADMIN_USER)) {
restHighLevelClient.deleteAllPits(DEFAULT);
}
}

@ClassRule
public static final LocalCluster cluster = new LocalCluster.Builder().clusterManager(ClusterManager.THREE_CLUSTER_MANAGERS)
.anonymousAuth(false)
@@ -180,11 +185,9 @@ public void createPitWithIndexAlias_negative() throws IOException {
}
}

@Ignore("Pretty sure cleanUpPits is returning before all of the PITs have actually been deleted")
@Test
public void listAllPits_positive() throws IOException {
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(POINT_IN_TIME_USER)) {
cleanUpPits();
String firstIndexPit = createPitForIndices(FIRST_SONG_INDEX);
String secondIndexPit = createPitForIndices(SECOND_SONG_INDEX);

@@ -250,7 +253,6 @@ public void deletePitCreatedWithIndexAlias_negative() throws IOException {
@Test
public void deleteAllPits_positive() throws IOException {
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(POINT_IN_TIME_USER)) {
cleanUpPits();
String firstIndexPit = createPitForIndices(FIRST_SONG_INDEX);
String secondIndexPit = createPitForIndices(SECOND_SONG_INDEX);

@@ -409,20 +411,4 @@ private String createPitForIndices(String... indices) throws IOException {
}
}

/**
* Deletes all PITs.
*/
public void cleanUpPits() throws IOException {
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(ADMIN_USER)) {
try {
restHighLevelClient.deleteAllPits(DEFAULT);
} catch (OpenSearchStatusException ex) {
if (ex.status() != RestStatus.NOT_FOUND) {
throw ex;
}
// tried to remove pits but no pit exists
}
}
}

}
Loading