[Packaging] Run BATS upgrade tests against the current version (#20453)

BATS upgrade tests fails on master branch because it tries to install 2.x versions to upgrade from instead of 5.x versions. And since #18554 we should only test upgrades from 5.0.0-alpha4 versions.

This commit changes the vagrant tests so that it tries to list all the previous releases from version N-1. If nothing is found, it will fetch the current version and will run the upgrade tests with it. It works nicely with the current master 6.0.0-alpha1-SNAPSHOT. Once 5.0.0 is released it should run the test with it.
This commit is contained in:
Tanguy Leroux 2016-09-13 17:52:06 +02:00
parent 3caaafa4bd
commit f3f9b499ad
5 changed files with 44 additions and 30 deletions

View File

@ -126,7 +126,16 @@ Set<String> getVersions() {
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s -> new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
xml = new XmlParser().parse(s) xml = new XmlParser().parse(s)
} }
return new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /2\.\d\.\d/ })
// List all N-1 releases from maven central
int major = Integer.parseInt(project.version.substring(0, project.version.indexOf('.'))) - 1
Set<String> versions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /$major\.\d\.\d/ })
if (versions.isEmpty() == false) {
return versions;
}
// If no version is found, we run the tests with the current version
return Collections.singleton(project.version);
} }
task updatePackagingTestUpgradeFromVersions { task updatePackagingTestUpgradeFromVersions {

View File

@ -37,6 +37,11 @@ load os_package
# Cleans everything for the 1st execution # Cleans everything for the 1st execution
setup() { setup() {
skip_not_dpkg_or_rpm skip_not_dpkg_or_rpm
sameVersion="false"
if [ "$(cat upgrade_from_version)" == "$(cat version)" ]; then
sameVersion="true"
fi
} }
@test "[UPGRADE] install old version" { @test "[UPGRADE] install old version" {
@ -49,11 +54,7 @@ setup() {
} }
@test "[UPGRADE] check elasticsearch version is old version" { @test "[UPGRADE] check elasticsearch version is old version" {
curl -s localhost:9200 | grep \"number\"\ :\ \"$(cat upgrade_from_version)\" || { check_elasticsearch_version "$(cat upgrade_from_version)"
echo "Installed an unexpected version:"
curl -s localhost:9200
false
}
} }
@test "[UPGRADE] index some documents into a few indexes" { @test "[UPGRADE] index some documents into a few indexes" {
@ -79,7 +80,11 @@ setup() {
} }
@test "[UPGRADE] install version under test" { @test "[UPGRADE] install version under test" {
install_package -u if [ "$sameVersion" == "true" ]; then
install_package -f
else
install_package -u
fi
} }
@test "[UPGRADE] start version under test" { @test "[UPGRADE] start version under test" {
@ -88,12 +93,7 @@ setup() {
} }
@test "[UPGRADE] check elasticsearch version is version under test" { @test "[UPGRADE] check elasticsearch version is version under test" {
local versionToCheck=$(cat version | sed -e 's/-SNAPSHOT//') check_elasticsearch_version "$(cat version)"
curl -s localhost:9200 | grep \"number\"\ :\ \"$versionToCheck\" || {
echo "Installed an unexpected version:"
curl -s localhost:9200
false
}
} }
@test "[UPGRADE] verify that the documents are there after restart" { @test "[UPGRADE] verify that the documents are there after restart" {

View File

@ -44,12 +44,16 @@ export_elasticsearch_paths() {
install_package() { install_package() {
local version=$(cat version) local version=$(cat version)
local rpmCommand='-i' local rpmCommand='-i'
while getopts ":uv:" opt; do while getopts ":fuv:" opt; do
case $opt in case $opt in
u) u)
rpmCommand='-U' rpmCommand='-U'
dpkgCommand='--force-confnew' dpkgCommand='--force-confnew'
;; ;;
f)
rpmCommand='-U --force'
dpkgCommand='--force-conflicts'
;;
v) v)
version=$OPTARG version=$OPTARG
;; ;;

View File

@ -452,6 +452,22 @@ wait_for_elasticsearch_status() {
} }
} }
# Checks the current elasticsearch version using the Info REST endpoint
# $1 - expected version
check_elasticsearch_version() {
local version=$1
local versionToCheck=$(echo $version | sed -e 's/-SNAPSHOT//')
run curl -s localhost:9200
[ "$status" -eq 0 ]
echo $output | grep \"number\"\ :\ \"$versionToCheck\" || {
echo "Installed an unexpected version:"
curl -s localhost:9200
false
}
}
install_elasticsearch_test_scripts() { install_elasticsearch_test_scripts() {
install_script is_guide.groovy install_script is_guide.groovy
install_script is_guide.mustache install_script is_guide.mustache

View File

@ -1,16 +1 @@
2.0.0 6.0.0-alpha1-SNAPSHOT
2.0.1
2.0.2
2.1.0
2.1.1
2.1.2
2.2.0
2.2.1
2.2.2
2.3.0
2.3.1
2.3.2
2.3.3
2.3.4
2.3.5
2.4.0