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:
parent
55b0eced04
commit
ace1b33c3c
|
@ -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);
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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.
|
||||
internalCluster().startNode(settingsBuilder().put("node.stay", true));
|
||||
internalCluster().startNode(settingsBuilder().put("node.stay", false));
|
||||
internalCluster().startNode(settingsBuilder().put("node.stay", false));
|
||||
|
@ -260,56 +251,26 @@ 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() {
|
||||
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()) {
|
||||
percolateBuilder.setPercolateDoc(docBuilder().setDoc(document));
|
||||
} else {
|
||||
percolateBuilder.setGetRequest(Requests.getRequest("test").type("type").id("1"));
|
||||
}
|
||||
PercolateResponse response = percolateBuilder.get();
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getSuccessfulShards(), equalTo(response.getTotalShards()));
|
||||
assertThat(response.getCount(), equalTo((long) numQueries));
|
||||
assertThat(response.getMatches().length, equalTo(numQueries));
|
||||
}
|
||||
Runnable r = () -> {
|
||||
try {
|
||||
while (run.get()) {
|
||||
PercolateRequestBuilder percolateBuilder = client.preparePercolate()
|
||||
.setIndices("test").setDocumentType("type").setSize(numQueries);
|
||||
if (randomBoolean()) {
|
||||
percolateBuilder.setPercolateDoc(docBuilder().setDoc(document));
|
||||
} else {
|
||||
percolateBuilder.setGetRequest(Requests.getRequest("test").type("type").id("1"));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.info("Error in percolate thread...", t);
|
||||
run.set(false);
|
||||
error.set(t);
|
||||
PercolateResponse response = percolateBuilder.get();
|
||||
assertNoFailures(response);
|
||||
assertThat(response.getSuccessfulShards(), equalTo(response.getTotalShards()));
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue