Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.external.http.Utils.getUrl;
import static org.elasticsearch.xpack.inference.services.ServiceComponentsTests.createWithEmptySettings;
Expand All @@ -59,7 +59,7 @@ public class InferenceRevokeDefaultEndpointsIT extends ESSingleNodeTestCase {

@Before
public void createComponents() throws Exception {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
webServer.start();
gatewayUrl = getUrl(webServer);
modelRegistry = node().injector().getInstance(ModelRegistry.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public static ClusterService mockClusterService(Settings settings) {
return clusterService;
}

public static ScalingExecutorBuilder inferenceUtilityPool() {
return new ScalingExecutorBuilder(
public static ScalingExecutorBuilder[] inferenceUtilityExecutors() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename and return an array.

createThreadPool() signature is:

protected TestThreadPool createThreadPool(ExecutorBuilder<?>... executorBuilders) {

return new ScalingExecutorBuilder[] {new ScalingExecutorBuilder(
UTILITY_THREAD_POOL_NAME,
1,
4,
TimeValue.timeValueMinutes(10),
false,
"xpack.inference.utility_thread_pool"
);
)};
}

public static void storeSparseModel(String inferenceId, ModelRegistry modelRegistry) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.Map;
import java.util.Optional;

import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
Expand All @@ -59,7 +59,7 @@ public class TransportDeleteInferenceEndpointActionTests extends ESTestCase {
@Before
public void setUp() throws Exception {
super.setUp();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
mockModelRegistry = mock(ModelRegistry.class);
mockInferenceServiceRegistry = mock(InferenceServiceRegistry.class);
action = new TransportDeleteInferenceEndpointAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.hamcrest.Matchers.is;

public class AdjustableCapacityBlockingQueueTests extends ESTestCase {
Expand All @@ -46,7 +46,7 @@ public BlockingQueue<Integer> create() {

@Before
public void init() {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterService;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.external.http.HttpClientTests.createHttpPost;
Expand All @@ -46,7 +46,7 @@ public class HttpClientManagerTests extends ESTestCase {
@Before
public void init() throws Exception {
webServer.start();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterService;
import static org.elasticsearch.xpack.inference.logging.ThrottlerManagerTests.mockThrottlerManager;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -65,7 +65,7 @@ public class HttpClientTests extends ESTestCase {
@Before
public void init() throws Exception {
webServer.start();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.concurrent.atomic.AtomicReference;

import static org.elasticsearch.xpack.inference.InferencePlugin.UTILITY_THREAD_POOL_NAME;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -507,7 +507,7 @@ public void testDoubleSubscribeFails() {
*/
public void testReuseMlThread() throws ExecutionException, InterruptedException, TimeoutException {
try {
threadPool = spy(createThreadPool(inferenceUtilityPool()));
threadPool = spy(createThreadPool(inferenceUtilityExecutors()));
publisher = new StreamingHttpResultPublisher(threadPool, settings, listener());
var subscriber = new TestSubscriber();
publisher.responseReceived(mock(HttpResponse.class));
Expand Down Expand Up @@ -537,7 +537,7 @@ public void testReuseMlThread() throws ExecutionException, InterruptedException,
public void testCancelBreaksInfiniteLoop() throws Exception {
try {
var futureHolder = new AtomicReference<CompletableFuture<Void>>();
threadPool = spy(createThreadPool(inferenceUtilityPool()));
threadPool = spy(createThreadPool(inferenceUtilityExecutors()));
doAnswer(utilityThreadPool -> {
var realExecutorService = (ExecutorService) utilityThreadPool.callRealMethod();
var executorServiceSpy = spy(realExecutorService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.core.inference.results.TextEmbeddingFloatResultsTests.buildExpectationFloat;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.external.http.Utils.entityAsMap;
import static org.elasticsearch.xpack.inference.external.http.Utils.getUrl;
Expand Down Expand Up @@ -75,7 +75,7 @@ public class HttpRequestSenderTests extends ESTestCase {
@Before
public void init() throws Exception {
webServer.start();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
clientManager = HttpClientManager.create(Settings.EMPTY, threadPool, mockClusterServiceEmpty(), mock(ThrottlerManager.class));
threadRef.set(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.util.concurrent.TimeoutException;

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.common.AdjustableCapacityBlockingQueueTests.mockQueueCreator;
import static org.elasticsearch.xpack.inference.external.http.sender.RequestExecutorServiceSettingsTests.createRequestExecutorServiceSettings;
import static org.elasticsearch.xpack.inference.external.http.sender.RequestExecutorServiceSettingsTests.createRequestExecutorServiceSettingsEmpty;
Expand All @@ -63,7 +63,7 @@ public class RequestExecutorServiceTests extends ESTestCase {

@Before
public void init() {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.concurrent.atomic.AtomicReference;

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
Expand All @@ -45,7 +45,7 @@ public class RequestTaskTests extends ESTestCase {

@Before
public void init() throws Exception {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.concurrent.atomic.AtomicReference;

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
Expand All @@ -42,7 +42,7 @@ public class TimedListenerTests extends ESTestCase {

@Before
public void init() throws Exception {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.junit.After;
import org.junit.Before;

import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.logging.ThrottlerTests.mockLogger;
import static org.mockito.ArgumentMatchers.any;
Expand All @@ -33,7 +33,7 @@ public class ThrottlerManagerTests extends ESTestCase {

@Before
public void init() {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
taskQueue = new DeterministicTaskQueue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import static org.elasticsearch.xpack.inference.Utils.getInvalidModel;
import static org.elasticsearch.xpack.inference.Utils.getPersistedConfigMap;
import static org.elasticsearch.xpack.inference.Utils.getRequestConfigMap;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
Expand All @@ -62,7 +62,7 @@ public abstract class AbstractInferenceServiceTests extends InferenceServiceTest
public void setUp() throws Exception {
super.setUp();
webServer.start();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
clientManager = HttpClientManager.create(Settings.EMPTY, threadPool, mockClusterServiceEmpty(), mock(ThrottlerManager.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.external.http.Utils.getUrl;
import static org.elasticsearch.xpack.inference.external.http.sender.HttpRequestSenderTests.createSender;
Expand All @@ -59,7 +59,7 @@ public abstract class ChatCompletionActionTests extends ESTestCase {
@Before
public void init() throws Exception {
webServer.start();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
clientManager = HttpClientManager.create(Settings.EMPTY, threadPool, mockClusterServiceEmpty(), mock(ThrottlerManager.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterService;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.services.ServiceComponentsTests.createWithEmptySettings;
Expand All @@ -56,7 +56,7 @@ public class SenderServiceTests extends ESTestCase {

@Before
public void init() throws Exception {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
import static org.elasticsearch.common.xcontent.XContentHelper.toXContent;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXContentEquivalent;
import static org.elasticsearch.xcontent.ToXContent.EMPTY_PARAMS;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.external.http.Utils.getUrl;
import static org.elasticsearch.xpack.inference.services.ServiceComponentsTests.createWithEmptySettings;
Expand Down Expand Up @@ -172,7 +172,7 @@ protected String fetchPersistedConfigTaskTypeParsingErrorMessageFormat() {
@Before
public void init() throws Exception {
webServer.start();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
clientManager = HttpClientManager.create(Settings.EMPTY, threadPool, mockClusterServiceEmpty(), mock(ThrottlerManager.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.util.concurrent.TimeUnit;

import static org.elasticsearch.xpack.core.inference.results.ChatCompletionResultsTests.buildExpectationCompletion;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.external.http.Utils.entityAsMap;
import static org.elasticsearch.xpack.inference.external.http.Utils.getUrl;
Expand All @@ -58,7 +58,7 @@ public class Ai21ActionCreatorTests extends ESTestCase {
@Before
public void init() throws Exception {
webServer.start();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
clientManager = HttpClientManager.create(Settings.EMPTY, threadPool, mockClusterServiceEmpty(), mock(ThrottlerManager.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import static org.elasticsearch.common.xcontent.XContentHelper.toXContent;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertToXContentEquivalent;
import static org.elasticsearch.xpack.inference.Utils.getPersistedConfigMap;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests.createRandomChunkingSettingsMap;
import static org.elasticsearch.xpack.inference.services.ServiceComponentsTests.createWithEmptySettings;
Expand All @@ -82,7 +82,7 @@ public class AlibabaCloudSearchServiceTests extends InferenceServiceTestCase {

@Before
public void init() throws Exception {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
clientManager = HttpClientManager.create(Settings.EMPTY, threadPool, mockClusterServiceEmpty(), mock(ThrottlerManager.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import static org.apache.lucene.tests.util.LuceneTestCase.expectThrows;
import static org.elasticsearch.xpack.core.inference.results.ChatCompletionResultsTests.buildExpectationCompletion;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.external.action.ActionUtils.constructFailedToSendRequestMessage;
import static org.elasticsearch.xpack.inference.services.settings.DefaultSecretSettingsTests.getSecretSettingsMap;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
Expand All @@ -62,7 +60,7 @@ public class AlibabaCloudSearchCompletionActionTests extends ESTestCase {
@Before
public void init() throws IOException {
webServer.start();
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
clientManager = HttpClientManager.create(Settings.EMPTY, threadPool, mockClusterServiceEmpty(), mock(ThrottlerManager.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import static org.elasticsearch.xpack.core.inference.results.ChatCompletionResultsTests.buildExpectationCompletion;
import static org.elasticsearch.xpack.core.inference.results.TextEmbeddingFloatResultsTests.buildExpectationFloat;
import static org.elasticsearch.xpack.inference.Utils.getInvalidModel;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.elasticsearch.xpack.inference.Utils.mockClusterServiceEmpty;
import static org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests.createRandomChunkingSettings;
import static org.elasticsearch.xpack.inference.chunking.ChunkingSettingsTests.createRandomChunkingSettingsMap;
Expand All @@ -99,7 +99,7 @@ public class AmazonBedrockServiceTests extends InferenceServiceTestCase {

@Before
public void init() throws Exception {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import static org.elasticsearch.xpack.core.inference.results.ChatCompletionResultsTests.buildExpectationCompletion;
import static org.elasticsearch.xpack.core.inference.results.TextEmbeddingFloatResultsTests.buildExpectationFloat;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityPool;
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
import static org.hamcrest.Matchers.is;

public class AmazonBedrockActionCreatorTests extends ESTestCase {
Expand All @@ -43,7 +43,7 @@ public class AmazonBedrockActionCreatorTests extends ESTestCase {

@Before
public void init() throws Exception {
threadPool = createThreadPool(inferenceUtilityPool());
threadPool = createThreadPool(inferenceUtilityExecutors());
}

@After
Expand Down
Loading