Separate greenfield and upgrade tests

In order to independently test a greenfield deploy
and an upgrade, with the upgrade's initial deploy
using the previous stable branch role, we seperate
the two tests.

This makes it a more accurate test without having
to do funky workarounds in the role required to
cater for two versions of galera.

Depends-On: Ic881bf3acf6fb6daf71611c26322f02fb8b0b9be
Depends-On: I5c88b2019c01b44193a5d0df9299ecce6de52f01
Depends-On: I8b09c2520c84bb43353b4c56bac157259f71b041
Needed-By: I2aca4721e4e023d315f3fcdae0f931dc960ef2be
Change-Id: I0c74e511cec01ed51101b873784c4a90a7302da6
This commit is contained in:
Jesse Pretorius 2017-07-13 19:52:45 +01:00
parent 47162ce505
commit 0227dbe40d
7 changed files with 141 additions and 27 deletions

View File

@ -22,3 +22,7 @@
src: https://git.openstack.org/openstack/openstack-ansible-galera_client
scm: git
version: master
- name: previous_galera_server
src: https://git.openstack.org/openstack/openstack-ansible-galera_server
scm: git
version: stable/ocata

View File

@ -13,20 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
galera_server_old_package:
debian:
galera_mariadb_server_package: "mariadb-galera-server-10.0"
galera_repo_url: "http://mirror.rackspace.com/mariadb/repo/10.0/ubuntu"
redhat:
galera_mariadb_server_package: "MariaDB-Galera-server"
galera_repo_url: "http://yum.mariadb.org/10.0/centos/7/x86_64"
# NOTE(hwoarang): On SUSE we only have one version in the
# repos so this will not actually test the upgrade path. As such
# the following dictionary is mostly a NOOP just to keep the tests happy.
suse:
galera_mariadb_server_package: "mariadb"
galera_repo_url: "http://download.opensuse.org/repositories/server:/database/openSUSE_Leap_{{ ansible_distribution_version }}"
# Testing my.cnf overrides
galera_my_cnf_overrides:
sst:

88
tests/test-galera-upgrades.sh Executable file
View File

@ -0,0 +1,88 @@
#!/usr/bin/env bash
# Copyright 2016, Rackspace US, Inc.
#
# Licensed 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.
# WARNING:
# This file is use by all OpenStack-Ansible roles for testing purposes.
# Any changes here will affect all OpenStack-Ansible role repositories
# with immediate effect.
# PURPOSE:
# This script executes test Ansible playbooks required for performing
# an upgrade test of the role.
## Shell Opts ----------------------------------------------------------------
set -e
## Vars ----------------------------------------------------------------------
export WORKING_DIR=${WORKING_DIR:-$(pwd)}
export ROLE_NAME=${ROLE_NAME:-''}
export ANSIBLE_PARAMETERS=${ANSIBLE_PARAMETERS:-"-vvv"}
export TEST_PLAYBOOK=${TEST_PLAYBOOK:-$WORKING_DIR/tests/test-upgrade-pre.yml}
export TEST_CHECK_MODE=${TEST_CHECK_MODE:-false}
export TEST_IDEMPOTENCE=${TEST_IDEMPOTENCE:-false}
export COMMON_TESTS_PATH="${WORKING_DIR}/tests/common"
echo "ANSIBLE_OVERRIDES: ${ANSIBLE_OVERRIDES}"
echo "ANSIBLE_PARAMETERS: ${ANSIBLE_PARAMETERS}"
echo "TEST_PLAYBOOK: ${TEST_PLAYBOOK}"
echo "TEST_CHECK_MODE: ${TEST_CHECK_MODE}"
echo "TEST_IDEMPOTENCE: ${TEST_IDEMPOTENCE}"
## Functions -----------------------------------------------------------------
function execute_ansible_playbook {
export ANSIBLE_CLI_PARAMETERS="${ANSIBLE_PARAMETERS} -e @${ANSIBLE_OVERRIDES}"
CMD_TO_EXECUTE="ansible-playbook ${TEST_PLAYBOOK} $@ ${ANSIBLE_CLI_PARAMETERS}"
echo "Executing: ${CMD_TO_EXECUTE}"
echo "With:"
echo " ANSIBLE_INVENTORY: ${ANSIBLE_INVENTORY}"
echo " ANSIBLE_LOG_PATH: ${ANSIBLE_LOG_PATH}"
${CMD_TO_EXECUTE}
}
function gate_job_exit_tasks {
source "${COMMON_TESTS_PATH}/test-log-collect.sh"
}
## Main ----------------------------------------------------------------------
# Ensure that the Ansible environment is properly prepared
source "${COMMON_TESTS_PATH}/test-ansible-env-prep.sh"
# Set gate job exit traps, this is run regardless of exit state when the job finishes.
trap gate_job_exit_tasks EXIT
# Prepare environment for the initial deploy of previous version
# No upgrading or testing is done yet.
export TEST_PLAYBOOK="${WORKING_DIR}/tests/test-upgrade-pre.yml"
export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/ansible-execute-install.log"
# Execute the setup of previous version
execute_ansible_playbook
# Prepare environment for the upgrade
export TEST_PLAYBOOK="${WORKING_DIR}/tests/test-upgrade-post.yml"
export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/ansible-execute-upgrade.log"
# Execute the upgrade
execute_ansible_playbook

View File

@ -13,13 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Deploy galera
# Install current version Galera server
- name: Deploy current galera version
hosts: galera_all
user: root
serial: 1
max_fail_percentage: 20
gather_facts: true
roles:
- role: "galera_server"
vars:
galera_upgrade: true
vars_files:
- common/test-vars.yml
# Re-run functional tests
- include: test-galera-server-functional.yml

View File

@ -0,0 +1,31 @@
---
# Copyright 2015, Rackspace US, Inc.
#
# Licensed 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.
# Setup the host
- include: common/test-setup-host.yml
# Prepare the containers
- include: common/test-prepare-containers.yml
# Install previous version
- name: Deploy previous galera version
hosts: galera_all
user: root
serial: 1
gather_facts: true
roles:
- role: "previous_galera_server"
vars_files:
- common/previous/test-vars.yml

View File

@ -21,17 +21,6 @@
# Install previous version Galera server
- include: common/test-install-galera.yml
vars:
galera_mariadb_server_package: "{{ galera_server_old_package[ansible_os_family | lower]['galera_mariadb_server_package'] }}"
galera_repo_url: "{{ galera_server_old_package[ansible_os_family | lower]['galera_repo_url'] }}"
# Run functional tests
- include: test-galera-server-functional.yml
# Install current version Galera server
- include: test-install-galera-upgrade.yml
vars:
galera_upgrade: true
# Re-run functional tests
- include: test-galera-server-functional.yml

11
tox.ini
View File

@ -102,6 +102,17 @@ commands =
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
[testenv:upgrade]
deps =
{[testenv:ansible]deps}
setenv =
{[testenv]setenv}
ANSIBLE_OVERRIDES={toxinidir}/tests/galera_server-overrides.yml
CLONE_UPGRADE_TESTS=yes
commands =
bash -c "{toxinidir}/tests/tests-repo-clone.sh"
bash -c "{toxinidir}/tests/test-galera-upgrades.sh"
[testenv:ssl]
deps =
{[testenv:ansible]deps}