From 2aa4a3f7d2bacfbbf58f6cf35f37ce654939dcff Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 2 Mar 2017 15:24:35 +0000 Subject: [PATCH] Adjust gate-check-commit for deploy/upgrade testing In order to facilitate periodic deployment and upgrade testing, this patch implements an 'action' as a second CLI parameter for the gate-check-commit script. This seperates the 'action' from the 'scenario', allowing us to execute a gate-check-commit for multiple scenarios instead of being stuck with only one. That is why the 'upgrade' scenario is removed. This patch is partnered with this project-config change: https://review.openstack.org/419517 The patch also tidies a few things up in order to make the script a little more readable. Change-Id: Ie62efc188d5eafd5bb64eb53f14c191dd50bef33 --- scripts/gate-check-commit.sh | 58 +++++++++++++++++++++++------------- tests/bootstrap-aio.yml | 19 ++---------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/scripts/gate-check-commit.sh b/scripts/gate-check-commit.sh index 3672e73f52..acc35a0f61 100755 --- a/scripts/gate-check-commit.sh +++ b/scripts/gate-check-commit.sh @@ -17,26 +17,38 @@ set -e -u -x ## Variables ----------------------------------------------------------------- + +# Successerator: How many times do we try before failing export MAX_RETRIES=${MAX_RETRIES:-"2"} + # tempest and testr options, default is to run tempest in serial export TESTR_OPTS=${TESTR_OPTS:-''} + # Disable the python output buffering so that jenkins gets the output properly export PYTHONUNBUFFERED=1 + # Extra options to pass to the AIO bootstrap process export BOOTSTRAP_OPTS=${BOOTSTRAP_OPTS:-''} + # This variable is being added to ensure the gate job executes an exit # function at the end of the run. export OSA_GATE_JOB=true -# Set the role fetch mode to any option [galaxy, git-clone] + +# Set the role fetch mode to git-clone to avoid interactions +# with the Ansible galaxy API. export ANSIBLE_ROLE_FETCH_MODE="git-clone" + # Set the scenario to execute based on the first CLI parameter export SCENARIO=${1:-"aio"} -# TODO(sc68cal) update the job configs to have the stable branch -# So we have job names like: -# gate-openstack-ansible-openstack-ansible-upgrade-newton-ubuntu-xenial-nv -export UPGRADE_BASEBRANCH=${2:-"ocata"} -export SCENARIO_BACKUP=${SCENARIO_BACKUP:-''} +# Set the action base on the second CLI parameter +# Actions available: [ 'deploy', 'upgrade' ] +export ACTION=${2:-"deploy"} + +# Set the source branch for upgrade tests +# Be sure to change this whenever a new stable branch +# is created. The checkout must always be N-1. +export UPGRADE_SOURCE_BRANCH=${UPGRADE_SOURCE_BRANCH:-'stable/ocata'} ## Functions ----------------------------------------------------------------- info_block "Checking for required libraries." 2> /dev/null || source "$(dirname "${0}")/scripts-library.sh" @@ -48,14 +60,15 @@ trap gate_job_exit_tasks EXIT # Log some data about the instance and the rest of the system log_instance_info +# If the action is to upgrade, then store the current SHA, +# checkout the source SHA before executing the greenfield +# deployment. +if [[ "${ACTION}" == "upgrade" ]]; then + # Store the target SHA/branch + export UPGRADE_TARGET_BRANCH=$(git rev-parse HEAD) -if [[ "$SCENARIO" == "upgrade" ]]; then - # First, check out the base branch and build an AIO - git checkout origin/stable/$UPGRADE_BASEBRANCH - - # Do a quick swap of SCENARIO since the newton branch doesn't know about the upgrade scenario - export SCENARIO_BACKUP=$SCENARIO - SCENARIO="aio" + # Now checkout the source SHA/branch + git checkout origin/${UPGRADE_SOURCE_BRANCH} fi # Get minimum disk size @@ -121,16 +134,21 @@ bash "$(dirname "${0}")/run-playbooks.sh" # Log some data about the instance and the rest of the system log_instance_info -if [ ! -z $SCENARIO_BACKUP ]; then - # Restore the scenario from L56 - SCENARIO=$SCENARIO_BACKUP -fi +# If the action is to upgrade, then checkout the original SHA for +# the checkout, and execute the upgrade. +if [[ "${ACTION}" == "upgrade" ]]; then -if [[ "$SCENARIO" == "upgrade" ]]; then - # Hopefully we can re-check out the patch from Zuul. - git checkout FETCH_HEAD + # Checkout the original HEAD we started with + git checkout ${UPGRADE_TARGET_BRANCH} + + # There is a protection in the run-upgrade script + # to prevent people doing anything silly. We need + # to bypass that for an automated test. export I_REALLY_KNOW_WHAT_I_AM_DOING=true + + # Execute the upgrade script. bash "$(dirname "${0}")/run-upgrade.sh" + fi exit_success diff --git a/tests/bootstrap-aio.yml b/tests/bootstrap-aio.yml index 79a2415d79..69784faebf 100644 --- a/tests/bootstrap-aio.yml +++ b/tests/bootstrap-aio.yml @@ -22,9 +22,8 @@ - role: "pip_install" - role: "bootstrap-host" vars: - openstack_confd_entries: "{{ confd_overrides[scenario] }}" - bootstrap_host_scenario: "{{ scenario }}" - scenario: "{{ lookup('env','SCENARIO') | default('aio', true) }}" + openstack_confd_entries: "{{ confd_overrides[bootstrap_host_scenario] }}" + bootstrap_host_scenario: "{{ lookup('env','SCENARIO') | default('aio', true) }}" confd_overrides: aio: - name: cinder.yml.aio @@ -45,20 +44,6 @@ - name: keystone.yml.aio - name: neutron.yml.aio - name: nova.yml.aio - upgrade: - # This starts as an AIO box, then an upgrade is run - - name: aodh.yml.aio - - name: cinder.yml.aio - - name: ceilometer.yml.aio - - name: designate.yml.aio - - name: glance.yml.aio - - name: gnocchi.yml.aio - - name: heat.yml.aio - - name: horizon.yml.aio - - name: keystone.yml.aio - - name: neutron.yml.aio - - name: nova.yml.aio - - name: swift.yml.aio sftp_subsystem: "{{ (ansible_pkg_mgr == 'apt') | ternary('sftp /usr/lib/openssh/sftp-server','sftp /usr/libexec/openssh/sftp-server') }}" sshd: ListenAddress: