Skip to content

Commit 381ed23

Browse files
authored
Re-enable plugin and upgrade bats tests (#51565) (#56999)
While the tests remained in place, the execution of these tests were lost when creating the DistroTestPlugin. This commit restores executing them.
1 parent 79224a9 commit 381ed23

File tree

8 files changed

+41
-34
lines changed

8 files changed

+41
-34
lines changed

Vagrantfile

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -495,22 +495,12 @@ JAVA
495495
rm -rf /tmp/bats
496496
}
497497
498-
cat \<\<VARS > /etc/profile.d/elasticsearch_vars.sh
499-
export ZIP=/elasticsearch/distribution/zip/build/distributions
500-
export TAR=/elasticsearch/distribution/tar/build/distributions
501-
export RPM=/elasticsearch/distribution/rpm/build/distributions
502-
export DEB=/elasticsearch/distribution/deb/build/distributions
503-
export PACKAGING_TESTS=/project/build/packaging/tests
504-
VARS
505498
cat \<\<SUDOERS_VARS > /etc/sudoers.d/elasticsearch_vars
506-
Defaults env_keep += "ZIP"
507-
Defaults env_keep += "TAR"
508-
Defaults env_keep += "RPM"
509-
Defaults env_keep += "DEB"
510-
Defaults env_keep += "PACKAGING_ARCHIVES"
511-
Defaults env_keep += "PACKAGING_TESTS"
512499
Defaults env_keep += "BATS_UTILS"
513500
Defaults env_keep += "BATS_TESTS"
501+
Defaults env_keep += "BATS_PLUGINS"
502+
Defaults env_keep += "BATS_UPGRADE"
503+
Defaults env_keep += "PACKAGE_NAME"
514504
Defaults env_keep += "JAVA_HOME"
515505
Defaults env_keep += "SYSTEM_JAVA_HOME"
516506
SUDOERS_VARS

buildSrc/src/main/java/org/elasticsearch/gradle/test/DistroTestPlugin.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,22 @@ public void apply(Project project) {
116116
lifecyleTasks.get(distribution.getType()).configure(t -> t.dependsOn(destructiveTask));
117117
}
118118

