Skip to content

Commit d72c5e6

Browse files
committed
Install plugins in a single transaction in tests (#51433)
When building clusters for integration tests, today we install plugins sequentially. We recently introduced the ability to install plugins in a single invocation of the install plugin command. Using this can save substantial time starting up JVMs. This commit changes the build infrastructure to install multiple plugins at once when building clusters for integration tests. For the docs integration tests in particular, where we install many plugins, this change makes a substantial difference. On my laptop, prior to this change, installing the plugins sequentially took 115 seconds. After this change, it takes 14 seconds.
1 parent 128b91a commit d72c5e6

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,27 @@ public synchronized void start() {
422422
}
423423
createConfiguration();
424424

425+
final List<String> pluginsToInstall = new ArrayList<>();
425426
if (plugins.isEmpty() == false) {
426-
logToProcessStdout("Installing " + plugins.size() + " plugins");
427-
plugins.forEach(plugin -> runElasticsearchBinScript("elasticsearch-plugin", "install", "--batch", plugin.toString()));
427+
pluginsToInstall.addAll(plugins.stream().map(URI::toString).collect(Collectors.toList()));
428428
}
429429

430430
if (getVersion().before("6.3.0") && testDistribution == TestDistribution.DEFAULT) {
431-
LOGGER.info("emulating the {} flavor for {} by installing x-pack", testDistribution, getVersion());
432-
runElasticsearchBinScript("elasticsearch-plugin", "install", "--batch", "x-pack");
431+
logToProcessStdout("emulating the " + testDistribution + " flavor for " + getVersion() + " by installing x-pack");
432+
pluginsToInstall.add("x-pack");
433+
}
434+
435+
if (pluginsToInstall.isEmpty() == false) {
436+
if (getVersion().onOrAfter("7.6.0")) {
437+
logToProcessStdout("installing " + pluginsToInstall.size() + " plugins in a single transaction");
438+
final String[] arguments = Stream.concat(Stream.of("install", "--batch"), pluginsToInstall.stream()).toArray(String[]::new);
439+
runElasticsearchBinScript("elasticsearch-plugin", arguments);
440+
logToProcessStdout("installed plugins");
441+
} else {
442+
logToProcessStdout("installing " + pluginsToInstall.size() + " plugins sequentially");
443+
pluginsToInstall.forEach(plugin -> runElasticsearchBinScript("elasticsearch-plugin", "install", "--batch", plugin));
444+
logToProcessStdout("installed plugins");
445+
}
433446
}
434447

435448
if (keystoreSettings.isEmpty() == false || keystoreFiles.isEmpty() == false) {

0 commit comments

Comments
 (0)