Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST: Increase timeout testFollowIndexAndCloseNode #33333

Merged
merged 1 commit into from
Sep 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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 @@ -338,26 +337,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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 much cleaner. There was no need to stop a node inside the callback.

logger.info("waiting for at least [{}] documents to be indexed", maxNumDocsReplicated);
atLeastDocsIndexed("index2", maxNumDocsReplicated);
run.set(false);
Expand Down Expand Up @@ -548,7 +533,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 @@ -660,7 +645,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 @@ -674,7 +659,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