119-
Map<String, TaskProvider<?>> batsTests = new HashMap<>();
120-
configureBatsTest(project, "plugins", distributionsDir, copyDistributionsTask, copyPluginsTask).configure(
121-
t -> t.setPluginsDir(pluginsDir)
119+
TaskProvider<BatsTestTask> batsPluginsTest = configureBatsTest(
120+
project,
121+
"plugins",
122+
distributionsDir,
123+
copyDistributionsTask,
124+
copyPluginsTask
122125
);
123-
configureBatsTest(project, "upgrade", distributionsDir, copyDistributionsTask, copyUpgradeTask).configure(
124-
t -> t.setUpgradeDir(upgradeDir)
126+
batsPluginsTest.configure(t -> t.setPluginsDir(pluginsDir));
127+
TaskProvider<BatsTestTask> batsUpgradeTest = configureBatsTest(
128+
project,
129+
"upgrade",
130+
distributionsDir,
131+
copyDistributionsTask,
132+
copyUpgradeTask
125133
);
134+
batsUpgradeTest.configure(t -> t.setUpgradeDir(upgradeDir));
126135

127136
project.subprojects(vmProject -> {
128137
vmProject.getPluginManager().apply(VagrantBasePlugin.class);
@@ -166,12 +175,15 @@ public void apply(Project project) {
166175
}
167176
}
168177

169-
batsTests.forEach((desc, task) -> {
170-
configureVMWrapperTask(vmProject, desc, task.getName(), vmDependencies).configure(t -> {
171-
t.setProgressHandler(new BatsProgressLogger(project.getLogger()));
172-
t.onlyIf(spec -> isWindows(vmProject) == false); // bats doesn't run on windows
173-
t.dependsOn(copyDistributionsTask);
174-
});
178+
configureVMWrapperTask(vmProject, "bats plugins", batsPluginsTest.getName(), vmDependencies).configure(t -> {
179+
t.setProgressHandler(new BatsProgressLogger(project.getLogger()));
180+
t.onlyIf(spec -> isWindows(vmProject) == false); // bats doesn't run on windows
181+
t.dependsOn(copyDistributionsTask, copyPluginsTask);
182+
});
183+
configureVMWrapperTask(vmProject, "bats upgrade", batsUpgradeTest.getName(), vmDependencies).configure(t -> {
184+
t.setProgressHandler(new BatsProgressLogger(project.getLogger()));
185+
t.onlyIf(spec -> isWindows(vmProject) == false); // bats doesn't run on windows
186+
t.dependsOn(copyDistributionsTask, copyUpgradeTask);
175187
});
176188
});
177189
}

qa/os/bats/plugins/module_and_plugin_test_cases.bash

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ fi
210210
}
211211

212212
@test "[$GROUP] install ingest-attachment plugin" {
213-
# we specify the version on the poi-4.0.0.jar so that the test does
213+
# we specify the version on the poi-4.0.1.jar so that the test does
214214
# not spuriously pass if the jar is missing but the other poi jars
215215
# are present
216-
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
216+
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
217217
}
218218

219219
@test "[$GROUP] check ingest-common module" {
@@ -240,7 +240,7 @@ fi
240240
}
241241

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

246246
@test "[$GROUP] install murmur3 mapper plugin" {
@@ -408,8 +408,8 @@ fi
408408
sudo -E -u $ESPLUGIN_COMMAND_USER "$ESHOME/bin/elasticsearch-plugin" install --batch "file://$relativePath" > /tmp/plugin-cli-output
409409
# exclude progress line
410410
local loglines=$(cat /tmp/plugin-cli-output | grep -v "^[[:cntrl:]]" | wc -l)
411-
[ "$loglines" -eq "2" ] || {
412-
echo "Expected 2 lines excluding progress bar but the output had $loglines lines and was:"
411+
[ "$loglines" -eq "3" ] || {
412+
echo "Expected 3 lines excluding progress bar but the output had $loglines lines and was:"
413413
cat /tmp/plugin-cli-output
414414
false
415415
}

qa/os/bats/upgrade/80_upgrade.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ setup() {
4646
sameVersion="false"
4747
if [ "$(cat $BATS_UPGRADE/upgrade_from_version)" == "$(cat version)" ]; then
4848
sameVersion="true"
49+
else
50+
echo "BWC test version: $(cat $BATS_UPGRADE/upgrade_from_version)"
4951
fi
5052
# TODO: this needs to conditionally change based on version > 6.3.0
5153
if [ -f $BATS_UPGRADE/upgrade_is_oss ]; then

qa/os/bats/utils/packages.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ install_package() {
5959
local version=$(cat version)
6060
local rpmCommand='-i'
6161
local dir='./'
62-
while getopts ":fuv:" opt; do
62+
while getopts ":ufd:v:" opt; do
6363
case $opt in
6464
u)
6565
rpmCommand='-U'

qa/os/bats/utils/plugins.bash

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,7 @@ install_meta_plugin() {
185185
compare_plugins_list() {
186186
cat $1 | sort > /tmp/plugins
187187
echo "Checking plugins from $2 (<) against expected plugins (>):"
188-
diff -w /elasticsearch/qa/vagrant/build/plugins/expected /tmp/plugins
188+
# bats tests are run under build/packaging/distributions, and expected file is in build/plugins/expected
189+
# this can't be an absolute path since it differs whether running in vagrant or GCP
190+
diff -w ../../plugins/expected /tmp/plugins
189191
}

qa/os/bats/utils/utils.bash

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ describe_port() {
428428
}
429429

430430
debug_collect_logs() {
431-
local es_logfile="$ESLOG/elasticsearch_server.json"
431+
local es_logfile="/var/log/elasticsearch/elasticsearch.log"
432432
local system_logfile='/var/log/messages'
433433

434434
if [ -e "$es_logfile" ]; then
@@ -497,6 +497,7 @@ wait_for_elasticsearch_status() {
497497
fi
498498
echo $output | grep $desiredStatus || {
499499
echo "unexpected status: '$output' wanted '$desiredStatus'"
500+
debug_collect_logs
500501
false
501502
}
502503
}

qa/os/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ tasks.dependenciesInfo.enabled = false
5858
tasks.thirdPartyAudit.ignoreMissingClasses()
5959

6060
tasks.register('destructivePackagingTest') {
61-
dependsOn 'destructiveDistroTest'
61+
dependsOn 'destructiveDistroTest', 'destructiveBatsTest.plugins', 'destructiveBatsTest.upgrade'
6262
}
6363

6464
processTestResources {
@@ -67,7 +67,7 @@ processTestResources {
6767

6868
subprojects { Project platformProject ->
6969
tasks.register('packagingTest') {
70-
dependsOn 'distroTest'
70+
dependsOn 'distroTest', 'batsTest.plugins', 'batsTest.upgrade'
7171
}
7272

7373
vagrant {

0 commit comments

Comments
 (0)