Skip to content

Commit 875b603

Browse files
authored
Flaky test : Don't use async repo for SplitIndex and wait for translo… (#15107)
* 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 8f95735 commit 875b603

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

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

+24
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.opensearch.action.index.IndexRequest;
4747
import org.opensearch.action.index.IndexRequestBuilder;
4848
import org.opensearch.action.search.SearchResponse;
49+
import org.opensearch.action.support.IndicesOptions;
4950
import org.opensearch.client.Client;
5051
import org.opensearch.cluster.ClusterState;
5152
import org.opensearch.cluster.metadata.IndexMetadata;
@@ -69,12 +70,15 @@
6970
import org.opensearch.remotestore.RemoteStoreBaseIntegTestCase;
7071
import org.opensearch.test.OpenSearchIntegTestCase;
7172
import org.opensearch.test.VersionUtils;
73+
import org.junit.After;
74+
import org.junit.Before;
7275

7376
import java.io.IOException;
7477
import java.io.UncheckedIOException;
7578
import java.util.Arrays;
7679
import java.util.HashSet;
7780
import java.util.Set;
81+
import java.util.concurrent.TimeUnit;
7882
import java.util.function.BiFunction;
7983
import java.util.stream.IntStream;
8084

@@ -89,12 +93,32 @@
8993

9094
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
9195
public class RemoteSplitIndexIT extends RemoteStoreBaseIntegTestCase {
96+
@Before
97+
public void setup() {
98+
asyncUploadMockFsRepo = false;
99+
}
92100

93101
@Override
94102
protected boolean forbidPrivateIndexSettings() {
95103
return false;
96104
}
97105

106+
@After
107+
public void cleanUp() throws Exception {
108+
// Delete is async.
109+
assertAcked(
110+
client().admin().indices().prepareDelete("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get()
111+
);
112+
assertBusy(() -> {
113+
try {
114+
assertEquals(0, getFileCount(translogRepoPath));
115+
} catch (IOException e) {
116+
fail();
117+
}
118+
}, 30, TimeUnit.SECONDS);
119+
super.teardown();
120+
}
121+
98122
public Settings indexSettings() {
99123
return Settings.builder()
100124
.put(super.indexSettings())

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void assertRemoteStoreRepositoryOnAllNodes(String repositoryName) {
313313
}
314314
}
315315

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

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

+11-7
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void testStatsResponseFromLocalNode() {
250250
}
251251
}
252252

253-
@TestLogging(reason = "Getting trace logs from remote store package", value = "org.opensearch.remotestore:TRACE")
253+
@TestLogging(reason = "Getting trace logs from remote store package", value = "org.opensearch.index.shard:TRACE")
254254
public void testDownloadStatsCorrectnessSinglePrimarySingleReplica() throws Exception {
255255
setup();
256256
// Scenario:
@@ -280,11 +280,13 @@ public void testDownloadStatsCorrectnessSinglePrimarySingleReplica() throws Exce
280280
.get(0)
281281
.getSegmentStats();
282282
logger.info(
283-
"Zero state primary stats: {}ms refresh time lag, {}b bytes lag, {}b upload bytes started and {}b upload bytes failed.",
283+
"Zero state primary stats: {}ms refresh time lag, {}b bytes lag, {}b upload bytes started, {}b upload bytes failed , {} uploads succeeded, {} upload byes succeeded.",
284284
zeroStatePrimaryStats.refreshTimeLagMs,
285285
zeroStatePrimaryStats.bytesLag,
286286
zeroStatePrimaryStats.uploadBytesStarted,
287-
zeroStatePrimaryStats.uploadBytesFailed
287+
zeroStatePrimaryStats.uploadBytesFailed,
288+
zeroStatePrimaryStats.totalUploadsSucceeded,
289+
zeroStatePrimaryStats.uploadBytesSucceeded
288290
);
289291
assertTrue(
290292
zeroStatePrimaryStats.totalUploadsStarted == zeroStatePrimaryStats.totalUploadsSucceeded
@@ -348,7 +350,7 @@ public void testDownloadStatsCorrectnessSinglePrimarySingleReplica() throws Exce
348350
}
349351
}
350352

351-
@TestLogging(reason = "Getting trace logs from remote store package", value = "org.opensearch.remotestore:TRACE")
353+
@TestLogging(reason = "Getting trace logs from remote store package", value = "org.opensearch.index.shard:TRACE")
352354
public void testDownloadStatsCorrectnessSinglePrimaryMultipleReplicaShards() throws Exception {
353355
setup();
354356
// Scenario:
@@ -382,11 +384,13 @@ public void testDownloadStatsCorrectnessSinglePrimaryMultipleReplicaShards() thr
382384
.get(0)
383385
.getSegmentStats();
384386
logger.info(
385-
"Zero state primary stats: {}ms refresh time lag, {}b bytes lag, {}b upload bytes started and {}b upload bytes failed.",
387+
"Zero state primary stats: {}ms refresh time lag, {}b bytes lag, {}b upload bytes started, {}b upload bytes failed , {} uploads succeeded, {} upload byes succeeded.",
386388
zeroStatePrimaryStats.refreshTimeLagMs,
387389
zeroStatePrimaryStats.bytesLag,
388390
zeroStatePrimaryStats.uploadBytesStarted,
389-
zeroStatePrimaryStats.uploadBytesFailed
391+
zeroStatePrimaryStats.uploadBytesFailed,
392+
zeroStatePrimaryStats.totalUploadsSucceeded,
393+
zeroStatePrimaryStats.uploadBytesSucceeded
390394
);
391395
assertTrue(
392396
zeroStatePrimaryStats.totalUploadsStarted == zeroStatePrimaryStats.totalUploadsSucceeded
@@ -617,7 +621,7 @@ public void testNonZeroPrimaryStatsOnNewlyCreatedIndexWithZeroDocs() throws Exce
617621
}
618622
assertZeroTranslogDownloadStats(translogStats);
619623
});
620-
}, 5, TimeUnit.SECONDS);
624+
}, 10, TimeUnit.SECONDS);
621625
}
622626

623627
public void testStatsCorrectnessOnFailover() {

0 commit comments

Comments
 (0)