test: simplify percolator recovery test by only testing what is needed

Running requests via the percolate or mpercolate api is irrelevant.
What is relevant is that when nodes come back that they report the expected number of matches.
This commit is contained in:
Martijn van Groningen 2016-01-11 13:13:56 +01:00
parent 55b0eced04
commit ace1b33c3c
1 changed files with 21 additions and 60 deletions

View File

@ -219,18 +219,9 @@ public class RecoveryPercolatorIT extends ESIntegTestCase {
assertThat(response.getMatches()[0].getId().string(), equalTo("100"));
}
public void testSinglePercolatorRecovery() throws Exception {
percolatorRecovery(false);
}
@AwaitsFix(bugUrl = "sometimes reprodes with: gradle :core:integTest -Dtests.seed=21DDCAA92013B00C -Dtests.class=org.elasticsearch.percolator.RecoveryPercolatorIT -Dtests.method=\"testMultiPercolatorRecovery\"")
public void testMultiPercolatorRecovery() throws Exception {
percolatorRecovery(true);
}
public void testPercolatorRecovery() throws Exception {
// 3 nodes, 2 primary + 2 replicas per primary, so each node should have a copy of the data.
// We only start and stop nodes 2 and 3, so all requests should succeed and never be partial.
private void percolatorRecovery(final boolean multiPercolate) throws Exception {
internalCluster().startNode(settingsBuilder().put("node.stay", true));
internalCluster().startNode(settingsBuilder().put("node.stay", false));
internalCluster().startNode(settingsBuilder().put("node.stay", false));
@ -260,37 +251,9 @@ public class RecoveryPercolatorIT extends ESIntegTestCase {
final AtomicBoolean run = new AtomicBoolean(true);
final AtomicReference<Throwable> error = new AtomicReference<>();
Runnable r = new Runnable() {
@Override
public void run() {
Runnable r = () -> {
try {
while (run.get()) {
if (multiPercolate) {
MultiPercolateRequestBuilder builder = client
.prepareMultiPercolate();
int numPercolateRequest = randomIntBetween(50, 100);
for (int i = 0; i < numPercolateRequest; i++) {
PercolateRequestBuilder percolateBuilder = client.preparePercolate()
.setIndices("test").setDocumentType("type").setSize(numQueries);
if (randomBoolean()) {
percolateBuilder.setGetRequest(Requests.getRequest("test").type("type").id("1"));
} else {
percolateBuilder.setPercolateDoc(docBuilder().setDoc(document));
}
builder.add(percolateBuilder);
}
MultiPercolateResponse response = builder.get();
assertThat(response.items().length, equalTo(numPercolateRequest));
for (MultiPercolateResponse.Item item : response) {
assertThat(item.isFailure(), equalTo(false));
assertNoFailures(item.getResponse());
assertThat(item.getResponse().getSuccessfulShards(), equalTo(item.getResponse().getTotalShards()));
assertThat(item.getResponse().getCount(), equalTo((long) numQueries));
assertThat(item.getResponse().getMatches().length, equalTo(numQueries));
}
} else {
PercolateRequestBuilder percolateBuilder = client.preparePercolate()
.setIndices("test").setDocumentType("type").setSize(numQueries);
if (randomBoolean()) {
@ -304,13 +267,11 @@ public class RecoveryPercolatorIT extends ESIntegTestCase {
assertThat(response.getCount(), equalTo((long) numQueries));
assertThat(response.getMatches().length, equalTo(numQueries));
}
}
} catch (Throwable t) {
logger.info("Error in percolate thread...", t);
run.set(false);
error.set(t);
}
}
};
Thread t = new Thread(r);
t.start();