From 91b7524603650edbef984fd9fe83e352b90604d2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Wed, 10 Jan 2018 09:21:57 +0000 Subject: [PATCH] Use a venv with previous ansible version for upgrades When doing the role upgrade, we run every playbook with current's branch ansible. This is normal for the infrastructure bits (which are running on current branch), but not for the installation of the previous branch's role, which should use previous branch's environment. This commit adds: - A new venv build script, containing the previous version of ansible - A split between the infrastructure bits (running current ansible), the previous role run, and the upgrade of the role. Change-Id: I91fe4e867750d7cee9ad7d84b005eb0231849df9 Signed-off-by: Jean-Philippe Evrard Closes-Bug: #1741471 --- tests/create-previous-venv.sh | 33 +++++++++++++++++++++++++++++++++ tests/test-keystone-upgrades.sh | 24 ++++++++++++++++++++---- tests/test-upgrade-pre.yml | 3 --- 3 files changed, 53 insertions(+), 7 deletions(-) create mode 100755 tests/create-previous-venv.sh diff --git a/tests/create-previous-venv.sh b/tests/create-previous-venv.sh new file mode 100755 index 00000000..ee87c735 --- /dev/null +++ b/tests/create-previous-venv.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Copyright 2018, 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. + +## Shell Opts ---------------------------------------------------------------- + +set -e + +## Vars ---------------------------------------------------------------------- + +export WORKING_DIR=${WORKING_DIR:-$(pwd)} +export PREVIOUS_VENV=${PREVIOUS_VENV:-"ansible-previous"} + + +pushd ${WORKING_DIR}/.tox + virtualenv ${PREVIOUS_VENV} + ${PREVIOUS_VENV}/bin/pip install -c https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike \ + -rhttps://git.openstack.org/cgit/openstack/openstack-ansible/plain/global-requirement-pins.txt?h=stable/pike \ + -r${WORKING_DIR}/tests/common/previous/test-ansible-deps.txt + # Display venv contents + ${PREVIOUS_VENV}/bin/pip freeze +popd diff --git a/tests/test-keystone-upgrades.sh b/tests/test-keystone-upgrades.sh index 5c0aad53..fbd6f564 100755 --- a/tests/test-keystone-upgrades.sh +++ b/tests/test-keystone-upgrades.sh @@ -36,7 +36,7 @@ set -e export WORKING_DIR=${WORKING_DIR:-$(pwd)} export ROLE_NAME=${ROLE_NAME:-''} -export ANSIBLE_PARAMETERS=${ANSIBLE_PARAMETERS:-"-vvv"} +export ANSIBLE_PARAMETERS=${ANSIBLE_PARAMETERS:-"-vv"} 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} @@ -53,7 +53,8 @@ echo "TEST_IDEMPOTENCE: ${TEST_IDEMPOTENCE}" function execute_ansible_playbook { export ANSIBLE_CLI_PARAMETERS="${ANSIBLE_PARAMETERS} -e @${ANSIBLE_OVERRIDES}" - CMD_TO_EXECUTE="ansible-playbook ${TEST_PLAYBOOK} $@ ${ANSIBLE_CLI_PARAMETERS}" + export ANSIBLE_BIN=${ANSIBLE_BIN:-"ansible-playbook"} + CMD_TO_EXECUTE="${ANSIBLE_BIN} ${TEST_PLAYBOOK} $@ ${ANSIBLE_CLI_PARAMETERS}" echo "Executing: ${CMD_TO_EXECUTE}" echo "With:" @@ -69,13 +70,28 @@ function execute_ansible_playbook { # Ensure that the Ansible environment is properly prepared source "${COMMON_TESTS_PATH}/test-ansible-env-prep.sh" -# Prepare environment for the initial deploy of previous Keystone +# Prepare environment for the initial deploy of (previous and current) Keystone # 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-keystone-install.log" +export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/ansible-execute-keystone-infrainstall.log" +# Execute the setup of the Keystone environment +execute_ansible_playbook + +# Create an ansible venv matching previous branch +source ${WORKING_DIR}/tests/create-previous-venv.sh + +# Prepare environment for the deploy of previous Keystone: +# No upgrading or testing is done yet. +export TEST_PLAYBOOK="${WORKING_DIR}/tests/test-install-previous-keystone.yml" +export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/ansible-execute-keystone-install.log" +export PREVIOUS_VENV="ansible-previous" +export ANSIBLE_BIN="${WORKING_DIR}/.tox/${PREVIOUS_VENV}/bin/ansible-playbook" # Execute the setup of previous Keystone execute_ansible_playbook +# Unset previous branch overrides +unset PREVIOUS_VENV +unset ANSIBLE_BIN # Prepare environment for the upgrade of Keystone export TEST_PLAYBOOK="${WORKING_DIR}/tests/test-upgrade-post.yml" diff --git a/tests/test-upgrade-pre.yml b/tests/test-upgrade-pre.yml index f44a8186..48a659fa 100644 --- a/tests/test-upgrade-pre.yml +++ b/tests/test-upgrade-pre.yml @@ -33,6 +33,3 @@ # Ensure the repo is setup for previous version - include: common/previous/test-repo-setup.yml - -# Install previous Keystone -- include: test-install-previous-keystone.yml