Skip to content

Commit

Permalink
Re-enable plugin and upgrade bats tests (#51565) (#56999)
Browse files Browse the repository at this point in the history
While the tests remained in place, the execution of these tests were
lost when creating the DistroTestPlugin. This commit restores executing
them.
  • Loading branch information
rjernst authored May 20, 2020
1 parent 79224a9 commit 381ed23
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 34 deletions.
16 changes: 3 additions & 13 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -495,22 +495,12 @@ JAVA
rm -rf /tmp/bats
}
cat \<\<VARS > /etc/profile.d/elasticsearch_vars.sh
export ZIP=/elasticsearch/distribution/zip/build/distributions
export TAR=/elasticsearch/distribution/tar/build/distributions
export RPM=/elasticsearch/distribution/rpm/build/distributions
export DEB=/elasticsearch/distribution/deb/build/distributions
export PACKAGING_TESTS=/project/build/packaging/tests
VARS
cat \<\<SUDOERS_VARS > /etc/sudoers.d/elasticsearch_vars
Defaults env_keep += "ZIP"
Defaults env_keep += "TAR"
Defaults env_keep += "RPM"
Defaults env_keep += "DEB"
Defaults env_keep += "PACKAGING_ARCHIVES"
Defaults env_keep += "PACKAGING_TESTS"
Defaults env_keep += "BATS_UTILS"
Defaults env_keep += "BATS_TESTS"
Defaults env_keep += "BATS_PLUGINS"
Defaults env_keep += "BATS_UPGRADE"
Defaults env_keep += "PACKAGE_NAME"
Defaults env_keep += "JAVA_HOME"
Defaults env_keep += "SYSTEM_JAVA_HOME"
SUDOERS_VARS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,22 @@ public void apply(Project project) {
lifecyleTasks.get(distribution.getType()).configure(t -> t.dependsOn(destructiveTask));
}

