Skip to content

Commit e74c237

Browse files
authored
Enable online prewarming SPI in integration tests (elastic#126777)
Integration tests use the MockNode. This adds the SPI lookup when building the MockSearchService. This will enable us to have the online prewarming implementation avilable in ESIntegTestCase.
1 parent 5a6509a commit e74c237

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

test/framework/src/main/java/org/elasticsearch/node/MockNode.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.node;
1111

12+
import org.elasticsearch.action.search.OnlinePrewarmingService;
13+
import org.elasticsearch.action.search.OnlinePrewarmingServiceProvider;
1214
import org.elasticsearch.client.internal.node.NodeClient;
1315
import org.elasticsearch.cluster.ClusterInfoService;
1416
import org.elasticsearch.cluster.MockInternalClusterInfoService;
@@ -117,6 +119,10 @@ SearchService newSearchService(
117119
tracer
118120
);
119121
}
122+
OnlinePrewarmingService onlinePrewarmingService = pluginsService.loadSingletonServiceProvider(
123+
OnlinePrewarmingServiceProvider.class,
124+
() -> OnlinePrewarmingServiceProvider.DEFAULT
125+
).create(clusterService.getSettings(), threadPool, clusterService);
120126
return new MockSearchService(
121127
clusterService,
122128
indicesService,
@@ -126,7 +132,8 @@ SearchService newSearchService(
126132
fetchPhase,
127133
circuitBreakerService,
128134
executorSelector,
129-
tracer
135+
tracer,
136+
onlinePrewarmingService
130137
);
131138
}
132139

test/framework/src/main/java/org/elasticsearch/search/MockSearchService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public MockSearchService(
8585
FetchPhase fetchPhase,
8686
CircuitBreakerService circuitBreakerService,
8787
ExecutorSelector executorSelector,
88-
Tracer tracer
88+
Tracer tracer,
89+
OnlinePrewarmingService onlinePrewarmingService
8990
) {
9091
super(
9192
clusterService,
@@ -97,7 +98,7 @@ public MockSearchService(
9798
circuitBreakerService,
9899
executorSelector,
99100
tracer,
100-
OnlinePrewarmingService.NOOP
101+
onlinePrewarmingService
101102
);
102103
}
103104

0 commit comments

Comments
 (0)