[TEST] Add more randomization to bulk tests

This commit is contained in:
Simon Willnauer 2014-04-08 11:38:08 +02:00
parent fd8a6ac382
commit c58b823e9f
1 changed files with 9 additions and 5 deletions

View File

@ -216,7 +216,11 @@ public class BulkTests extends ElasticsearchIntegrationTest {
createIndex("test");
ensureGreen();
int numDocs = 2000;
int numDocs = scaledRandomIntBetween(100, 2000);
if (numDocs % 2 == 1) {
numDocs++; // this test needs an even num of docs
}
logger.info("Bulk-Indexing {} docs", numDocs);
BulkRequestBuilder builder = client().prepareBulk();
for (int i = 0; i < numDocs; i++) {
builder.add(
@ -356,11 +360,11 @@ public class BulkTests extends ElasticsearchIntegrationTest {
.put(indexSettings())
.put("index.number_of_replicas", replica)));
int numDocs = 5000;
int bulk = 50;
int numDocs = scaledRandomIntBetween(100, 5000);
int bulk = scaledRandomIntBetween(1, 99);
for (int i = 0; i < numDocs; ) {
BulkRequestBuilder builder = client().prepareBulk();
for (int j = 0; j < bulk; j++, i++) {
final BulkRequestBuilder builder = client().prepareBulk();
for (int j = 0; j < bulk && i < numDocs; j++, i++) {
builder.add(client().prepareIndex("test", "type1", Integer.toString(i)).setSource("val", i));
}
logger.info("bulk indexing {}-{}", i - bulk, i - 1);