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@e177b742f9
This commit is contained in:
parent
b456885b39
commit
7c90f874d7
|
@ -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.vagrantsupport'
|
||||||
apply plugin: 'elasticsearch.vagrant'
|
apply plugin: 'elasticsearch.vagrant'
|
||||||
|
|
||||||
|
@ -6,8 +11,41 @@ esvagrant {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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
|
// Inherit Bats test utils from :qa:vagrant project
|
||||||
bats project(path: ':qa:vagrant', configuration: 'bats')
|
bats project(path: ':qa:vagrant', configuration: 'bats')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, List<String>> metaPlugins = [:]
|
||||||
|
for (Project metaPlugin : project.rootProject.subprojects) {
|
||||||
|
if (metaPlugin.plugins.hasPlugin(MetaPluginBuildPlugin)) {
|
||||||
|
MetaPluginPropertiesExtension extension = metaPlugin.extensions.findByName('es_meta_plugin')
|
||||||
|
if (extension != null) {
|
||||||
|
List<String> 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')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,36 +5,79 @@
|
||||||
# you may not use this file except in compliance with the Elastic License.
|
# you may not use this file except in compliance with the Elastic License.
|
||||||
|
|
||||||
install_xpack() {
|
install_xpack() {
|
||||||
install_and_check_plugin x pack x-pack-core-*.jar x-pack-graph-*.jar x-pack-ml-*.jar \
|
install_meta_plugin x-pack
|
||||||
x-pack-monitoring-*.jar x-pack-security-*.jar x-pack-watcher-*.jar
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checks that X-Pack files are correctly installed
|
# Checks that X-Pack files are correctly installed
|
||||||
verify_xpack_installation() {
|
verify_xpack_installation() {
|
||||||
|
local name="x-pack"
|
||||||
local user="$ESPLUGIN_COMMAND_USER"
|
local user="$ESPLUGIN_COMMAND_USER"
|
||||||
local group="$ESPLUGIN_COMMAND_USER"
|
local group="$ESPLUGIN_COMMAND_USER"
|
||||||
|
|
||||||
assert_file "$ESHOME/bin/x-pack" d $user $group 755
|
# Verify binary files
|
||||||
assert_file "$ESHOME/bin/x-pack/certgen" f $user $group 755
|
assert_file "$ESHOME/bin/$name" d $user $group 755
|
||||||
assert_file "$ESHOME/bin/x-pack/croneval" f $user $group 755
|
local binaryFiles=(
|
||||||
assert_file "$ESHOME/bin/x-pack/extension" f $user $group 755
|
'certgen'
|
||||||
assert_file "$ESHOME/bin/x-pack/migrate" f $user $group 755
|
'certgen.bat'
|
||||||
assert_file "$ESHOME/bin/x-pack/saml-metadata" f $user $group 755
|
'certutil'
|
||||||
assert_file "$ESHOME/bin/x-pack/setup-passwords" f $user $group 755
|
'certutil.bat'
|
||||||
assert_file "$ESHOME/bin/x-pack/syskeygen" f $user $group 755
|
'croneval'
|
||||||
assert_file "$ESHOME/bin/x-pack/users" f $user $group 755
|
'croneval.bat'
|
||||||
assert_file "$ESHOME/bin/x-pack/x-pack-env" f $user $group 755
|
'extension'
|
||||||
assert_number_of_files "$ESHOME/bin/x-pack/" 20
|
'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
|
local binaryFilesCount=0
|
||||||
assert_file "$ESCONFIG/x-pack/users" f $user elasticsearch 660
|
for binaryFile in ${binaryFiles[@]}; do
|
||||||
assert_file "$ESCONFIG/x-pack/users_roles" f $user elasticsearch 660
|
assert_file "$ESHOME/bin/$name/${binaryFile}" f $user $group 755
|
||||||
assert_file "$ESCONFIG/x-pack/roles.yml" f $user elasticsearch 660
|
binaryFilesCount=$(( binaryFilesCount + 1 ))
|
||||||
assert_file "$ESCONFIG/x-pack/role_mapping.yml" f $user elasticsearch 660
|
done
|
||||||
assert_file "$ESCONFIG/x-pack/log4j2.properties" f $user elasticsearch 660
|
assert_number_of_files "$ESHOME/bin/$name/" $binaryFilesCount
|
||||||
assert_number_of_files "$ESCONFIG/x-pack" 5
|
|
||||||
|
|
||||||
|
# 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
|
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 </project/build/plugins/$name.expected
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_number_of_files() {
|
assert_number_of_files() {
|
||||||
|
|
Loading…
Reference in New Issue