Skip to content

Commit

Permalink
TEST: Increase timeout testFollowIndexAndCloseNode (#33333)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dnhatn committed Sep 2, 2018
1 parent a6312a5 commit 64695b6
Showing 1 changed file with 6 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.elasticsearch.xpack.core.XPackSettings;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -337,26 +336,12 @@ public void testFollowIndexAndCloseNode() throws Exception {
ShardFollowNodeTask.DEFAULT_MAX_WRITE_BUFFER_SIZE, TimeValue.timeValueMillis(500), TimeValue.timeValueMillis(10));
client().execute(FollowIndexAction.INSTANCE, followRequest).get();

long maxNumDocsReplicated = Math.min(3000, randomLongBetween(followRequest.getMaxBatchOperationCount(),
long maxNumDocsReplicated = Math.min(1000, randomLongBetween(followRequest.getMaxBatchOperationCount(),
followRequest.getMaxBatchOperationCount() * 10));
long minNumDocsReplicated = maxNumDocsReplicated / 3L;
logger.info("waiting for at least [{}] documents to be indexed and then stop a random data node", minNumDocsReplicated);
awaitBusy(() -> {
SearchRequest request = new SearchRequest("index2");
request.source(new SearchSourceBuilder().size(0));
SearchResponse response = client().search(request).actionGet();
if (response.getHits().getTotalHits() >= minNumDocsReplicated) {
try {
internalCluster().stopRandomNonMasterNode();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return true;
} else {
return false;
}
}, 30, TimeUnit.SECONDS);

atLeastDocsIndexed("index2", minNumDocsReplicated);
internalCluster().stopRandomNonMasterNode();
logger.info("waiting for at least [{}] documents to be indexed", maxNumDocsReplicated);
atLeastDocsIndexed("index2", maxNumDocsReplicated);
run.set(false);
Expand Down Expand Up @@ -546,7 +531,7 @@ private void unfollowIndex(String index) throws Exception {
}
}
assertThat(numNodeTasks, equalTo(0));
});
}, 30, TimeUnit.SECONDS);
}

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

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

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

0 comments on commit 64695b6

Please sign in to comment.