Skip to content

Commit

Permalink
Flaky test : Don't use async repo for SplitIndex and wait for translo… (
Browse files Browse the repository at this point in the history
opensearch-project#15107)

* Flaky test : Don't use async repo for SplitIndex and wait for translog file deletion

Signed-off-by: Gaurav Bafna <[email protected]>
  • Loading branch information
gbbafna authored and harshavamsi committed Aug 20, 2024
1 parent 4e13bfe commit 007447a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.action.support.IndicesOptions;
import org.opensearch.client.Client;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.metadata.IndexMetadata;
Expand All @@ -69,12 +70,15 @@
import org.opensearch.remotestore.RemoteStoreBaseIntegTestCase;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.VersionUtils;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.stream.IntStream;

Expand All @@ -89,12 +93,32 @@

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0)
public class RemoteSplitIndexIT extends RemoteStoreBaseIntegTestCase {
@Before
public void setup() {
asyncUploadMockFsRepo = false;
}

@Override
protected boolean forbidPrivateIndexSettings() {
return false;
}

@After
public void cleanUp() throws Exception {
// Delete is async.
assertAcked(
client().admin().indices().prepareDelete("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get()
);
assertBusy(() -> {
try {
assertEquals(0, getFileCount(translogRepoPath));
} catch (IOException e) {
fail();
}
}, 30, TimeUnit.SECONDS);
super.teardown();
}

public Settings indexSettings() {
return Settings.builder()
.put(super.indexSettings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public void assertRemoteStoreRepositoryOnAllNodes(String repositoryName) {
}
}

public static int getFileCount(Path path) throws Exception {
public static int getFileCount(Path path) throws IOException {
final AtomicInteger filesExisting = new AtomicInteger(0);
Files.walkFileTree(path, new SimpleFileVisitor<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void testStatsResponseFromLocalNode() {
}
}

@TestLogging(reason = "Getting trace logs from remote store package", value = "org.opensearch.remotestore:TRACE")
@TestLogging(reason = "Getting trace logs from remote store package", value = "org.opensearch.index.shard:TRACE")
public void testDownloadStatsCorrectnessSinglePrimarySingleReplica() throws Exception {
setup();
// Scenario:
Expand Down Expand Up @@ -280,11 +280,13 @@ public void testDownloadStatsCorrectnessSinglePrimarySingleReplica() throws Exce
.get(0)
.getSegmentStats();
logger.info(
"Zero state primary stats: {}ms refresh time lag, {}b bytes lag, {}b upload bytes started and {}b upload bytes failed.",
"Zero state primary stats: {}ms refresh time lag, {}b bytes lag, {}b upload bytes started, {}b upload bytes failed , {} uploads succeeded, {} upload byes succeeded.",
zeroStatePrimaryStats.refreshTimeLagMs,
zeroStatePrimaryStats.bytesLag,
zeroStatePrimaryStats.uploadBytesStarted,
zeroStatePrimaryStats.uploadBytesFailed
zeroStatePrimaryStats.uploadBytesFailed,
zeroStatePrimaryStats.totalUploadsSucceeded,
zeroStatePrimaryStats.uploadBytesSucceeded
);
assertTrue(
zeroStatePrimaryStats.totalUploadsStarted == zeroStatePrimaryStats.totalUploadsSucceeded
Expand Down Expand Up @@ -348,7 +350,7 @@ public void testDownloadStatsCorrectnessSinglePrimarySingleReplica() throws Exce
}
}

@TestLogging(reason = "Getting trace logs from remote store package", value = "org.opensearch.remotestore:TRACE")
@TestLogging(reason = "Getting trace logs from remote store package", value = "org.opensearch.index.shard:TRACE")
public void testDownloadStatsCorrectnessSinglePrimaryMultipleReplicaShards() throws Exception {
setup();
// Scenario:
Expand Down Expand Up @@ -382,11 +384,13 @@ public void testDownloadStatsCorrectnessSinglePrimaryMultipleReplicaShards() thr
.get(0)
.getSegmentStats();
logger.info(
"Zero state primary stats: {}ms refresh time lag, {}b bytes lag, {}b upload bytes started and {}b upload bytes failed.",
"Zero state primary stats: {}ms refresh time lag, {}b bytes lag, {}b upload bytes started, {}b upload bytes failed , {} uploads succeeded, {} upload byes succeeded.",
zeroStatePrimaryStats.refreshTimeLagMs,
zeroStatePrimaryStats.bytesLag,
zeroStatePrimaryStats.uploadBytesStarted,
zeroStatePrimaryStats.uploadBytesFailed
zeroStatePrimaryStats.uploadBytesFailed,
zeroStatePrimaryStats.totalUploadsSucceeded,
zeroStatePrimaryStats.uploadBytesSucceeded
);
assertTrue(
zeroStatePrimaryStats.totalUploadsStarted == zeroStatePrimaryStats.totalUploadsSucceeded
Expand Down Expand Up @@ -617,7 +621,7 @@ public void testNonZeroPrimaryStatsOnNewlyCreatedIndexWithZeroDocs() throws Exce
}
assertZeroTranslogDownloadStats(translogStats);
});
}, 5, TimeUnit.SECONDS);
}, 10, TimeUnit.SECONDS);
}

public void testStatsCorrectnessOnFailover() {
Expand Down

0 comments on commit 007447a

Please sign in to comment.