Add module tests

This commit is contained in:
Jason Tedor 2016-03-16 19:29:16 -04:00
parent b46dd3f01c
commit ace45e8bda
7 changed files with 73 additions and 21 deletions

View File

@ -1 +1 @@
plugin_test_cases.bash
module_and_plugin_test_cases.bash

View File

@ -0,0 +1 @@
module_and_plugin_test_cases.bash

View File

@ -1 +0,0 @@
plugin_test_cases.bash

View File

@ -33,13 +33,14 @@
##################################
# Common test cases for both tar and rpm/deb based plugin tests
##################################
# This file is symlinked to both 25_tar_plugins.bats and 50_plugins.bats so its
# This file is symlinked to both 25_tar_plugins.bats and 50_modules_and_plugins.bats so its
# executed twice - once to test plugins using the tar distribution and once to
# test files using the rpm distribution or the deb distribution, whichever the
# system uses.
# Load test utilities
load packaging_test_utils
load modules
load plugins
setup() {
@ -219,16 +220,30 @@ fi
install_and_check_plugin discovery ec2 aws-java-sdk-core-*.jar
}
@test "[$GROUP] install lang-expression plugin" {
install_and_check_plugin lang expression
@test "[$GROUP] check ingest-grok module" {
check_module ingest-grok jcodings-*.jar joni-*.jar
}
@test "[$GROUP] install lang-groovy plugin" {
install_and_check_plugin lang groovy
@test "[$GROUP] check lang-expression module" {
# we specify the version on the asm-5.0.4.jar so that the test does
# not spuriously pass if the jar is missing but the other asm jars
# are present
check_secure_module lang-expression antlr4-runtime-*.jar asm-5.0.4.jar asm-commons-*.jar asm-tree-*.jar lucene-expressions-*.jar
}
@test "[$GROUP] install lang-painless plugin" {
install_and_check_plugin lang painless
@test "[$GROUP] check lang-groovy module" {
check_secure_module lang-groovy groovy-*-indy.jar
}
@test "[$GROUP] check lang-mustache module" {
check_secure_module lang-mustache compiler-*.jar
}
@test "[$GROUP] check lang-painless module" {
# we specify the version on the asm-5.0.4.jar so that the test does
# not spuriously pass if the jar is missing but the other asm jars
# are present
check_secure_module lang-painless antlr4-runtime-*.jar asm-5.0.4.jar asm-commons-*.jar asm-tree-*.jar
}
@test "[$GROUP] install javascript plugin" {
@ -247,6 +262,10 @@ fi
install_and_check_plugin mapper murmur3
}
@test "[$GROUP] check reindex module" {
check_module reindex
}
@test "[$GROUP] install size mapper plugin" {
install_and_check_plugin mapper size
}
@ -321,18 +340,6 @@ fi
remove_plugin discovery-ec2
}
@test "[$GROUP] remove lang-expression plugin" {
remove_plugin lang-expression
}
@test "[$GROUP] remove lang-groovy plugin" {
remove_plugin lang-groovy
}
@test "[$GROUP] remove lang-painless plugin" {
remove_plugin lang-painless
}
@test "[$GROUP] remove javascript plugin" {
remove_plugin lang-javascript
}

View File

@ -0,0 +1,42 @@
#!/bin/sh
# This file contains some utilities to test the elasticsearch scripts,
# the .deb/.rpm packages and the SysV/Systemd scripts.
# WARNING: This testing file must be executed as root and can
# dramatically change your system. It removes the 'elasticsearch'
# user/group and also many directories. Do not execute this file
# unless you know exactly what you are doing.
# Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
check_module() {
local name=$1
shift
for file in "$@"; do
assert_file_exist "$(readlink -m $ESMODULES/$name/$file)"
done
assert_file_exist "$(readlink -m $ESMODULES/$name/$name-*.jar)"
assert_file_exist "$(readlink -m $ESMODULES/$name/plugin-descriptor.properties)"
}
check_secure_module() {
check_module "$@" plugin-security.policy
}

View File

@ -30,6 +30,7 @@
export_elasticsearch_paths() {
export ESHOME="/usr/share/elasticsearch"
export ESPLUGINS="$ESHOME/plugins"
export ESMODULES="$ESHOME/modules"
export ESCONFIG="/etc/elasticsearch"
export ESSCRIPTS="$ESCONFIG/scripts"
export ESDATA="/var/lib/elasticsearch"
@ -82,6 +83,7 @@ verify_package_installation() {
assert_file "$ESDATA" d elasticsearch elasticsearch 755
assert_file "$ESLOG" d elasticsearch elasticsearch 755
assert_file "$ESPLUGINS" d elasticsearch elasticsearch 755
assert_file "$ESMODULES" d root root 755
assert_file "$ESPIDDIR" d elasticsearch elasticsearch 755
assert_file "$ESHOME/NOTICE.txt" f root root 644
assert_file "$ESHOME/README.textile" f root root 644

View File

@ -68,6 +68,7 @@ move_elasticsearch() {
# Export some useful paths.
export_elasticsearch_paths() {
export ESMODULES="$ESHOME/modules"
export ESPLUGINS="$ESHOME/plugins"
export ESCONFIG="$ESHOME/config"
export ESSCRIPTS="$ESCONFIG/scripts"