Skip to content

Commit

Permalink
Install plugins in a single transaction in tests (#51433)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jasontedor committed Jan 24, 2020
1 parent bdb8b6a commit f38eae7
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,27 @@ public synchronized void start() {
}
createConfiguration();

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

if (getVersion().before("6.3.0") && testDistribution == TestDistribution.DEFAULT) {
LOGGER.info("emulating the {} flavor for {} by installing x-pack", testDistribution, getVersion());
runElasticsearchBinScript("elasticsearch-plugin", "install", "--batch", "x-pack");
logToProcessStdout("emulating the " + testDistribution + " flavor for " + getVersion() + " by installing x-pack");
pluginsToInstall.add("x-pack");
}

if (pluginsToInstall.isEmpty() == false) {
if (getVersion().onOrAfter("7.6.0")) {
logToProcessStdout("installing " + pluginsToInstall.size() + " plugins in a single transaction");
final String[] arguments = Stream.concat(Stream.of("install", "--batch"), pluginsToInstall.stream()).toArray(String[]::new);
runElasticsearchBinScript("elasticsearch-plugin", arguments);
logToProcessStdout("installed plugins");
} else {
logToProcessStdout("installing " + pluginsToInstall.size() + " plugins sequentially");
pluginsToInstall.forEach(plugin -> runElasticsearchBinScript("elasticsearch-plugin", "install", "--batch", plugin));
logToProcessStdout("installed plugins");
}
}

if (keystoreSettings.isEmpty() == false || keystoreFiles.isEmpty() == false) {
Expand Down

0 comments on commit f38eae7

Please sign in to comment.