Skip to content

Commit

Permalink
[Remote Segment Store] Fix flaky RemoteStoreIT.testStaleCommitDeletio…
Browse files Browse the repository at this point in the history
…n tests (opensearch-project#8523)

Signed-off-by: Sachin Kale <[email protected]>
Signed-off-by: sahil buddharaju <[email protected]>
  • Loading branch information
sachinpkale authored and sahil buddharaju committed Jul 18, 2023
1 parent ecc6682 commit b6411b1
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.remotestore;

import org.hamcrest.MatcherAssert;
import org.junit.Before;
import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreRequest;
import org.opensearch.action.admin.indices.delete.DeleteIndexRequest;
Expand Down Expand Up @@ -35,6 +36,8 @@
import java.util.concurrent.TimeUnit;

import static org.hamcrest.Matchers.comparesEqualTo;
import static org.hamcrest.Matchers.oneOf;
import static org.hamcrest.Matchers.is;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;

Expand Down Expand Up @@ -285,7 +288,6 @@ public void testRemoteTranslogCleanup() throws Exception {
verifyRemoteStoreCleanup(true);
}

@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/8504")
public void testStaleCommitDeletionWithInvokeFlush() throws Exception {
internalCluster().startDataOnlyNodes(3);
createIndex(INDEX_NAME, remoteStoreIndexSettings(1, 10000l));
Expand All @@ -301,16 +303,15 @@ public void testStaleCommitDeletionWithInvokeFlush() throws Exception {
assertBusy(() -> {
int actualFileCount = getFileCount(indexPath);
if (numberOfIterations <= RemoteStoreRefreshListener.LAST_N_METADATA_FILES_TO_KEEP) {
assertEquals(numberOfIterations, actualFileCount);
MatcherAssert.assertThat(actualFileCount, is(oneOf(numberOfIterations, numberOfIterations + 1)));
} else {
// As delete is async its possible that the file gets created before the deletion or after
// deletion.
assertTrue(actualFileCount >= 10 || actualFileCount <= 11);
MatcherAssert.assertThat(actualFileCount, is(oneOf(10, 11)));
}
}, 30, TimeUnit.SECONDS);
}

@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/8504")
public void testStaleCommitDeletionWithoutInvokeFlush() throws Exception {
internalCluster().startDataOnlyNodes(3);
createIndex(INDEX_NAME, remoteStoreIndexSettings(1, 10000l));
Expand All @@ -322,6 +323,8 @@ public void testStaleCommitDeletionWithoutInvokeFlush() throws Exception {
.get()
.getSetting(INDEX_NAME, IndexMetadata.SETTING_INDEX_UUID);
Path indexPath = Path.of(String.valueOf(absolutePath), indexUUID, "/0/segments/metadata");
assertEquals(numberOfIterations, getFileCount(indexPath));
int actualFileCount = getFileCount(indexPath);
// We also allow (numberOfIterations + 1) as index creation also triggers refresh.
MatcherAssert.assertThat(actualFileCount, is(oneOf(numberOfIterations, numberOfIterations + 1)));
}
}

0 comments on commit b6411b1

Please sign in to comment.