Fix CcrRepositoryIT.testCcrRepositoryFetchesSnapshotShardSizeEtc (#64228) (#64479)

This test failed sometimes for various reasons: an empty bulk request
that can't be validated, a background force-merge that completes after
 the store stats were collected and finally an assertBusy() that waits
10 seconds while we usually wait 60s on the follower cluster in CCR
tests.

Closes #64167
This commit is contained in:
Tanguy Leroux 2020-11-02 15:47:07 +01:00 committed by GitHub
parent 2ba1b105ba
commit 2d0bddf428
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -473,13 +473,18 @@ public class CcrRepositoryIT extends CcrIntegTestCase {
TimeValue.ZERO.getStringRep())), XContentType.JSON));
final int numDocs = scaledRandomIntBetween(0, 1_000);
final BulkRequestBuilder bulkRequest = leaderClient().prepareBulk(leaderIndex, "_doc");
for (int i = 0; i < numDocs; i++) {
bulkRequest.add(new IndexRequest(leaderIndex).id(Integer.toString(i)).source("field", i));
if (numDocs > 0) {
final BulkRequestBuilder bulkRequest = leaderClient().prepareBulk(leaderIndex, "_doc");
for (int i = 0; i < numDocs; i++) {
bulkRequest.add(new IndexRequest(leaderIndex).id(Integer.toString(i)).source("field", i));
}
assertThat(bulkRequest.get().hasFailures(), is(false));
}
assertThat(bulkRequest.get().hasFailures(), is(false));
final ForceMergeResponse forceMergeResponse = leaderClient().admin().indices().prepareForceMerge(leaderIndex).setFlush(true).get();
final ForceMergeResponse forceMergeResponse = leaderClient().admin().indices().prepareForceMerge(leaderIndex)
.setMaxNumSegments(1)
.setFlush(true)
.get();
assertThat(forceMergeResponse.getSuccessfulShards(), equalTo(numberOfShards));
assertThat(forceMergeResponse.getFailedShards(), equalTo(0));
ensureLeaderGreen(leaderIndex);
@ -564,7 +569,7 @@ public class CcrRepositoryIT extends CcrIntegTestCase {
assertThat(snapshotShardSize,
equalTo(indexStats.getIndexShards().get(shardId).getPrimary().getStore().getSizeInBytes()));
}
});
}, 60L, TimeUnit.SECONDS);
blockCcrRestore.countDown();
ensureFollowerGreen(followerIndex);
@ -678,7 +683,7 @@ public class CcrRepositoryIT extends CcrIntegTestCase {
final long randomSize = randomNonNegativeLong();
assertThat(snapshotShardSizeInfo.getShardSize(primary, randomSize), equalTo(randomSize));
}
});
}, 60L, TimeUnit.SECONDS);
} finally {
transportServices.forEach(MockTransportService::clearAllRules);
}