Skip to content

Commit ec13798

Browse files
committed
Flaky test : Don't use async repo for SplitIndex and wait for translog file deletion
Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
1 parent a785073 commit ec13798

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/RemoteSplitIndexIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import org.opensearch.remotestore.RemoteStoreBaseIntegTestCase;
7070
import org.opensearch.test.OpenSearchIntegTestCase;
7171
import org.opensearch.test.VersionUtils;
72+
import org.junit.Before;
7273

7374
import java.io.IOException;
7475
import java.io.UncheckedIOException;
@@ -89,6 +90,10 @@
8990

9091
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
9192
public class RemoteSplitIndexIT extends RemoteStoreBaseIntegTestCase {
93+
@Before
94+
public void setup() {
95+
asyncUploadMockFsRepo = false;
96+
}
9297

9398
@Override
9499
protected boolean forbidPrivateIndexSettings() {

server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreBaseIntegTestCase.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.opensearch.action.index.IndexRequest;
2020
import org.opensearch.action.index.IndexRequestBuilder;
2121
import org.opensearch.action.index.IndexResponse;
22+
import org.opensearch.action.support.IndicesOptions;
2223
import org.opensearch.action.support.PlainActionFuture;
2324
import org.opensearch.action.support.WriteRequest;
2425
import org.opensearch.cluster.metadata.IndexMetadata;
@@ -57,6 +58,7 @@
5758
import java.util.Locale;
5859
import java.util.Map;
5960
import java.util.concurrent.ExecutionException;
61+
import java.util.concurrent.TimeUnit;
6062
import java.util.concurrent.atomic.AtomicInteger;
6163
import java.util.stream.Collectors;
6264
import java.util.stream.Stream;
@@ -257,14 +259,25 @@ protected Settings remoteStoreIndexSettings(int numberOfReplicas, long totalFiel
257259
}
258260

259261
@After
260-
public void teardown() {
262+
public void teardown() throws Exception {
261263
clusterSettingsSuppliedByTest = false;
262264
asyncUploadMockFsRepo = randomBoolean();
263265
metadataSupportedType = randomBoolean();
264266
assertRemoteStoreRepositoryOnAllNodes(REPOSITORY_NAME);
265267
assertRemoteStoreRepositoryOnAllNodes(REPOSITORY_2_NAME);
266268
clusterAdmin().prepareCleanupRepository(REPOSITORY_NAME).get();
267269
clusterAdmin().prepareCleanupRepository(REPOSITORY_2_NAME).get();
270+
// Delete is async.
271+
assertAcked(
272+
client().admin().indices().prepareDelete("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get()
273+
);
274+
assertBusy(() -> {
275+
try {
276+
assertEquals(0, getFileCount(translogRepoPath));
277+
} catch (IOException e) {
278+
fail();
279+
}
280+
}, 30, TimeUnit.SECONDS);
268281
}
269282

270283
public RepositoryMetadata buildRepositoryMetadata(DiscoveryNode node, String name) {
@@ -313,7 +326,7 @@ public void assertRemoteStoreRepositoryOnAllNodes(String repositoryName) {
313326
}
314327
}
315328

316-
public static int getFileCount(Path path) throws Exception {
329+
public static int getFileCount(Path path) throws IOException {
317330
final AtomicInteger filesExisting = new AtomicInteger(0);
318331
Files.walkFileTree(path, new SimpleFileVisitor<>() {
319332
@Override

0 commit comments

Comments
 (0)