Merge pull request #12895 from nik9000/config_tests

Use jvm-example for testing bin/plugin
This commit is contained in:
Nik Everett 2015-08-17 11:13:02 -07:00
commit ded5d7456a
5 changed files with 197 additions and 267 deletions

2
Vagrantfile vendored
View File

@ -150,7 +150,7 @@ export TAR=/elasticsearch/distribution/tar/target/releases
export RPM=/elasticsearch/distribution/rpm/target/releases export RPM=/elasticsearch/distribution/rpm/target/releases
export DEB=/elasticsearch/distribution/deb/target/releases export DEB=/elasticsearch/distribution/deb/target/releases
export TESTROOT=/elasticsearch/qa/vagrant/target/testroot export TESTROOT=/elasticsearch/qa/vagrant/target/testroot
export BATS=/elasticsearch/qa/vagrant/src/test/resources/packaging/scripts/ export BATS=/elasticsearch/qa/vagrant/src/test/resources/packaging/scripts
VARS VARS
SHELL SHELL
end end

View File

@ -92,6 +92,12 @@
<version>${elasticsearch.version}</version> <version>${elasticsearch.version}</version>
<type>deb</type> <type>deb</type>
</artifactItem> </artifactItem>
<artifactItem>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>elasticsearch-jvm-example</artifactId>
<version>${elasticsearch.version}</version>
<type>zip</type>
</artifactItem>
</artifactItems> </artifactItems>
</configuration> </configuration>
</execution> </execution>

View File

