Browse Source

[reindex] Don't get rejected

BulkByScrollTaskTest#testDelayAndRethrottle was getting rejected exceptions
every once in a while. This was reproducible ~20% of the time for me. I
added a CyclicBarrier to prevent the test from shutting down the thread pool
before the threads get finished.
Nik Everett 9 years ago
parent
commit
14d37baa4b

+ 3 - 0
modules/reindex/src/test/java/org/elasticsearch/index/reindex/BulkByScrollTaskTests.java

@@ -28,6 +28,7 @@ import org.junit.Before;
 import java.io.IOException;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -146,6 +147,7 @@ public class BulkByScrollTaskTests extends ESTestCase {
         List<Throwable> errors = new CopyOnWriteArrayList<>();
         AtomicBoolean done = new AtomicBoolean();
         int threads = between(1, 10);
+        CyclicBarrier waitForShutdown = new CyclicBarrier(threads);
 
         /*
          * We never end up waiting this long because the test rethrottles over and over again, ratcheting down the delay a random amount
@@ -188,6 +190,7 @@ public class BulkByScrollTaskTests extends ESTestCase {
                         rethrottles += 1;
                     }
                     logger.info("Rethrottled [{}] times", rethrottles);
+                    waitForShutdown.await();
                 } catch (Exception e) {
                     errors.add(e);
                 }