[TEST] Prevent RelocationTests from going crazy when relocations take time
This commit is contained in:
parent
124d370b5f
commit
a5aafbb04c
|
@ -21,6 +21,7 @@ package org.elasticsearch.recovery;
|
|||
|
||||
import com.carrotsearch.hppc.IntOpenHashSet;
|
||||
import com.carrotsearch.hppc.procedures.IntProcedure;
|
||||
import com.carrotsearch.randomizedtesting.RandomizedTest;
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||
|
@ -128,8 +129,8 @@ public class RelocationTests extends ElasticsearchIntegrationTest {
|
|||
}
|
||||
}
|
||||
|
||||
try (BackgroundIndexer indexer = new BackgroundIndexer("test", "type1", client())) {
|
||||
final int numDocs = scaledRandomIntBetween(200, 2500);
|
||||
final int numDocs = scaledRandomIntBetween(200, 2500);
|
||||
try (BackgroundIndexer indexer = new BackgroundIndexer("test", "type1", client(), scaledRandomIntBetween(2, 5), true, numDocs * 2)) {
|
||||
logger.info("--> waiting for {} docs to be indexed ...", numDocs);
|
||||
waitForDocs(numDocs, indexer);
|
||||
logger.info("--> {} docs indexed", numDocs);
|
||||
|
|
|
@ -54,10 +54,10 @@ public class BackgroundIndexer implements AutoCloseable {
|
|||
}
|
||||
|
||||
public BackgroundIndexer(String index, String type, Client client, int writerCount) {
|
||||
this(index, type, client, writerCount, true);
|
||||
this(index, type, client, writerCount, true, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public BackgroundIndexer(final String index, final String type, final Client client, final int writerCount, boolean autoStart) {
|
||||
public BackgroundIndexer(final String index, final String type, final Client client, final int writerCount, boolean autoStart, final int maxNumDocs) {
|
||||
|
||||
failures = new CopyOnWriteArrayList<>();
|
||||
writers = new Thread[writerCount];
|
||||
|
@ -73,7 +73,7 @@ public class BackgroundIndexer implements AutoCloseable {
|
|||
try {
|
||||
startLatch.await();
|
||||
logger.info("**** starting indexing thread {}", indexerId);
|
||||
while (!stop.get()) {
|
||||
while (!stop.get() && indexCounter.get() < maxNumDocs) { // step out once we reach the hard limit
|
||||
if (batch) {
|
||||
int batchSize = RandomizedTest.getRandom().nextInt(20) + 1;
|
||||
BulkRequestBuilder bulkRequest = client.prepareBulk();
|
||||
|
@ -97,7 +97,7 @@ public class BackgroundIndexer implements AutoCloseable {
|
|||
indexCounter.incrementAndGet();
|
||||
}
|
||||
}
|
||||
logger.info("**** done indexing thread {}", indexerId);
|
||||
logger.info("**** done indexing thread {} stop: {} numDocsIndexed: {} maxNumDocs: {}", indexerId, stop.get(), indexCounter.get(), maxNumDocs);
|
||||
} catch (Throwable e) {
|
||||
failures.add(e);
|
||||
logger.warn("**** failed indexing thread {} on doc id {}", e, indexerId, id);
|
||||
|
|
Loading…
Reference in New Issue