Added new iteration to RecoveryWhileUnderLoadTests

We want to check whether the issue causing the test to fail would be fixed by an additional refresh or not
This commit is contained in:
Luca Cavanna 2013-09-02 16:29:49 +02:00
parent fc1d6670df
commit 91c3853452
1 changed files with 27 additions and 10 deletions

View File

@ -293,26 +293,43 @@ public class RecoveryWhileUnderLoadTests extends AbstractSharedClusterTest {
}
private void iterateAssertCount(final int numberOfShards, final long numberOfDocs, int iterations) {
CountResponse[] iterationResults = new CountResponse[iterations];
boolean error = false;
for (int i = 0; i < iterations; i++) {
CountResponse countResponse = client().prepareCount().setQuery(matchAllQuery()).execute().actionGet();
logCountResponse(numberOfShards, numberOfDocs, i, countResponse);
iterationResults[i] = countResponse;
logger.info("iteration [{}] - successful shards: {} (expected {})", i, countResponse.getSuccessfulShards(), numberOfShards);
logger.info("iteration [{}] - failed shards: {} (expected 0)", i, countResponse.getFailedShards());
if (countResponse.getShardFailures() != null && countResponse.getShardFailures().length > 0) {
logger.info("iteration [{}] - shard failures: {}", i, Arrays.toString(countResponse.getShardFailures()));
if (countResponse.getCount() != numberOfDocs) {
error = true;
}
logger.info("iteration [{}] - returned documents: {} (expected {})", i, countResponse.getCount(), numberOfDocs);
}
//if there was an error we try to refresh again and run another iteration
//we want to find out if we had a refresh problem or if we are missing documents on a shard
if (error) {
logger.info("--> refreshing again");
refresh();
for (int i = 0; i < iterations; i++) {
CountResponse countResponse = iterationResults[i];
assertHitCount(countResponse, numberOfDocs);
CountResponse countResponse = client().prepareCount().setQuery(matchAllQuery()).execute().actionGet();
logCountResponse(numberOfShards, numberOfDocs, i, countResponse);
}
}
//lets now make the test fail if it was supposed to fail
for (int i = 0; i < iterations; i++) {
assertHitCount(iterationResults[i], numberOfDocs);
}
}
private void logCountResponse(int numberOfShards, long numberOfDocs, int iteration, CountResponse countResponse) {
logger.info("iteration [{}] - successful shards: {} (expected {})", iteration, countResponse.getSuccessfulShards(), numberOfShards);
logger.info("iteration [{}] - failed shards: {} (expected 0)", iteration, countResponse.getFailedShards());
if (countResponse.getShardFailures() != null && countResponse.getShardFailures().length > 0) {
logger.info("iteration [{}] - shard failures: {}", iteration, Arrays.toString(countResponse.getShardFailures()));
}
logger.info("iteration [{}] - returned documents: {} (expected {})", iteration, countResponse.getCount(), numberOfDocs);
}
private void refreshAndAssert(final int numberOfShards) throws InterruptedException {
assertThat(awaitBusy(new Predicate<Object>() {
public boolean apply(Object o) {