From 0227dbe40dfd4d21a8a92ec038a608efab5ebe18 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 13 Jul 2017 19:52:45 +0100 Subject: [PATCH] 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 --- tests/ansible-role-requirements.yml | 4 + tests/galera_server-overrides.yml | 14 --- tests/test-galera-upgrades.sh | 88 +++++++++++++++++++ ...lera-upgrade.yml => test-upgrade-post.yml} | 9 +- tests/test-upgrade-pre.yml | 31 +++++++ tests/test.yml | 11 --- tox.ini | 11 +++ 7 files changed, 141 insertions(+), 27 deletions(-) create mode 100755 tests/test-galera-upgrades.sh rename tests/{test-install-galera-upgrade.yml => test-upgrade-post.yml} (80%) create mode 100644 tests/test-upgrade-pre.yml diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml index 3a7a721e..653ce2a6 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -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 diff --git a/tests/galera_server-overrides.yml b/tests/galera_server-overrides.yml index ea261563..ec443a06 100644 --- a/tests/galera_server-overrides.yml +++ b/tests/galera_server-overrides.yml @@ -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: diff --git a/tests/test-galera-upgrades.sh b/tests/test-galera-upgrades.sh new file mode 100755 index 00000000..e6ee74ee --- /dev/null +++ b/tests/test-galera-upgrades.sh @@ -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 diff --git a/tests/test-install-galera-upgrade.yml b/tests/test-upgrade-post.yml similarity index 80% rename from tests/test-install-galera-upgrade.yml rename to tests/test-upgrade-post.yml index 7db33cca..18a3bc4c 100644 --- a/tests/test-install-galera-upgrade.yml +++ b/tests/test-upgrade-post.yml @@ -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 diff --git a/tests/test-upgrade-pre.yml b/tests/test-upgrade-pre.yml new file mode 100644 index 00000000..ca11b7e6 --- /dev/null +++ b/tests/test-upgrade-pre.yml @@ -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 diff --git a/tests/test.yml b/tests/test.yml index 2dcaae9a..9213db8a 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -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 diff --git a/tox.ini b/tox.ini index b3527e76..e70ca026 100644 --- a/tox.ini +++ b/tox.ini @@ -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}