Skip to content

Commit 7b708c4

Browse files
authored
fix flaky tests in SegmentReplicationPressureIT (#6868)
Signed-off-by: Poojita Raj <poojiraj@amazon.com>
1 parent bd9b00d commit 7b708c4

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

server/src/internalClusterTest/java/org/opensearch/index/SegmentReplicationPressureIT.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.opensearch.common.util.concurrent.OpenSearchRejectedExecutionException;
1818
import org.opensearch.index.shard.IndexShard;
1919
import org.opensearch.indices.replication.SegmentReplicationBaseIT;
20+
import org.opensearch.indices.replication.common.ReplicationType;
2021
import org.opensearch.plugins.Plugin;
2122
import org.opensearch.rest.RestStatus;
2223
import org.opensearch.test.OpenSearchIntegTestCase;
@@ -52,12 +53,24 @@ protected Settings nodeSettings(int nodeOrdinal) {
5253
.build();
5354
}
5455

56+
@Override
57+
public Settings indexSettings() {
58+
// we want to control refreshes
59+
return Settings.builder()
60+
.put(super.indexSettings())
61+
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, SHARD_COUNT)
62+
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, REPLICA_COUNT)
63+
.put(IndexModule.INDEX_QUERY_CACHE_ENABLED_SETTING.getKey(), false)
64+
.put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT)
65+
.put("index.refresh_interval", -1)
66+
.build();
67+
}
68+
5569
@Override
5670
protected Collection<Class<? extends Plugin>> nodePlugins() {
5771
return asList(MockTransportService.TestPlugin.class);
5872
}
5973

60-
@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/6671")
6174
public void testWritesRejected() throws Exception {
6275
final String primaryNode = internalCluster().startNode();
6376
createIndex(INDEX_NAME);
@@ -76,6 +89,10 @@ public void testWritesRejected() throws Exception {
7689
indexingThread.start();
7790
indexingThread.join();
7891
latch.await();
92+
93+
indexDoc();
94+
totalDocs.incrementAndGet();
95+
refresh(INDEX_NAME);
7996
// index again while we are stale.
8097
assertBusy(() -> {
8198
expectThrows(OpenSearchRejectedExecutionException.class, () -> {
@@ -90,6 +107,7 @@ public void testWritesRejected() throws Exception {
90107

91108
// index another doc showing there is no pressure enforced.
92109
indexDoc();
110+
refresh(INDEX_NAME);
93111
waitForSearchableDocs(totalDocs.incrementAndGet(), replicaNodes.toArray(new String[] {}));
94112
verifyStoreContent();
95113
}
@@ -98,7 +116,6 @@ public void testWritesRejected() throws Exception {
98116
* This test ensures that a replica can be added while the index is under write block.
99117
* Ensuring that only write requests are blocked.
100118
*/
101-
@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/6671")
102119
public void testAddReplicaWhileWritesBlocked() throws Exception {
103120
final String primaryNode = internalCluster().startNode();
104121
createIndex(INDEX_NAME);
@@ -118,6 +135,9 @@ public void testAddReplicaWhileWritesBlocked() throws Exception {
118135
indexingThread.start();
119136
indexingThread.join();
120137
latch.await();
138+
indexDoc();
139+
totalDocs.incrementAndGet();
140+
refresh(INDEX_NAME);
121141
// index again while we are stale.
122142
assertBusy(() -> {
123143
expectThrows(OpenSearchRejectedExecutionException.class, () -> {
@@ -142,6 +162,7 @@ public void testAddReplicaWhileWritesBlocked() throws Exception {
142162

143163
// index another doc showing there is no pressure enforced.
144164
indexDoc();
165+
refresh(INDEX_NAME);
145166
waitForSearchableDocs(totalDocs.incrementAndGet(), replicaNodes.toArray(new String[] {}));
146167
verifyStoreContent();
147168
}
@@ -258,7 +279,7 @@ private void assertFailedRequests(BulkResponse response) {
258279
}
259280

260281
private void indexDoc() {
261-
client().prepareIndex(INDEX_NAME).setId(UUIDs.base64UUID()).setSource("{}", "{}").get();
282+
client().prepareIndex(INDEX_NAME).setId(UUIDs.base64UUID()).setSource("{}", "{}").execute().actionGet();
262283
}
263284

264285
private void assertEqualSegmentInfosVersion(List<String> replicaNames, IndexShard primaryShard) {

0 commit comments

Comments
 (0)