Map<String, TaskProvider<?>> batsTests = new HashMap<>();
configureBatsTest(project, "plugins", distributionsDir, copyDistributionsTask, copyPluginsTask).configure(
t -> t.setPluginsDir(pluginsDir)
TaskProvider<BatsTestTask> batsPluginsTest = configureBatsTest(
project,
"plugins",
distributionsDir,
copyDistributionsTask,
copyPluginsTask
);
configureBatsTest(project, "upgrade", distributionsDir, copyDistributionsTask, copyUpgradeTask).configure(
t -> t.setUpgradeDir(upgradeDir)
batsPluginsTest.configure(t -> t.setPluginsDir(pluginsDir));
TaskProvider<BatsTestTask> batsUpgradeTest = configureBatsTest(
project,
"upgrade",
distributionsDir,
copyDistributionsTask,
copyUpgradeTask
);
batsUpgradeTest.configure(t -> t.setUpgradeDir(upgradeDir));

project.subprojects(vmProject -> {
vmProject.getPluginManager().apply(VagrantBasePlugin.class);
Expand Down Expand Up @@ -166,12 +175,15 @@ public void apply(Project project) {
}
}

batsTests.forEach((desc, task) -> {
configureVMWrapperTask(vmProject, desc, task.getName(), vmDependencies).configure(t -> {
t.setProgressHandler(new BatsProgressLogger(project.getLogger()));
t.onlyIf(spec -> isWindows(vmProject) == false); // bats doesn't run on windows
t.dependsOn(copyDistributionsTask);
});
configureVMWrapperTask(vmProject, "bats plugins", batsPluginsTest.getName(), vmDependencies).configure(t -> {
t.setProgressHandler(new BatsProgressLogger(project.getLogger()));
t.onlyIf(spec -> isWindows(vmProject) == false); // bats doesn't run on windows
t.dependsOn(copyDistributionsTask, copyPluginsTask);
});
configureVMWrapperTask(vmProject, "bats upgrade", batsUpgradeTest.getName(), vmDependencies).configure(t -> {
t.setProgressHandler(new BatsProgressLogger(project.getLogger()));
t.onlyIf(spec -> isWindows(vmProject) == false); // bats doesn't run on windows
t.dependsOn(copyDistributionsTask, copyUpgradeTask);
});
});
}
Expand Down
10 changes: 5 additions & 5 deletions qa/os/bats/plugins/module_and_plugin_test_cases.bash
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ fi
}

@test "[$GROUP] install ingest-attachment plugin" {
# we specify the version on the poi-4.0.0.jar so that the test does
# we specify the version on the poi-4.0.1.jar so that the test does
# not spuriously pass if the jar is missing but the other poi jars
# are present
install_and_check_plugin ingest attachment bcprov-jdk15on-*.jar tika-core-*.jar pdfbox-*.jar poi-4.0.0.jar poi-ooxml-4.0.0.jar poi-ooxml-schemas-*.jar poi-scratchpad-*.jar
install_and_check_plugin ingest attachment bcprov-jdk15on-*.jar tika-core-*.jar pdfbox-*.jar poi-4.0.1.jar poi-ooxml-4.0.1.jar poi-ooxml-schemas-*.jar poi-scratchpad-*.jar
}

@test "[$GROUP] check ingest-common module" {
Expand All @@ -240,7 +240,7 @@ fi
}

@test "[$GROUP] check lang-painless module" {
check_secure_module lang-painless antlr4-runtime-*.jar asm-debug-all-*.jar
check_secure_module lang-painless antlr4-runtime-*.jar asm-util-*.jar asm-tree-*.jar asm-commons-*.jar asm-analysis-*.jar
}

@test "[$GROUP] install murmur3 mapper plugin" {
Expand Down Expand Up @@ -408,8 +408,8 @@ fi
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/elasticsearch-plugin" install --batch "file://$relativePath" > /tmp/plugin-cli-output
# exclude progress line
local loglines=$(cat /tmp/plugin-cli-output | grep -v "^[[:cntrl:]]" | wc -l)
[ "$loglines" -eq "2" ] || {
echo "Expected 2 lines excluding progress bar but the output had $loglines lines and was:"
[ "$loglines" -eq "3" ] || {
echo "Expected 3 lines excluding progress bar but the output had $loglines lines and was:"
cat /tmp/plugin-cli-output
false
}
Expand Down
2 changes: 2 additions & 0 deletions qa/os/bats/upgrade/80_upgrade.bats
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ setup() {
sameVersion="false"
if [ "$(cat $BATS_UPGRADE/upgrade_from_version)" == "$(cat version)" ]; then
sameVersion="true"
else
echo "BWC test version: $(cat $BATS_UPGRADE/upgrade_from_version)"
fi
# TODO: this needs to conditionally change based on version > 6.3.0
if [ -f $BATS_UPGRADE/upgrade_is_oss ]; then
Expand Down
2 changes: 1 addition & 1 deletion qa/os/bats/utils/packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ install_package() {
local version=$(cat version)
local rpmCommand='-i'
local dir='./'
while getopts ":fuv:" opt; do
while getopts ":ufd:v:" opt; do
case $opt in
u)
rpmCommand='-U'
Expand Down
4 changes: 3 additions & 1 deletion qa/os/bats/utils/plugins.bash
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,7 @@ install_meta_plugin() {
compare_plugins_list() {
cat $1 | sort > /tmp/plugins
echo "Checking plugins from $2 (<) against expected plugins (>):"
diff -w /elasticsearch/qa/vagrant/build/plugins/expected /tmp/plugins
# bats tests are run under build/packaging/distributions, and expected file is in build/plugins/expected
# this can't be an absolute path since it differs whether running in vagrant or GCP
diff -w ../../plugins/expected /tmp/plugins
}
3 changes: 2 additions & 1 deletion qa/os/bats/utils/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ describe_port() {
}

debug_collect_logs() {
local es_logfile="$ESLOG/elasticsearch_server.json"
local es_logfile="/var/log/elasticsearch/elasticsearch.log"
local system_logfile='/var/log/messages'

if [ -e "$es_logfile" ]; then
Expand Down Expand Up @@ -497,6 +497,7 @@ wait_for_elasticsearch_status() {
fi
echo $output | grep $desiredStatus || {
echo "unexpected status: '$output' wanted '$desiredStatus'"
debug_collect_logs
false
}
}
Expand Down
4 changes: 2 additions & 2 deletions qa/os/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tasks.dependenciesInfo.enabled = false
tasks.thirdPartyAudit.ignoreMissingClasses()

tasks.register('destructivePackagingTest') {
dependsOn 'destructiveDistroTest'
dependsOn 'destructiveDistroTest', 'destructiveBatsTest.plugins', 'destructiveBatsTest.upgrade'
}

processTestResources {
Expand All @@ -67,7 +67,7 @@ processTestResources {

subprojects { Project platformProject ->
tasks.register('packagingTest') {
dependsOn 'distroTest'
dependsOn 'distroTest', 'batsTest.plugins', 'batsTest.upgrade'
}

vagrant {
Expand Down

0 comments on commit 381ed23

Please sign in to comment.