Skip to content

Commit 64695b6

Browse files
committed
TEST: Increase timeout testFollowIndexAndCloseNode (#33333)
This test fails several times due to timeout when asserting the number of docs on the following and leading indices. This change reduces the number of docs to index and increases the timeout.
1 parent a6312a5 commit 64695b6

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/ShardChangesIT.java

+6-21
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.elasticsearch.xpack.core.XPackSettings;
4747

4848
import java.io.IOException;
49-
import java.io.UncheckedIOException;
5049
import java.util.Arrays;
5150
import java.util.Collection;
5251
import java.util.Collections;
@@ -337,26 +336,12 @@ public void testFollowIndexAndCloseNode() throws Exception {
337336
ShardFollowNodeTask.DEFAULT_MAX_WRITE_BUFFER_SIZE, TimeValue.timeValueMillis(500), TimeValue.timeValueMillis(10));
338337
client().execute(FollowIndexAction.INSTANCE, followRequest).get();
339338

340-
long maxNumDocsReplicated = Math.min(3000, randomLongBetween(followRequest.getMaxBatchOperationCount(),
339+
long maxNumDocsReplicated = Math.min(1000, randomLongBetween(followRequest.getMaxBatchOperationCount(),
341340
followRequest.getMaxBatchOperationCount() * 10));
342341
long minNumDocsReplicated = maxNumDocsReplicated / 3L;
343342
logger.info("waiting for at least [{}] documents to be indexed and then stop a random data node", minNumDocsReplicated);
344-
awaitBusy(() -> {
345-
SearchRequest request = new SearchRequest("index2");
346-
request.source(new SearchSourceBuilder().size(0));
347-
SearchResponse response = client().search(request).actionGet();
348-
if (response.getHits().getTotalHits() >= minNumDocsReplicated) {
349-
try {
350-
internalCluster().stopRandomNonMasterNode();
351-
} catch (IOException e) {
352-
throw new UncheckedIOException(e);
353-
}
354-
return true;
355-
} else {
356-
return false;
357-
}
358-
}, 30, TimeUnit.SECONDS);
359-
343+
atLeastDocsIndexed("index2", minNumDocsReplicated);
344+
internalCluster().stopRandomNonMasterNode();
360345
logger.info("waiting for at least [{}] documents to be indexed", maxNumDocsReplicated);
361346
atLeastDocsIndexed("index2", maxNumDocsReplicated);
362347
run.set(false);
@@ -546,7 +531,7 @@ private void unfollowIndex(String index) throws Exception {
546531
}
547532
}
548533
assertThat(numNodeTasks, equalTo(0));
549-
});
534+
}, 30, TimeUnit.SECONDS);
550535
}
551536

552537
private CheckedRunnable<Exception> assertExpectedDocumentRunnable(final int value) {
@@ -658,7 +643,7 @@ private void atLeastDocsIndexed(String index, long numDocsReplicated) throws Int
658643
request.source(new SearchSourceBuilder().size(0));
659644
SearchResponse response = client().search(request).actionGet();
660645
return response.getHits().getTotalHits() >= numDocsReplicated;
661-
}, 30, TimeUnit.SECONDS);
646+
}, 60, TimeUnit.SECONDS);
662647
}
663648

664649
private void assertSameDocCount(String index1, String index2) throws Exception {
@@ -672,7 +657,7 @@ private void assertSameDocCount(String index1, String index2) throws Exception {
672657
request2.source(new SearchSourceBuilder().size(0));
673658
SearchResponse response2 = client().search(request2).actionGet();
674659
assertThat(response2.getHits().getTotalHits(), equalTo(response1.getHits().getTotalHits()));
675-
});
660+
}, 60, TimeUnit.SECONDS);
676661
}
677662

678663
public static FollowIndexAction.Request createFollowRequest(String leaderIndex, String followIndex) {

0 commit comments

Comments
 (0)