1616import org .opensearch .cluster .metadata .IndexMetadata ;
1717import org .opensearch .cluster .routing .RecoverySource ;
1818import org .opensearch .common .settings .Settings ;
19- import org .opensearch .index .shard .RemoteStoreRefreshListener ;
2019import org .opensearch .indices .recovery .RecoveryState ;
2120import org .opensearch .plugins .Plugin ;
2221import org .opensearch .test .OpenSearchIntegTestCase ;
2928import java .util .Optional ;
3029import java .util .concurrent .TimeUnit ;
3130
32- import static org .hamcrest .Matchers .is ;
33- import static org .hamcrest .Matchers .oneOf ;
34- import static org .hamcrest .Matchers .comparesEqualTo ;
3531import static org .hamcrest .Matchers .comparesEqualTo ;
3632import static org .hamcrest .Matchers .is ;
3733import static org .hamcrest .Matchers .oneOf ;
34+ import static org .opensearch .index .shard .RemoteStoreRefreshListener .LAST_N_METADATA_FILES_TO_KEEP ;
3835import static org .opensearch .test .hamcrest .OpenSearchAssertions .assertAcked ;
3936import static org .opensearch .test .hamcrest .OpenSearchAssertions .assertHitCount ;
4037
@@ -148,10 +145,9 @@ public void testRemoteTranslogCleanup() throws Exception {
148145 verifyRemoteStoreCleanup ();
149146 }
150147
151- @ AwaitsFix (bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/8658" )
152148 public void testStaleCommitDeletionWithInvokeFlush () throws Exception {
153- internalCluster ().startDataOnlyNodes (3 );
154- createIndex (INDEX_NAME , remoteStoreIndexSettings (1 , 10000l ));
149+ internalCluster ().startDataOnlyNodes (1 );
150+ createIndex (INDEX_NAME , remoteStoreIndexSettings (1 , 10000l , - 1 ));
155151 int numberOfIterations = randomIntBetween (5 , 15 );
156152 indexData (numberOfIterations , true , INDEX_NAME );
157153 String indexUUID = client ().admin ()
@@ -163,20 +159,22 @@ public void testStaleCommitDeletionWithInvokeFlush() throws Exception {
163159 // Delete is async.
164160 assertBusy (() -> {
165161 int actualFileCount = getFileCount (indexPath );
166- if (numberOfIterations <= RemoteStoreRefreshListener . LAST_N_METADATA_FILES_TO_KEEP ) {
167- MatcherAssert .assertThat (actualFileCount , is (oneOf (numberOfIterations , numberOfIterations + 1 )));
162+ if (numberOfIterations <= LAST_N_METADATA_FILES_TO_KEEP ) {
163+ MatcherAssert .assertThat (actualFileCount , is (oneOf (numberOfIterations - 1 , numberOfIterations , numberOfIterations + 1 )));
168164 } else {
169165 // As delete is async its possible that the file gets created before the deletion or after
170166 // deletion.
171- MatcherAssert .assertThat (actualFileCount , is (oneOf (10 , 11 )));
167+ MatcherAssert .assertThat (
168+ actualFileCount ,
169+ is (oneOf (LAST_N_METADATA_FILES_TO_KEEP - 1 , LAST_N_METADATA_FILES_TO_KEEP , LAST_N_METADATA_FILES_TO_KEEP + 1 ))
170+ );
172171 }
173172 }, 30 , TimeUnit .SECONDS );
174173 }
175174
176- @ AwaitsFix (bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/8658" )
177175 public void testStaleCommitDeletionWithoutInvokeFlush () throws Exception {
178- internalCluster ().startDataOnlyNodes (3 );
179- createIndex (INDEX_NAME , remoteStoreIndexSettings (1 , 10000l ));
176+ internalCluster ().startDataOnlyNodes (1 );
177+ createIndex (INDEX_NAME , remoteStoreIndexSettings (1 , 10000l , - 1 ));
180178 int numberOfIterations = randomIntBetween (5 , 15 );
181179 indexData (numberOfIterations , false , INDEX_NAME );
182180 String indexUUID = client ().admin ()
@@ -187,6 +185,6 @@ public void testStaleCommitDeletionWithoutInvokeFlush() throws Exception {
187185 Path indexPath = Path .of (String .valueOf (absolutePath ), indexUUID , "/0/segments/metadata" );
188186 int actualFileCount = getFileCount (indexPath );
189187 // We also allow (numberOfIterations + 1) as index creation also triggers refresh.
190- MatcherAssert .assertThat (actualFileCount , is (oneOf (numberOfIterations , numberOfIterations + 1 )));
188+ MatcherAssert .assertThat (actualFileCount , is (oneOf (numberOfIterations - 1 , numberOfIterations , numberOfIterations + 1 )));
191189 }
192190}
0 commit comments