diff --git a/qa/vagrant/pom.xml b/qa/vagrant/pom.xml
index 728b83d88bb..c2b6ca79dca 100644
--- a/qa/vagrant/pom.xml
+++ b/qa/vagrant/pom.xml
@@ -34,6 +34,11 @@
/usr/bin/rpmbuild
+
+
+ 2.0.0-beta1
@@ -92,6 +97,14 @@
${elasticsearch.version}
deb
+
+
+ org.elasticsearch.distribution.deb
+ elasticsearch
+ ${upgrade.from.version}
+ deb
+
org.elasticsearch.plugin
jvm-example
@@ -219,6 +232,21 @@
+
+ setup-version-files
+ pre-integration-test
+
+ run
+
+
+
+
+
+
+
+
test-vms
integration-test
@@ -269,6 +297,14 @@
${elasticsearch.version}
rpm
+
+
+ org.elasticsearch.distribution.rpm
+ elasticsearch
+ ${upgrade.from.version}
+ rpm
+
@@ -309,6 +345,14 @@
${elasticsearch.version}
rpm
+
+
+ org.elasticsearch.distribution.rpm
+ elasticsearch
+ ${upgrade.from.version}
+ rpm
+
diff --git a/qa/vagrant/src/test/resources/packaging/scripts/30_deb_package.bats b/qa/vagrant/src/test/resources/packaging/scripts/30_deb_package.bats
index 3367e62fcf8..38aa352d4c4 100644
--- a/qa/vagrant/src/test/resources/packaging/scripts/30_deb_package.bats
+++ b/qa/vagrant/src/test/resources/packaging/scripts/30_deb_package.bats
@@ -46,7 +46,7 @@ setup() {
}
@test "[DEB] package is available" {
- count=$(find . -type f -name 'elastic*.deb' | wc -l)
+ count=$(ls elasticsearch-$(cat version).deb | wc -l)
[ "$count" -eq 1 ]
}
@@ -56,7 +56,7 @@ setup() {
}
@test "[DEB] install package" {
- dpkg -i elasticsearch*.deb
+ dpkg -i elasticsearch-$(cat version).deb
}
@test "[DEB] package is installed" {
diff --git a/qa/vagrant/src/test/resources/packaging/scripts/40_rpm_package.bats b/qa/vagrant/src/test/resources/packaging/scripts/40_rpm_package.bats
index cbcdd794c76..b5d8a7b2844 100644
--- a/qa/vagrant/src/test/resources/packaging/scripts/40_rpm_package.bats
+++ b/qa/vagrant/src/test/resources/packaging/scripts/40_rpm_package.bats
@@ -45,7 +45,7 @@ setup() {
}
@test "[RPM] package is available" {
- count=$(find . -type f -name 'elastic*.rpm' | wc -l)
+ count=$(ls elasticsearch-$(cat version).rpm | wc -l)
[ "$count" -eq 1 ]
}
@@ -55,7 +55,7 @@ setup() {
}
@test "[RPM] install package" {
- rpm -i elasticsearch*.rpm
+ rpm -i elasticsearch-$(cat version).rpm
}
@test "[RPM] package is installed" {
diff --git a/qa/vagrant/src/test/resources/packaging/scripts/80_upgrade.bats b/qa/vagrant/src/test/resources/packaging/scripts/80_upgrade.bats
new file mode 100644
index 00000000000..fceea65d29a
--- /dev/null
+++ b/qa/vagrant/src/test/resources/packaging/scripts/80_upgrade.bats
@@ -0,0 +1,105 @@
+#!/usr/bin/env bats
+
+# Tests upgrading elasticsearch from a previous version with the deb or rpm
+# packages. Just uses a single node cluster on the current machine rather than
+# fancy rolling restarts.
+
+# 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.
+
+# The test case can be executed with the Bash Automated
+# Testing System tool available at https://github.com/sstephenson/bats
+# Thanks to Sam Stephenson!
+
+# 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.
+
+# Load test utilities
+load packaging_test_utils
+
+# Cleans everything for the 1st execution
+setup() {
+ skip_not_dpkg_or_rpm
+}
+
+@test "[UPGRADE] install old version" {
+ clean_before_test
+ install_package -v $(cat upgrade_from_version)
+}
+
+@test "[UPGRADE] start old version" {
+ start_elasticsearch_service
+}
+
+@test "[UPGRADE] check elasticsearch version is old version" {
+ curl -s localhost:9200 | grep \"number\"\ :\ \"$(cat upgrade_from_version)\" || {
+ echo "Installed an unexpected version:"
+ curl localhost:9200
+ false
+ }
+}
+
+@test "[UPGRADE] index some documents into a few indexes" {
+ curl -s -XPOST localhost:9200/library/book/1?pretty -d '{
+ "title": "Elasticsearch - The Definitive Guide"
+ }'
+ curl -s -XPOST localhost:9200/library/book/2?pretty -d '{
+ "title": "Brave New World"
+ }'
+ curl -s -XPOST localhost:9200/library2/book/1?pretty -d '{
+ "title": "The Left Hand of Darkness"
+ }'
+}
+
+@test "[UPGRADE] verify that the documents are there" {
+ curl -s localhost:9200/library/book/1?pretty | grep Elasticsearch
+ curl -s localhost:9200/library/book/2?pretty | grep World
+ curl -s localhost:9200/library2/book/1?pretty | grep Darkness
+}
+
+@test "[UPGRADE] stop old version" {
+ stop_elasticsearch_service
+}
+
+@test "[UPGRADE] install version under test" {
+ install_package -u
+}
+
+@test "[UPGRADE] start version under test" {
+ start_elasticsearch_service yellow
+}
+
+@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
+ }
+}
+
+@test "[UPGRADE] verify that the documents are there after restart" {
+ curl -s localhost:9200/library/book/1?pretty | grep Elasticsearch
+ curl -s localhost:9200/library/book/2?pretty | grep World
+ curl -s localhost:9200/library2/book/1?pretty | grep Darkness
+}
+
+@test "[UPGRADE] stop version under test" {
+ stop_elasticsearch_service
+}
diff --git a/qa/vagrant/src/test/resources/packaging/scripts/packaging_test_utils.bash b/qa/vagrant/src/test/resources/packaging/scripts/packaging_test_utils.bash
index 9eff5894c17..ff7255c5417 100644
--- a/qa/vagrant/src/test/resources/packaging/scripts/packaging_test_utils.bash
+++ b/qa/vagrant/src/test/resources/packaging/scripts/packaging_test_utils.bash
@@ -232,12 +232,29 @@ verify_package_installation() {
fi
}
-# Install the rpm or deb package
+# Install the rpm or deb package.
+# -u upgrade rather than install. This only matters for rpm.
+# -v the version to upgrade to. Defaults to the version under test.
install_package() {
+ local version=$(cat version)
+ local rpmCommand='-i'
+ while getopts ":uv:" opt; do
+ case $opt in
+ u)
+ rpmCommand='-U'
+ ;;
+ v)
+ version=$OPTARG
+ ;;
+ \?)
+ echo "Invalid option: -$OPTARG" >&2
+ ;;
+ esac
+ done
if is_rpm; then
- rpm -i elasticsearch*.rpm
+ rpm $rpmCommand elasticsearch-$version.rpm
elif is_dpkg; then
- dpkg -i elasticsearch*.deb
+ dpkg -i elasticsearch-$version.deb
else
skip "Only rpm or deb supported"
fi
@@ -317,7 +334,11 @@ clean_before_test() {
done
}
+# Start elasticsearch and wait for it to come up with a status.
+# $1 - expected status - defaults to green
start_elasticsearch_service() {
+ local desiredStatus=${1:-green}
+
if [ -f "/tmp/elasticsearch/bin/elasticsearch" ]; then
# su and the Elasticsearch init script work together to break bats.
# sudo isolates bats enough from the init script so everything continues
@@ -342,7 +363,7 @@ start_elasticsearch_service() {
[ "$status" -eq 0 ]
fi
- wait_for_elasticsearch_status
+ wait_for_elasticsearch_status $desiredStatus
if [ -r "/tmp/elasticsearch/elasticsearch.pid" ]; then
pid=$(cat /tmp/elasticsearch/elasticsearch.pid)
@@ -387,12 +408,10 @@ stop_elasticsearch_service() {
fi
}
-# Waits for Elasticsearch to reach a given status (defaults to "green")
+# Waits for Elasticsearch to reach some status.
+# $1 - expected status - defaults to green
wait_for_elasticsearch_status() {
- local desired_status="green"
- if [ "x$1" != "x" ]; then
- status="$1"
- fi
+ local desiredStatus=${1:-green}
echo "Making sure elasticsearch is up..."
wget -O - --retry-connrefused --waitretry=1 --timeout=60 http://localhost:9200 || {
@@ -411,7 +430,7 @@ wait_for_elasticsearch_status() {
}
echo "Tring to connect to elasticsearch and wait for expected status..."
- curl -sS "http://localhost:9200/_cluster/health?wait_for_status=$desired_status&timeout=60s&pretty"
+ curl -sS "http://localhost:9200/_cluster/health?wait_for_status=$desiredStatus&timeout=60s&pretty"
if [ $? -eq 0 ]; then
echo "Connected"
else
@@ -426,8 +445,8 @@ wait_for_elasticsearch_status() {
echo $output
false
fi
- echo $output | grep $desired_status || {
- echo "unexpected status: '$output' wanted '$desired_status'"
+ echo $output | grep $desiredStatus || {
+ echo "unexpected status: '$output' wanted '$desiredStatus'"
false
}
}