[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:
parent
3caaafa4bd
commit
f3f9b499ad
|
@ -126,7 +126,16 @@ Set<String> getVersions() {
|
|||
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { 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 {
|
||||
|
|
|
@ -37,6 +37,11 @@ load os_package
|
|||
# Cleans everything for the 1st execution
|
||||
setup() {
|
||||
skip_not_dpkg_or_rpm
|
||||
|
||||
sameVersion="false"
|
||||
if [ "$(cat upgrade_from_version)" == "$(cat version)" ]; then
|
||||
sameVersion="true"
|
||||
fi
|
||||
}
|
||||
|
||||
@test "[UPGRADE] install old version" {
|
||||
|
@ -49,11 +54,7 @@ setup() {
|
|||
}
|
||||
|
||||
@test "[UPGRADE] check elasticsearch version is old version" {
|
||||
curl -s localhost:9200 | grep \"number\"\ :\ \"$(cat upgrade_from_version)\" || {
|
||||
echo "Installed an unexpected version:"
|
||||
curl -s localhost:9200
|
||||
false
|
||||
}
|
||||
check_elasticsearch_version "$(cat upgrade_from_version)"
|
||||
}
|
||||
|
||||
@test "[UPGRADE] index some documents into a few indexes" {
|
||||
|
@ -79,7 +80,11 @@ setup() {
|
|||
}
|
||||
|
||||
@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" {
|
||||
|
@ -88,12 +93,7 @@ setup() {
|
|||
}
|
||||
|
||||
@test "[UPGRADE] check elasticsearch version is version under test" {
|
||||
local versionToCheck=$(cat version | sed -e 's/-SNAPSHOT//')
|
||||
curl -s localhost:9200 | grep \"number\"\ :\ \"$versionToCheck\" || {
|
||||
echo "Installed an unexpected version:"
|
||||
curl -s localhost:9200
|
||||
false
|
||||
}
|
||||
check_elasticsearch_version "$(cat version)"
|
||||
}
|
||||
|
||||
@test "[UPGRADE] verify that the documents are there after restart" {
|
||||
|
|
|
@ -44,12 +44,16 @@ export_elasticsearch_paths() {
|
|||
install_package() {
|
||||
local version=$(cat version)
|
||||
local rpmCommand='-i'
|
||||
while getopts ":uv:" opt; do
|
||||
while getopts ":fuv:" opt; do
|
||||
case $opt in
|
||||
u)
|
||||
rpmCommand='-U'
|
||||
dpkgCommand='--force-confnew'
|
||||
;;
|
||||
f)
|
||||
rpmCommand='-U --force'
|
||||
dpkgCommand='--force-conflicts'
|
||||
;;
|
||||
v)
|
||||
version=$OPTARG
|
||||
;;
|
||||
|
|
|
@ -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_script is_guide.groovy
|
||||
install_script is_guide.mustache
|
||||
|
|
|
@ -1,16 +1 @@
|
|||
2.0.0
|
||||
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
|
||||
6.0.0-alpha1-SNAPSHOT
|
||||
|
|
Loading…
Reference in New Issue