Skip to content

Commit c6b011f

Browse files
authored
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 b935076 commit c6b011f

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

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.elasticsearch.xpack.core.XPackSettings;
4848

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

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

554539
private CheckedRunnable<Exception> assertExpectedDocumentRunnable(final int value) {
@@ -660,7 +645,7 @@ private void atLeastDocsIndexed(String index, long numDocsReplicated) throws Int
660645
request.source(new SearchSourceBuilder().size(0));
661646
SearchResponse response = client().search(request).actionGet();
662647
return response.getHits().getTotalHits() >= numDocsReplicated;
663-
}, 30, TimeUnit.SECONDS);
648+
}, 60, TimeUnit.SECONDS);
664649
}
665650

666651
private void assertSameDocCount(String index1, String index2) throws Exception {
@@ -674,7 +659,7 @@ private void assertSameDocCount(String index1, String index2) throws Exception {
674659
request2.source(new SearchSourceBuilder().size(0));
675660
SearchResponse response2 = client().search(request2).actionGet();
676661
assertThat(response2.getHits().getTotalHits(), equalTo(response1.getHits().getTotalHits()));
677-
});
662+
}, 60, TimeUnit.SECONDS);
678663
}
679664

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

0 commit comments

Comments
 (0)