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.
This commit is contained in:
Jason Tedor 2020-01-24 13:10:59 -05:00
parent bdb8b6aa0d
commit f38eae7abc
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
1 changed files with 17 additions and 4 deletions

View File

@ -422,14 +422,27 @@ public class ElasticsearchNode implements TestClusterConfiguration {
}
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) {