@ -35,23 +35,12 @@ load packaging_test_utils
setup() { setup() {
# Cleans everything for every test execution # Cleans everything for every test execution
clean_before_test clean_before_test
# Download Shield
SHIELD_ZIP="$PWD/shield.zip"
if [ "$BATS_TEST_NUMBER" -eq 1 ]; then
if [ ! -e "$SHIELD_ZIP" ]; then
wget --quiet -O "$SHIELD_ZIP" "http://download.elasticsearch.org/elasticsearch/shield/shield-latest.zip"
fi
fi
} }
################################## ##################################
# Install plugins with a tar archive # Install plugins with a tar archive
################################## ##################################
@test "[TAR] install shield plugin" { @test "[TAR] install jvm-example plugin" {
skip "awaits public release of shield for 2.0"
# Install the archive # Install the archive
install_archive install_archive
@ -59,40 +48,35 @@ setup() {
verify_archive_installation verify_archive_installation
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield # Install jvm-example
run /tmp/elasticsearch/bin/plugin install elasticsearch/shield/latest -u "file://$SHIELD_ZIP" run /tmp/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that the plugin is correctly installed
assert_file_exist "/tmp/elasticsearch/bin/shield" assert_file_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "/tmp/elasticsearch/bin/shield/esusers" assert_file_exist "/tmp/elasticsearch/bin/jvm-example/test"
assert_file_exist "/tmp/elasticsearch/bin/shield/syskeygen" assert_file_exist "/tmp/elasticsearch/config/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield" assert_file_exist "/tmp/elasticsearch/config/jvm-example/example.yaml"
assert_file_exist "/tmp/elasticsearch/config/shield/role_mapping.yml" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/roles.yml" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example/plugin-descriptor.properties"
assert_file_exist "/tmp/elasticsearch/config/shield/users" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "/tmp/elasticsearch/config/shield/users_roles" echo "Running jvm-example's bin script...."
assert_file_exist "/tmp/elasticsearch/plugins/shield" /tmp/elasticsearch/bin/jvm-example/test | grep test
# Remove the plugin # Remove the plugin
run /tmp/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /tmp/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/tmp/elasticsearch/bin/shield" assert_file_not_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield" assert_file_exist "/tmp/elasticsearch/config/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/role_mapping.yml" assert_file_exist "/tmp/elasticsearch/config/jvm-example/example.yaml"
assert_file_exist "/tmp/elasticsearch/config/shield/roles.yml" assert_file_not_exist "/tmp/elasticsearch/plugins/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/users"
assert_file_exist "/tmp/elasticsearch/config/shield/users_roles"
assert_file_not_exist "/tmp/elasticsearch/plugins/shield"
} }
@test "[TAR] install shield plugin with a custom path.plugins" { @test "[TAR] install jvm-example plugin with a custom path.plugins" {
skip "awaits public release of shield for 2.0"
# Install the archive # Install the archive
install_archive install_archive
@ -109,44 +93,37 @@ setup() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield # Install jvm-example
run /tmp/elasticsearch/bin/plugin install elasticsearch/shield/latest -u "file://$SHIELD_ZIP" run /tmp/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that the plugin is correctly installed
assert_file_exist "/tmp/elasticsearch/bin/shield" assert_file_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "/tmp/elasticsearch/bin/shield/esusers" assert_file_exist "/tmp/elasticsearch/bin/jvm-example/test"
assert_file_exist "/tmp/elasticsearch/bin/shield/syskeygen" assert_file_exist "/tmp/elasticsearch/config/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield" assert_file_exist "/tmp/elasticsearch/config/jvm-example/example.yaml"
assert_file_exist "/tmp/elasticsearch/config/shield/role_mapping.yml" assert_file_exist "$TEMP_PLUGINS_DIR/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/roles.yml" assert_file_exist "$TEMP_PLUGINS_DIR/jvm-example/plugin-descriptor.properties"
assert_file_exist "/tmp/elasticsearch/config/shield/users" assert_file_exist "$TEMP_PLUGINS_DIR/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "/tmp/elasticsearch/config/shield/users_roles"
assert_file_exist "$TEMP_PLUGINS_DIR/shield"
# Remove the plugin # Remove the plugin
run /tmp/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /tmp/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/tmp/elasticsearch/bin/shield" assert_file_not_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield" assert_file_exist "/tmp/elasticsearch/config/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/role_mapping.yml" assert_file_exist "/tmp/elasticsearch/config/jvm-example/example.yaml"
assert_file_exist "/tmp/elasticsearch/config/shield/roles.yml" assert_file_not_exist "$TEMP_PLUGINS_DIR/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/users"
assert_file_exist "/tmp/elasticsearch/config/shield/users_roles"
assert_file_not_exist "$TEMP_PLUGINS_DIR/shield"
# Delete the custom plugins directory # Delete the custom plugins directory
run rm -rf "$TEMP_PLUGINS_DIR" run rm -rf "$TEMP_PLUGINS_DIR"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "[TAR] install shield plugin with a custom CONFIG_DIR" { @test "[TAR] install jvm-example plugin with a custom CONFIG_DIR" {
skip "awaits public release of shield for 2.0"
# Install the archive # Install the archive
install_archive install_archive
@ -166,44 +143,37 @@ setup() {
assert_file_exist "$TEMP_CONFIG_DIR/elasticsearch.yml" assert_file_exist "$TEMP_CONFIG_DIR/elasticsearch.yml"
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield with the CONF_DIR environment variable # Install jvm-example with the CONF_DIR environment variable
run env "CONF_DIR=$TEMP_CONFIG_DIR" /tmp/elasticsearch/bin/plugin install "elasticsearch/shield/latest" -u "file://$SHIELD_ZIP" run env "CONF_DIR=$TEMP_CONFIG_DIR" /tmp/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that jvm-example is correctly installed
assert_file_exist "/tmp/elasticsearch/bin/shield" assert_file_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "/tmp/elasticsearch/bin/shield/esusers" assert_file_exist "/tmp/elasticsearch/bin/jvm-example/test"
assert_file_exist "/tmp/elasticsearch/bin/shield/syskeygen" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example/example.yaml"
assert_file_exist "$TEMP_CONFIG_DIR/shield/role_mapping.yml" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/roles.yml" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example/plugin-descriptor.properties"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users_roles"
assert_file_exist "/tmp/elasticsearch/plugins/shield"
# Remove the plugin # Remove the plugin
run /tmp/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /tmp/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/tmp/elasticsearch/bin/shield" assert_file_not_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/role_mapping.yml" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example/example.yaml"
assert_file_exist "$TEMP_CONFIG_DIR/shield/roles.yml" assert_file_not_exist "/tmp/elasticsearch/plugins/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users_roles"
assert_file_not_exist "/tmp/elasticsearch/plugins/shield"
# Delete the custom plugins directory # Delete the custom plugins directory
run rm -rf "$TEMP_CONFIG_DIR" run rm -rf "$TEMP_CONFIG_DIR"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "[TAR] install shield plugin with a custom ES_JAVA_OPTS" { @test "[TAR] install jvm-example plugin with a custom ES_JAVA_OPTS" {
skip "awaits public release of shield for 2.0"
# Install the archive # Install the archive
install_archive install_archive
@ -227,44 +197,37 @@ setup() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield # Install jvm-example
run /tmp/elasticsearch/bin/plugin install elasticsearch/shield/latest -u "file://$SHIELD_ZIP" run /tmp/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that jvm-example is correctly installed
assert_file_exist "/tmp/elasticsearch/bin/shield" assert_file_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "/tmp/elasticsearch/bin/shield/esusers" assert_file_exist "/tmp/elasticsearch/bin/jvm-example/test"
assert_file_exist "/tmp/elasticsearch/bin/shield/syskeygen" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example/example.yaml"
assert_file_exist "$TEMP_CONFIG_DIR/shield/role_mapping.yml" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/roles.yml" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example/plugin-descriptor.properties"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users_roles"
assert_file_exist "/tmp/elasticsearch/plugins/shield"
# Remove the plugin # Remove the plugin
run /tmp/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /tmp/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/tmp/elasticsearch/bin/shield" assert_file_not_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/role_mapping.yml" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example/example.yaml"
assert_file_exist "$TEMP_CONFIG_DIR/shield/roles.yml" assert_file_not_exist "/tmp/elasticsearch/plugins/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users_roles"
assert_file_not_exist "/tmp/elasticsearch/plugins/shield"
# Delete the custom plugins directory # Delete the custom plugins directory
run rm -rf "$TEMP_CONFIG_DIR" run rm -rf "$TEMP_CONFIG_DIR"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "[TAR] install shield plugin to elasticsearch directory with a space" { @test "[TAR] install jvm-example plugin to elasticsearch directory with a space" {
skip "awaits public release of shield for 2.0"
export ES_DIR="/tmp/elastic search" export ES_DIR="/tmp/elastic search"
# Install the archive # Install the archive
@ -278,44 +241,37 @@ setup() {
mv /tmp/elasticsearch "$ES_DIR" mv /tmp/elasticsearch "$ES_DIR"
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield # Install jvm-example
run "$ES_DIR/bin/plugin" install elasticsearch/shield/latest -u "file://$SHIELD_ZIP" run "$ES_DIR/bin/plugin" install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that jvm-example is correctly installed
assert_file_exist "$ES_DIR/bin/shield" assert_file_exist "$ES_DIR/bin/jvm-example"
assert_file_exist "$ES_DIR/bin/shield/esusers" assert_file_exist "$ES_DIR/bin/jvm-example/test"
assert_file_exist "$ES_DIR/bin/shield/syskeygen" assert_file_exist "$ES_DIR/config/jvm-example"
assert_file_exist "$ES_DIR/config/shield" assert_file_exist "$ES_DIR/config/jvm-example/example.yaml"
assert_file_exist "$ES_DIR/config/shield/role_mapping.yml" assert_file_exist "$ES_DIR/plugins/jvm-example"
assert_file_exist "$ES_DIR/config/shield/roles.yml" assert_file_exist "$ES_DIR/plugins/jvm-example/plugin-descriptor.properties"
assert_file_exist "$ES_DIR/config/shield/users" assert_file_exist "$ES_DIR/plugins/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "$ES_DIR/config/shield/users_roles"
assert_file_exist "$ES_DIR/plugins/shield"
# Remove the plugin # Remove the plugin
run "$ES_DIR/bin/plugin" remove elasticsearch/shield/latest run "$ES_DIR/bin/plugin" remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "$ES_DIR/bin/shield" assert_file_not_exist "$ES_DIR/bin/jvm-example"
assert_file_exist "$ES_DIR/config/shield" assert_file_exist "$ES_DIR/config/jvm-example"
assert_file_exist "$ES_DIR/config/shield/role_mapping.yml" assert_file_exist "$ES_DIR/config/jvm-example/example.yaml"
assert_file_exist "$ES_DIR/config/shield/roles.yml" assert_file_not_exist "$ES_DIR/plugins/jvm-example"
assert_file_exist "$ES_DIR/config/shield/users"
assert_file_exist "$ES_DIR/config/shield/users_roles"
assert_file_not_exist "$ES_DIR/plugins/shield"
#Cleanup our temporary Elasticsearch installation #Cleanup our temporary Elasticsearch installation
rm -rf "$ES_DIR" rm -rf "$ES_DIR"
} }
@test "[TAR] install shield plugin from a directory with a space" { @test "[TAR] install jvm-example plugin from a directory with a space" {
skip "awaits public release of shield for 2.0" export EXAMPLE_PLUGIN_ZIP_WITH_SPACE="/tmp/plugins with space/jvm-example.zip"
export SHIELD_ZIP_WITH_SPACE="/tmp/plugins with space/shield.zip"
# Install the archive # Install the archive
install_archive install_archive
@ -324,41 +280,36 @@ setup() {
verify_archive_installation verify_archive_installation
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Copy the shield plugin to a directory with a space in it # Copy the jvm-example plugin to a directory with a space in it
rm -f "$SHIELD_ZIP_WITH_SPACE" rm -f "$EXAMPLE_PLUGIN_ZIP_WITH_SPACE"
mkdir -p "$(dirname "$SHIELD_ZIP_WITH_SPACE")" mkdir -p "$(dirname "$EXAMPLE_PLUGIN_ZIP_WITH_SPACE")"
cp $SHIELD_ZIP "$SHIELD_ZIP_WITH_SPACE" cp $EXAMPLE_PLUGIN_ZIP "$EXAMPLE_PLUGIN_ZIP_WITH_SPACE"
# Install Shield # Install jvm-example
run /tmp/elasticsearch/bin/plugin install elasticsearch/shield/latest -u "file://$SHIELD_ZIP_WITH_SPACE" run /tmp/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP_WITH_SPACE"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that the plugin is correctly installed
assert_file_exist "/tmp/elasticsearch/bin/shield" assert_file_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "/tmp/elasticsearch/bin/shield/esusers" assert_file_exist "/tmp/elasticsearch/bin/jvm-example/test"
assert_file_exist "/tmp/elasticsearch/bin/shield/syskeygen" assert_file_exist "/tmp/elasticsearch/config/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield" assert_file_exist "/tmp/elasticsearch/config/jvm-example/example.yaml"
assert_file_exist "/tmp/elasticsearch/config/shield/role_mapping.yml" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/roles.yml" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example/plugin-descriptor.properties"
assert_file_exist "/tmp/elasticsearch/config/shield/users" assert_file_exist "/tmp/elasticsearch/plugins/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "/tmp/elasticsearch/config/shield/users_roles"
assert_file_exist "/tmp/elasticsearch/plugins/shield"
# Remove the plugin # Remove the plugin
run /tmp/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /tmp/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/tmp/elasticsearch/bin/shield" assert_file_not_exist "/tmp/elasticsearch/bin/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield" assert_file_exist "/tmp/elasticsearch/config/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/role_mapping.yml" assert_file_exist "/tmp/elasticsearch/config/jvm-example/example.yaml"
assert_file_exist "/tmp/elasticsearch/config/shield/roles.yml" assert_file_not_exist "/tmp/elasticsearch/plugins/jvm-example"
assert_file_exist "/tmp/elasticsearch/config/shield/users"
assert_file_exist "/tmp/elasticsearch/config/shield/users_roles"
assert_file_not_exist "/tmp/elasticsearch/plugins/shield"
#Cleanup our plugin directory with a space #Cleanup our plugin directory with a space
rm -rf "$SHIELD_ZIP_WITH_SPACE" rm -rf "$EXAMPLE_PLUGIN_ZIP_WITH_SPACE"
} }

View File

@ -36,15 +36,6 @@ load packaging_test_utils
setup() { setup() {
# Cleans everything for every test execution # Cleans everything for every test execution
clean_before_test clean_before_test
# Download Shield
SHIELD_ZIP="$PWD/shield.zip"
if [ "$BATS_TEST_NUMBER" -eq 1 ]; then
if [ ! -e "$SHIELD_ZIP" ]; then
wget --quiet -O "$SHIELD_ZIP" "http://download.elasticsearch.org/elasticsearch/shield/shield-latest.zip"
fi
fi
} }
# Install a deb or rpm package # Install a deb or rpm package
@ -62,9 +53,7 @@ install_package() {
################################## ##################################
# Install plugins with DEB/RPM package # Install plugins with DEB/RPM package
################################## ##################################
@test "[PLUGINS] install shield plugin" { @test "[PLUGINS] install jvm-example plugin" {
skip "awaits public release of shield for 2.0"
# Install the package # Install the package
install_package install_package
@ -72,40 +61,33 @@ install_package() {
verify_package_installation verify_package_installation
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield # Install jvm-example
run /usr/share/elasticsearch/bin/plugin install elasticsearch/shield/latest -u "file://$SHIELD_ZIP" run /usr/share/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that jvm-example is correctly installed
assert_file_exist "/usr/share/elasticsearch/bin/shield" assert_file_exist "/usr/share/elasticsearch/bin/jvm-example"
assert_file_exist "/usr/share/elasticsearch/bin/shield/esusers" assert_file_exist "/usr/share/elasticsearch/bin/jvm-example/test"
assert_file_exist "/usr/share/elasticsearch/bin/shield/syskeygen" assert_file_exist "/etc/elasticsearch/jvm-example"
assert_file_exist "/etc/elasticsearch/shield" assert_file_exist "/etc/elasticsearch/jvm-example/example.yaml"
assert_file_exist "/etc/elasticsearch/shield/role_mapping.yml" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example"
assert_file_exist "/etc/elasticsearch/shield/roles.yml" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example/plugin-descriptor.properties"
assert_file_exist "/etc/elasticsearch/shield/users" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "/etc/elasticsearch/shield/users_roles"
assert_file_exist "/usr/share/elasticsearch/plugins/shield"
# Remove the plugin # Remove the plugin
run /usr/share/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /usr/share/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/usr/share/elasticsearch/bin/shield" assert_file_not_exist "/usr/share/elasticsearch/bin/jvm-example"
assert_file_exist "/etc/elasticsearch/shield" assert_file_exist "/etc/elasticsearch/jvm-example"
assert_file_exist "/etc/elasticsearch/shield/role_mapping.yml" assert_file_exist "/etc/elasticsearch/jvm-example/example.yaml"
assert_file_exist "/etc/elasticsearch/shield/roles.yml" assert_file_not_exist "/usr/share/elasticsearch/plugins/jvm-example"
assert_file_exist "/etc/elasticsearch/shield/users"
assert_file_exist "/etc/elasticsearch/shield/users_roles"
assert_file_not_exist "/usr/share/elasticsearch/plugins/shield"
} }
@test "[PLUGINS] install shield plugin with a custom path.plugins" { @test "[PLUGINS] install jvm-example plugin with a custom path.plugins" {
skip "awaits public release of shield for 2.0"
# Install the package # Install the package
install_package install_package
@ -126,44 +108,38 @@ install_package() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield # Install jvm-example
run /usr/share/elasticsearch/bin/plugin install elasticsearch/shield/latest -u "file://$SHIELD_ZIP" run /usr/share/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that jvm-example is correctly installed
assert_file_exist "/usr/share/elasticsearch/bin/shield" assert_file_exist "/usr/share/elasticsearch/bin/jvm-example"
assert_file_exist "/usr/share/elasticsearch/bin/shield/esusers" assert_file_exist "/usr/share/elasticsearch/bin/jvm-example/test"
assert_file_exist "/usr/share/elasticsearch/bin/shield/syskeygen" assert_file_exist "/etc/elasticsearch/jvm-example"
assert_file_exist "/etc/elasticsearch/shield" assert_file_exist "/etc/elasticsearch/jvm-example/example.yaml"
assert_file_exist "/etc/elasticsearch/shield/role_mapping.yml" assert_file_exist "$TEMP_PLUGINS_DIR/jvm-example"
assert_file_exist "/etc/elasticsearch/shield/roles.yml" assert_file_exist "$TEMP_PLUGINS_DIR/jvm-example/plugin-descriptor.properties"
assert_file_exist "/etc/elasticsearch/shield/users" assert_file_exist "$TEMP_PLUGINS_DIR/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "/etc/elasticsearch/shield/users_roles"
assert_file_exist "$TEMP_PLUGINS_DIR/shield"
# Remove the plugin # Remove the plugin
run /usr/share/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /usr/share/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/usr/share/elasticsearch/bin/shield" assert_file_not_exist "/usr/share/elasticsearch/bin/jvm-example"
assert_file_exist "/etc/elasticsearch/shield" assert_file_exist "/etc/elasticsearch/jvm-example"
assert_file_exist "/etc/elasticsearch/shield/role_mapping.yml" assert_file_exist "/etc/elasticsearch/jvm-example/example.yaml"
assert_file_exist "/etc/elasticsearch/shield/roles.yml" assert_file_not_exist "$TEMP_PLUGINS_DIR/jvm-example"
assert_file_exist "/etc/elasticsearch/shield/users"
assert_file_exist "/etc/elasticsearch/shield/users_roles"
assert_file_not_exist "$TEMP_PLUGINS_DIR/shield"
# Delete the custom plugins directory # Delete the custom plugins directory
run rm -rf "$TEMP_PLUGINS_DIR" run rm -rf "$TEMP_PLUGINS_DIR"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "[PLUGINS] install shield plugin with a custom CONFIG_DIR" { @test "[PLUGINS] install jvm-example plugin with a custom CONFIG_DIR" {
skip "awaits public release of shield for 2.0"
# Install the package # Install the package
install_package install_package
@ -194,44 +170,37 @@ install_package() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield # Install jvm-exampel
run /usr/share/elasticsearch/bin/plugin install elasticsearch/shield/latest -u "file://$SHIELD_ZIP" run /usr/share/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that jvm-example is correctly installed
assert_file_exist "/usr/share/elasticsearch/bin/shield" assert_file_exist "/usr/share/elasticsearch/bin/jvm-example"
assert_file_exist "/usr/share/elasticsearch/bin/shield/esusers" assert_file_exist "/usr/share/elasticsearch/bin/jvm-example/test"
assert_file_exist "/usr/share/elasticsearch/bin/shield/syskeygen" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example/example.yaml"
assert_file_exist "$TEMP_CONFIG_DIR/shield/role_mapping.yml" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/roles.yml" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example/plugin-descriptor.properties"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "/$TEMP_CONFIG_DIR/shield/users_roles"
assert_file_exist "/usr/share/elasticsearch/plugins/shield"
# Remove the plugin # Remove the plugin
run /usr/share/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /usr/share/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/usr/share/elasticsearch/bin/shield" assert_file_not_exist "/usr/share/elasticsearch/bin/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/role_mapping.yml" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example/example.yaml"
assert_file_exist "$TEMP_CONFIG_DIR/shield/roles.yml" assert_file_not_exist "/usr/share/elasticsearch/plugins/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users_roles"
assert_file_not_exist "/tmp/elasticsearch/plugins/shield"
# Delete the custom plugins directory # Delete the custom plugins directory
run rm -rf "$TEMP_CONFIG_DIR" run rm -rf "$TEMP_CONFIG_DIR"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "[PLUGINS] install shield plugin with a custom ES_JAVA_OPTS" { @test "[PLUGINS] install jvm-example plugin with a custom ES_JAVA_OPTS" {
skip "awaits public release of shield for 2.0"
# Install the package # Install the package
install_package install_package
@ -259,35 +228,30 @@ install_package() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that plugin archive is available # Checks that plugin archive is available
[ -e "$SHIELD_ZIP" ] [ -e "$EXAMPLE_PLUGIN_ZIP" ]
# Install Shield # Install jvm-example
run /usr/share/elasticsearch/bin/plugin install elasticsearch/shield/latest -u "file://$SHIELD_ZIP" run /usr/share/elasticsearch/bin/plugin install jvm-example -u "file://$EXAMPLE_PLUGIN_ZIP"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that Shield is correctly installed # Checks that jvm-example is correctly installed
assert_file_exist "/usr/share/elasticsearch/bin/shield" assert_file_exist "/usr/share/elasticsearch/bin/jvm-example"
assert_file_exist "/usr/share/elasticsearch/bin/shield/esusers" assert_file_exist "/usr/share/elasticsearch/bin/jvm-example/test"
assert_file_exist "/usr/share/elasticsearch/bin/shield/syskeygen" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example/example.yaml"
assert_file_exist "$TEMP_CONFIG_DIR/shield/role_mapping.yml" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/roles.yml" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example/plugin-descriptor.properties"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users" assert_file_exist "/usr/share/elasticsearch/plugins/jvm-example/elasticsearch-jvm-example-"*".jar"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users_roles"
assert_file_exist "/usr/share/elasticsearch/plugins/shield"
# Remove the plugin # Remove the plugin
run /usr/share/elasticsearch/bin/plugin remove elasticsearch/shield/latest run /usr/share/elasticsearch/bin/plugin remove jvm-example
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# Checks that the plugin is correctly removed # Checks that the plugin is correctly removed
assert_file_not_exist "/usr/share/elasticsearch/bin/shield" assert_file_not_exist "/usr/share/elasticsearch/bin/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/role_mapping.yml" assert_file_exist "$TEMP_CONFIG_DIR/jvm-example/example.yaml"
assert_file_exist "$TEMP_CONFIG_DIR/shield/roles.yml" assert_file_not_exist "/usr/share/elasticsearch/plugins/jvm-example"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users"
assert_file_exist "$TEMP_CONFIG_DIR/shield/users_roles"
assert_file_not_exist "/usr/share/elasticsearch/plugins/shield"
# Delete the custom plugins directory # Delete the custom plugins directory
run rm -rf "$TEMP_CONFIG_DIR" run rm -rf "$TEMP_CONFIG_DIR"

View File

@ -26,6 +26,9 @@
# under the License. # under the License.
# Variables used by tests
EXAMPLE_PLUGIN_ZIP=$(readlink -m elasticsearch-jvm-example-*.zip)
# Checks if necessary commands are available to run the tests # Checks if necessary commands are available to run the tests
if [ ! -x /usr/bin/which ]; then if [ ! -x /usr/bin/which ]; then
@ -134,11 +137,17 @@ skip_not_zip() {
} }
assert_file_exist() { assert_file_exist() {
[ -e "$1" ] local file="$1"
echo "Should exist: ${file}"
local file=$(readlink -m "${file}")
[ -e "$file" ]
} }
assert_file_not_exist() { assert_file_not_exist() {
[ ! -e "$1" ] local file="$1"
echo "Should not exist: ${file}"
local file=$(readlink -m "${file}")
[ ! -e "$file" ]
} }
assert_file() { assert_file() {