From 7c90f874d72a73111b585cbb41a54ee40207a528 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Thu, 25 Jan 2018 10:20:52 +0100 Subject: [PATCH] Update x-pack packaging tests to work with meta plugins (elastic/x-pack-elasticsearch#3683) relates elastic/x-pack-elasticsearch#3652 Original commit: elastic/x-pack-elasticsearch@e177b742f9b5f0fdf2ead75895b2a8f2c06975af --- qa/vagrant/build.gradle | 40 ++++++++- .../test/resources/packaging/utils/xpack.bash | 83 ++++++++++++++----- 2 files changed, 102 insertions(+), 21 deletions(-) diff --git a/qa/vagrant/build.gradle b/qa/vagrant/build.gradle index 5dce18ffefd..bc2e206c4ae 100644 --- a/qa/vagrant/build.gradle +++ b/qa/vagrant/build.gradle @@ -1,3 +1,8 @@ +import org.elasticsearch.gradle.plugin.MetaPluginBuildPlugin +import org.elasticsearch.gradle.plugin.MetaPluginPropertiesExtension +import org.elasticsearch.gradle.plugin.PluginBuildPlugin +import org.elasticsearch.gradle.plugin.PluginPropertiesExtension + apply plugin: 'elasticsearch.vagrantsupport' apply plugin: 'elasticsearch.vagrant' @@ -6,8 +11,41 @@ esvagrant { } dependencies { - bats project(path: ':x-pack-elasticsearch:plugin:core', configuration: 'zip') + // Packaging tests use the x-pack meta plugin + bats project(path: ':x-pack-elasticsearch:plugin', configuration: 'zip') // Inherit Bats test utils from :qa:vagrant project bats project(path: ':qa:vagrant', configuration: 'bats') } + +Map> metaPlugins = [:] +for (Project metaPlugin : project.rootProject.subprojects) { + if (metaPlugin.plugins.hasPlugin(MetaPluginBuildPlugin)) { + MetaPluginPropertiesExtension extension = metaPlugin.extensions.findByName('es_meta_plugin') + if (extension != null) { + List plugins = [] + metaPlugin.subprojects.each { + if (extension.plugins.contains(it.name)) { + Project plugin = (Project) it + if (plugin.plugins.hasPlugin(PluginBuildPlugin)) { + PluginPropertiesExtension esplugin = plugin.extensions.findByName('esplugin') + if (esplugin != null) { + plugins.add(esplugin.name) + } + } + } + } + metaPlugins.put(extension.name, plugins.toSorted()) + } + } +} + +setupBats { + doLast { + metaPlugins.each{ name, plugins -> + File expectedMetaPlugins = file("build/plugins/${name}.expected") + expectedMetaPlugins.parentFile.mkdirs() + expectedMetaPlugins.setText(plugins.join('\n'), 'UTF-8') + } + } +} diff --git a/qa/vagrant/src/test/resources/packaging/utils/xpack.bash b/qa/vagrant/src/test/resources/packaging/utils/xpack.bash index 31c33e04f10..e0cbf4357f3 100644 --- a/qa/vagrant/src/test/resources/packaging/utils/xpack.bash +++ b/qa/vagrant/src/test/resources/packaging/utils/xpack.bash @@ -5,36 +5,79 @@ # you may not use this file except in compliance with the Elastic License. install_xpack() { - install_and_check_plugin x pack x-pack-core-*.jar x-pack-graph-*.jar x-pack-ml-*.jar \ - x-pack-monitoring-*.jar x-pack-security-*.jar x-pack-watcher-*.jar + install_meta_plugin x-pack } # Checks that X-Pack files are correctly installed verify_xpack_installation() { + local name="x-pack" local user="$ESPLUGIN_COMMAND_USER" local group="$ESPLUGIN_COMMAND_USER" - assert_file "$ESHOME/bin/x-pack" d $user $group 755 - assert_file "$ESHOME/bin/x-pack/certgen" f $user $group 755 - assert_file "$ESHOME/bin/x-pack/croneval" f $user $group 755 - assert_file "$ESHOME/bin/x-pack/extension" f $user $group 755 - assert_file "$ESHOME/bin/x-pack/migrate" f $user $group 755 - assert_file "$ESHOME/bin/x-pack/saml-metadata" f $user $group 755 - assert_file "$ESHOME/bin/x-pack/setup-passwords" f $user $group 755 - assert_file "$ESHOME/bin/x-pack/syskeygen" f $user $group 755 - assert_file "$ESHOME/bin/x-pack/users" f $user $group 755 - assert_file "$ESHOME/bin/x-pack/x-pack-env" f $user $group 755 - assert_number_of_files "$ESHOME/bin/x-pack/" 20 + # Verify binary files + assert_file "$ESHOME/bin/$name" d $user $group 755 + local binaryFiles=( + 'certgen' + 'certgen.bat' + 'certutil' + 'certutil.bat' + 'croneval' + 'croneval.bat' + 'extension' + 'extension.bat' + 'migrate' + 'migrate.bat' + 'saml-metadata' + 'saml-metadata.bat' + 'setup-passwords' + 'setup-passwords.bat' + 'syskeygen' + 'syskeygen.bat' + 'users' + 'users.bat' + 'x-pack-env' + 'x-pack-env.bat' + 'x-pack-security-env' + 'x-pack-security-env.bat' + 'x-pack-watcher-env' + 'x-pack-watcher-env.bat' + ) - assert_file "$ESCONFIG/x-pack" d $user elasticsearch 750 - assert_file "$ESCONFIG/x-pack/users" f $user elasticsearch 660 - assert_file "$ESCONFIG/x-pack/users_roles" f $user elasticsearch 660 - assert_file "$ESCONFIG/x-pack/roles.yml" f $user elasticsearch 660 - assert_file "$ESCONFIG/x-pack/role_mapping.yml" f $user elasticsearch 660 - assert_file "$ESCONFIG/x-pack/log4j2.properties" f $user elasticsearch 660 - assert_number_of_files "$ESCONFIG/x-pack" 5 + local binaryFilesCount=0 + for binaryFile in ${binaryFiles[@]}; do + assert_file "$ESHOME/bin/$name/${binaryFile}" f $user $group 755 + binaryFilesCount=$(( binaryFilesCount + 1 )) + done + assert_number_of_files "$ESHOME/bin/$name/" $binaryFilesCount + # Verify config files + assert_file "$ESCONFIG/$name" d $user elasticsearch 750 + local configFiles=( + 'users' + 'users_roles' + 'roles.yml' + 'role_mapping.yml' + 'log4j2.properties' + ) + + local configFilesCount=0 + for configFile in ${configFiles[@]}; do + assert_file "$ESCONFIG/$name/${configFile}" f $user elasticsearch 660 + configFilesCount=$(( configFilesCount + 1 )) + done + assert_number_of_files "$ESCONFIG/$name/" $configFilesCount + + # Verify keystore creation assert_file "$ESCONFIG/elasticsearch.keystore" f $user elasticsearch 660 + + # Read the $name.expected file that contains all the expected + # plugins for the meta plugin + while read plugin; do + assert_module_or_plugin_directory "$ESPLUGINS/$name/$plugin" + assert_file_exist "$ESPLUGINS/$name/$plugin/$plugin"*".jar" + assert_file_exist "$ESPLUGINS/$name/$plugin/plugin-descriptor.properties" + assert_file_exist "$ESPLUGINS/$name/$plugin/plugin-security.policy" + done