Skip to content

Commit

Permalink
[Transform] Use test threadpool to avoid conflict with other tests (#…
Browse files Browse the repository at this point in the history
…65721)

use a test threadpool instead of the generic threadpool in test

fixes #65542
  • Loading branch information
Hendrik Muhs authored Dec 2, 2020
1 parent 0f406f1 commit 95fda0a
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.elasticsearch.search.suggest.Suggest;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.client.NoOpClient;
import org.elasticsearch.threadpool.ScalingExecutorBuilder;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.indexing.IndexerState;
Expand Down Expand Up @@ -88,6 +89,7 @@ public class TransformIndexerStateTests extends ESTestCase {

private Client client;
private ThreadPool threadPool;
private String executorName;
private TransformAuditor auditor;
private TransformConfigManager transformConfigManager;

Expand Down Expand Up @@ -234,7 +236,9 @@ public void setUpMocks() {
auditor = MockTransformAuditor.createMockAuditor();
transformConfigManager = new InMemoryTransformConfigManager();
client = new NoOpClient(getTestName());
threadPool = new TestThreadPool(ThreadPool.Names.GENERIC);
// we need "generic" as part of the name, because it is asserted
executorName = ThreadPool.Names.GENERIC + "-" + getTestName();
threadPool = new TestThreadPool(executorName, new ScalingExecutorBuilder(executorName, 4, 10, TimeValue.timeValueSeconds(30)));
}

@After
Expand Down Expand Up @@ -268,7 +272,7 @@ public void testStopAtCheckpoint() throws Exception {
stateRef,
null,
threadPool,
ThreadPool.Names.GENERIC,
executorName,
auditor,
new TransformIndexerStats(),
context
Expand All @@ -294,7 +298,7 @@ public void testStopAtCheckpoint() throws Exception {
state,
null,
threadPool,
ThreadPool.Names.GENERIC,
executorName,
auditor,
new TransformIndexerStats(),
context
Expand Down Expand Up @@ -324,7 +328,7 @@ public void testStopAtCheckpoint() throws Exception {
state,
null,
threadPool,
ThreadPool.Names.GENERIC,
executorName,
auditor,
new TransformIndexerStats(),
context
Expand Down Expand Up @@ -355,7 +359,7 @@ public void testStopAtCheckpoint() throws Exception {
state,
null,
threadPool,
ThreadPool.Names.GENERIC,
executorName,
auditor,
new TransformIndexerStats(),
context
Expand Down Expand Up @@ -399,7 +403,7 @@ public void testStopAtCheckpoint() throws Exception {
state,
null,
threadPool,
ThreadPool.Names.GENERIC,
executorName,
auditor,
new TransformIndexerStats(),
context
Expand Down Expand Up @@ -471,7 +475,7 @@ public void testStopAtCheckpointForThrottledTransform() throws Exception {
state,
null,
threadPool,
ThreadPool.Names.GENERIC,
executorName,
auditor,
new TransformIndexerStats(),
context
Expand Down Expand Up @@ -532,7 +536,7 @@ private void setStopAtCheckpoint(
) {
// we need to simulate that this is called from the task, which offloads it to the generic threadpool
CountDownLatch latch = new CountDownLatch(1);
threadPool.executor(ThreadPool.Names.GENERIC).execute(() -> {
threadPool.executor(executorName).execute(() -> {
indexer.setStopAtCheckpoint(shouldStopAtCheckpoint, shouldStopAtCheckpointListener);
latch.countDown();
});
Expand Down

0 comments on commit 95fda0a

Please sign in to comment.