Skip to content

Commit 26ecddb

Browse files
Starting integration tests
1 parent e42c29c commit 26ecddb

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/AuthorizationTaskExecutorIT.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,44 @@
77

88
package org.elasticsearch.xpack.inference.integration;
99

10-
import org.elasticsearch.cluster.ClusterState;
10+
import org.elasticsearch.common.settings.Settings;
1111
import org.elasticsearch.plugins.Plugin;
1212
import org.elasticsearch.reindex.ReindexPlugin;
1313
import org.elasticsearch.test.ESSingleNodeTestCase;
1414
import org.elasticsearch.test.http.MockWebServer;
1515
import org.elasticsearch.threadpool.ThreadPool;
1616
import org.elasticsearch.xpack.inference.LocalStateInferencePlugin;
1717
import org.elasticsearch.xpack.inference.registry.ModelRegistry;
18+
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceSettings;
1819
import org.elasticsearch.xpack.inference.services.elastic.authorization.AuthorizationTaskExecutor;
1920
import org.junit.After;
2021
import org.junit.Before;
22+
import org.junit.BeforeClass;
2123

24+
import java.io.IOException;
2225
import java.util.Collection;
2326

2427
import static org.elasticsearch.xpack.inference.Utils.inferenceUtilityExecutors;
2528
import static org.elasticsearch.xpack.inference.external.http.Utils.getUrl;
2629

2730
public class AuthorizationTaskExecutorIT extends ESSingleNodeTestCase {
2831

32+
private static final MockWebServer webServer = new MockWebServer();
33+
private static String gatewayUrl;
34+
2935
private ModelRegistry modelRegistry;
30-
private final MockWebServer webServer = new MockWebServer();
3136
private ThreadPool threadPool;
32-
private String gatewayUrl;
3337

34-
@Before
35-
public void createComponents() throws Exception {
36-
threadPool = createThreadPool(inferenceUtilityExecutors());
38+
@BeforeClass
39+
public static void initClass() throws IOException {
3740
webServer.start();
3841
gatewayUrl = getUrl(webServer);
42+
}
43+
44+
@Before
45+
public void createComponents() {
46+
threadPool = createThreadPool(inferenceUtilityExecutors());
3947
modelRegistry = node().injector().getInstance(ModelRegistry.class);
40-
node().injector().getInstance(ClusterState.class);
4148
}
4249

4350
@After
@@ -47,8 +54,11 @@ public void shutdown() {
4754
}
4855

4956
@Override
50-
protected boolean resetNodeAfterTest() {
51-
return true;
57+
protected Settings nodeSettings() {
58+
return Settings.builder()
59+
.put(ElasticInferenceServiceSettings.ELASTIC_INFERENCE_SERVICE_URL.getKey(), gatewayUrl)
60+
.put(ElasticInferenceServiceSettings.PERIODIC_AUTHORIZATION_ENABLED.getKey(), false)
61+
.build();
5262
}
5363

5464
@Override

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,13 @@ public Collection<?> createComponents(PluginServices services) {
331331
services.threadPool()
332332
);
333333

334-
var eisComponents = new ElasticInferenceServiceComponents(inferenceServiceSettings.getElasticInferenceServiceUrl());
335-
336334
var authTaskExecutor = AuthorizationTaskExecutor.create(
337335
services.clusterService(),
338336
new AuthorizationPoller.Parameters(
339337
serviceComponents.get(),
340338
authorizationHandler,
341339
elasticInferenceServiceFactory.get().createSender(),
342340
inferenceServiceSettings,
343-
eisComponents,
344341
modelRegistry.get(),
345342
services.client()
346343
)

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/ElasticInferenceServiceSettings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class ElasticInferenceServiceSettings {
2828
@Deprecated
2929
static final Setting<String> EIS_GATEWAY_URL = Setting.simpleString("xpack.inference.eis.gateway.url", Setting.Property.NodeScope);
3030

31-
static final Setting<String> ELASTIC_INFERENCE_SERVICE_URL = Setting.simpleString(
31+
public static final Setting<String> ELASTIC_INFERENCE_SERVICE_URL = Setting.simpleString(
3232
"xpack.inference.elastic.url",
3333
Setting.Property.NodeScope
3434
);
@@ -37,7 +37,7 @@ public class ElasticInferenceServiceSettings {
3737
* This setting is for testing only. It controls whether authorization is only performed once at bootup. If set to true, an
3838
* authorization request will be made repeatedly on an interval.
3939
*/
40-
static final Setting<Boolean> PERIODIC_AUTHORIZATION_ENABLED = Setting.boolSetting(
40+
public static final Setting<Boolean> PERIODIC_AUTHORIZATION_ENABLED = Setting.boolSetting(
4141
"xpack.inference.elastic.periodic_authorization_enabled",
4242
true,
4343
Setting.Property.NodeScope

0 commit comments

Comments
 (0)