Skip to content

Commit 584918e

Browse files
Save duplicate REST client in ESRestTestCase (#117910)
I debugged some tests today and noticed that these two clients are the same in almost all cases, no need to use extra connections. Might give usa small speedup for these tests that tend to be quite slow relative to the node client based tests.
1 parent 7070e95 commit 584918e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,11 @@ public void initClient() throws IOException {
333333
assert testFeatureServiceInitialized() == false;
334334
clusterHosts = parseClusterHosts(getTestRestCluster());
335335
logger.info("initializing REST clients against {}", clusterHosts);
336-
client = buildClient(restClientSettings(), clusterHosts.toArray(new HttpHost[clusterHosts.size()]));
337-
adminClient = buildClient(restAdminSettings(), clusterHosts.toArray(new HttpHost[clusterHosts.size()]));
336+
var clientSettings = restClientSettings();
337+
var adminSettings = restAdminSettings();
338+
var hosts = clusterHosts.toArray(new HttpHost[0]);
339+
client = buildClient(clientSettings, hosts);
340+
adminClient = clientSettings.equals(adminSettings) ? client : buildClient(adminSettings, hosts);
338341

339342
availableFeatures = EnumSet.of(ProductFeature.LEGACY_TEMPLATES);
340343
Set<String> versions = new HashSet<>();

0 commit comments

Comments
 (0)