Fix workspace setup

Stable branch overrides for client testing, devstack-gate alternate-branch
testing, and grenade old/new branch selection are all actually the same
thing.  Update setup_project to reflect that, fixing all known bugs in
the process.  Note that some jobs will need to be updated to pass in
OVERRIDE_ZUUL_BRANCH.

This is an update to the previously reverted change to add testing and a fix
for an issue seen in production.  The resulting code is actually simpler, but
it is worth noting that the check to ensure that at some point the ZUUL_REF
for the project was checked out has been removed.

Change-Id: Ie0c4b30878896684cc2faf02dee1ea222594ae6d
This commit is contained in:
James E. Blair 2013-12-24 14:54:55 -08:00
parent 830cf239cd
commit a8aabdb966
3 changed files with 121 additions and 65 deletions

View File

@ -204,6 +204,10 @@ export DEVSTACK_GATE_SELECT_MIRROR=${DEVSTACK_GATE_SELECT_MIRROR:-/usr/local/jen
# to run before being aborted (default 60). # to run before being aborted (default 60).
export DEVSTACK_GATE_TIMEOUT=${DEVSTACK_GATE_TIMEOUT:-60} export DEVSTACK_GATE_TIMEOUT=${DEVSTACK_GATE_TIMEOUT:-60}
# Set this to override the branch selected for testing (in
# single-branch checkouts; not used for grenade)
export OVERRIDE_ZUUL_BRANCH=${OVERRIDE_ZUUL_BRANCH:-$ZUUL_BRANCH}
if ! function_exists "gate_hook"; then if ! function_exists "gate_hook"; then
# the command we use to run the gate # the command we use to run the gate
function gate_hook { function gate_hook {
@ -224,7 +228,7 @@ if [ "$DEVSTACK_GATE_GRENADE" -eq "1" -o "$DEVSTACK_GATE_GRENADE_FORWARD" -eq "1
setup_workspace $GRENADE_OLD_BRANCH $BASE/old &> \ setup_workspace $GRENADE_OLD_BRANCH $BASE/old &> \
$WORKSPACE/logs/devstack-gate-setup-workspace-old.txt $WORKSPACE/logs/devstack-gate-setup-workspace-old.txt
else else
setup_workspace $ZUUL_BRANCH $BASE/new &> \ setup_workspace $OVERRIDE_ZUUL_BRANCH $BASE/new &> \
$WORKSPACE/logs/devstack-gate-setup-workspace-new.txt $WORKSPACE/logs/devstack-gate-setup-workspace-new.txt
fi fi

View File

@ -138,16 +138,29 @@ function fix_disk_layout {
fi fi
} }
# do all the zuulification magic for project at a specified branch # Set up a project in accordance with the future state proposed by
# Zuul.
# #
# The basic logic flow is as follows: # Arguments:
# if we have ``branch`` for project, check that out # project: The full name of the project to set up
# if we don't have ``branch`` for project, change ``branch`` to master # branch: The branch to check out
# and check that out #
# if the global ZUUL_BRANCH matches ``branch``, then also look for a # The branch argument should be the desired branch to check out. If
# valid ZUUL_REF, and use that instead of the HEAD of the branch # you have no other opinions, then you should supply ZUUL_BRANCH here.
# This is generally the branch corresponding with the change being
# tested.
#
# If you would like to check out a branch other than what ZUUL has
# selected, for example in order to check out the old or new branches
# for grenade, or an alternate branch to test client library
# compatability, then supply that as the argument instead. This
# function will try to check out the following (in order):
#
# The zuul ref for the indicated branch
# The zuul ref for the master branch
# The tip of the indicated branch
# The tip of the master branch
# #
# The end result is a tree on disk checked out at the right ref for zuul
function setup_project { function setup_project {
local project=$1 local project=$1
local branch=$2 local branch=$2
@ -158,9 +171,8 @@ function setup_project {
git_remote_set_url origin https://git.openstack.org/$project git_remote_set_url origin https://git.openstack.org/$project
if [ -n "$OVERRIDE_ZUUL_BRANCH" ] ; then # Try the specified branch before the ZUUL_BRANCH.
OVERRIDE_ZUUL_REF=$(echo $ZUUL_REF | sed -e "s,$branch,$OVERRIDE_ZUUL_BRANCH,") OVERRIDE_ZUUL_REF=$(echo $ZUUL_REF | sed -e "s,$ZUUL_BRANCH,$branch,")
fi
# Update git remotes # Update git remotes
git_remote_update git_remote_update
@ -169,29 +181,21 @@ function setup_project {
# See if this project has this branch, if not, use master # See if this project has this branch, if not, use master
FALLBACK_ZUUL_REF="" FALLBACK_ZUUL_REF=""
if ! git_has_branch $project $branch; then if ! git_has_branch $project $branch; then
branch=master
FALLBACK_ZUUL_REF=$(echo $ZUUL_REF | sed -e "s,$branch,master,") FALLBACK_ZUUL_REF=$(echo $ZUUL_REF | sed -e "s,$branch,master,")
fi fi
# See if we should check out a Zuul ref # See if Zuul prepared a ref for this project
if [ "$ZUUL_BRANCH" == "$branch" ]; then if git_fetch_at_ref $project $OVERRIDE_ZUUL_REF || \
# See if Zuul prepared a ref for this project git_fetch_at_ref $project $FALLBACK_ZUUL_REF; then
if git_fetch_at_ref $project $OVERRIDE_ZUUL_REF || \
git_fetch_at_ref $project $ZUUL_REF || \
git_fetch_at_ref $project $FALLBACK_ZUUL_REF; then
# It's there, so check it out. # It's there, so check it out.
git_checkout $project FETCH_HEAD git_checkout $project FETCH_HEAD
else
if [ "$project" == "$ZUUL_PROJECT" ]; then
echo "Unable to find ref $ZUUL_REF for $project"
exit 1
fi
git_checkout $project $branch
fi
else else
# We're ignoring Zuul refs if git_has_branch $project $branch; then
git_checkout $project $branch git_checkout $project $branch
else
git_checkout $project master
fi
fi fi
} }

View File

@ -63,6 +63,8 @@ function git_has_branch {
case $project in case $project in
openstack/glance) return 0 ;; openstack/glance) return 0 ;;
openstack/swift) return 0 ;; openstack/swift) return 0 ;;
openstack/nova) return 0 ;;
openstack/keystone) return 0 ;;
esac esac
esac esac
return 1 return 1
@ -176,16 +178,17 @@ function test_multi_branch_on_stable {
setup_project openstack/glance $ZUUL_BRANCH setup_project openstack/glance $ZUUL_BRANCH
setup_project openstack/python-glanceclient $ZUUL_BRANCH setup_project openstack/python-glanceclient $ZUUL_BRANCH
#TODO: This is a test failure indicating a bug assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZB' $LINENO
#assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZB' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/stable/havana/ZB' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/stable/havana/ZB' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO
} }
function test_grenade_backward { function test_grenade_backward {
# devstack-gate master ZA # devstack-gate master ZA
# glance stable/havana ZB # nova stable/havana ZB
# glance master ZC # keystone stable/havana ZC
# keystone master ZD
# glance master ZE
# swift not in queue # swift not in queue
# python-glanceclient not in queue # python-glanceclient not in queue
echo "== Test grenade backward" echo "== Test grenade backward"
@ -195,44 +198,62 @@ function test_grenade_backward {
declare -A TEST_ZUUL_REFS declare -A TEST_ZUUL_REFS
ZUUL_PROJECT='openstack/glance' ZUUL_PROJECT='openstack/glance'
ZUUL_BRANCH='master' ZUUL_BRANCH='master'
ZUUL_REF='refs/zuul/master/ZC' ZUUL_REF='refs/zuul/master/ZE'
GRENADE_OLD_BRANCH='stable/havana' GRENADE_OLD_BRANCH='stable/havana'
GRENADE_NEW_BRANCH='master' GRENADE_NEW_BRANCH='master'
TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZA' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZA'
TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZB' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZB'
TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZC' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZC'
TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZB' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZD'
TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZC' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZE'
TEST_ZUUL_REFS[glance]+=' refs/zuul/master/ZC' TEST_ZUUL_REFS[nova]+=' refs/zuul/stable/havana/ZB'
TEST_ZUUL_REFS[nova]+=' refs/zuul/stable/havana/ZC'
TEST_ZUUL_REFS[nova]+=' refs/zuul/stable/havana/ZD'
TEST_ZUUL_REFS[nova]+=' refs/zuul/stable/havana/ZE'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/stable/havana/ZC'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/stable/havana/ZD'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/stable/havana/ZE'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/master/ZD'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/master/ZE'
TEST_ZUUL_REFS[glance]+=' refs/zuul/master/ZE'
setup_project openstack-infra/devstack-gate $GRENADE_OLD_BRANCH setup_project openstack-infra/devstack-gate $GRENADE_OLD_BRANCH
setup_project openstack/nova $GRENADE_OLD_BRANCH
setup_project openstack/keystone $GRENADE_OLD_BRANCH
setup_project openstack/glance $GRENADE_OLD_BRANCH setup_project openstack/glance $GRENADE_OLD_BRANCH
setup_project openstack/swift $GRENADE_OLD_BRANCH setup_project openstack/swift $GRENADE_OLD_BRANCH
setup_project openstack/python-glanceclient $GRENADE_OLD_BRANCH setup_project openstack/python-glanceclient $GRENADE_OLD_BRANCH
assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZC' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZE' $LINENO
#TODO: This is a test failure indicating a bug assert_equal "${TEST_GIT_CHECKOUTS[nova]}" 'refs/zuul/stable/havana/ZE' $LINENO
#assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/stable/havana/ZC' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[keystone]}" 'refs/zuul/stable/havana/ZE' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'stable/havana' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'stable/havana' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'stable/havana' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO
declare -A TEST_GIT_CHECKOUTS declare -A TEST_GIT_CHECKOUTS
setup_project openstack-infra/devstack-gate $GRENADE_NEW_BRANCH setup_project openstack-infra/devstack-gate $GRENADE_NEW_BRANCH
setup_project openstack/nova $GRENADE_NEW_BRANCH
setup_project openstack/keystone $GRENADE_NEW_BRANCH
setup_project openstack/glance $GRENADE_NEW_BRANCH setup_project openstack/glance $GRENADE_NEW_BRANCH
setup_project openstack/swift $GRENADE_NEW_BRANCH setup_project openstack/swift $GRENADE_NEW_BRANCH
setup_project openstack/python-glanceclient $GRENADE_NEW_BRANCH setup_project openstack/python-glanceclient $GRENADE_NEW_BRANCH
assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZC' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZE' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/master/ZC' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[nova]}" 'master' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[keystone]}" 'refs/zuul/master/ZE' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/master/ZE' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'master' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'master' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO
} }
function test_grenade_forward { function test_grenade_forward {
# devstack-gate master ZA # devstack-gate master ZA
# glance master ZB # nova master ZB
# glance stable/havana ZC # keystone stable/havana ZC
# keystone master ZD
# glance stable/havana ZE
# swift not in queue # swift not in queue
# python-glanceclient not in queue # python-glanceclient not in queue
echo "== Test grenade forward" echo "== Test grenade forward"
@ -242,38 +263,52 @@ function test_grenade_forward {
declare -A TEST_ZUUL_REFS declare -A TEST_ZUUL_REFS
ZUUL_PROJECT='openstack/glance' ZUUL_PROJECT='openstack/glance'
ZUUL_BRANCH='stable/havana' ZUUL_BRANCH='stable/havana'
ZUUL_REF='refs/zuul/stable/havana/ZC' ZUUL_REF='refs/zuul/stable/havana/ZE'
GRENADE_OLD_BRANCH='stable/havana' GRENADE_OLD_BRANCH='stable/havana'
GRENADE_NEW_BRANCH='master' GRENADE_NEW_BRANCH='master'
TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZA' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZA'
TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZB' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZB'
TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZC' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZC'
TEST_ZUUL_REFS[glance]+=' refs/zuul/master/ZB' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZD'
TEST_ZUUL_REFS[glance]+=' refs/zuul/master/ZC' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZE'
TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZC' TEST_ZUUL_REFS[nova]+=' refs/zuul/master/ZB'
TEST_ZUUL_REFS[nova]+=' refs/zuul/master/ZC'
TEST_ZUUL_REFS[nova]+=' refs/zuul/master/ZD'
TEST_ZUUL_REFS[nova]+=' refs/zuul/master/ZE'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/stable/havana/ZC'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/stable/havana/ZD'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/stable/havana/ZE'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/master/ZD'
TEST_ZUUL_REFS[keystone]+=' refs/zuul/master/ZE'
TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZE'
setup_project openstack-infra/devstack-gate $GRENADE_OLD_BRANCH setup_project openstack-infra/devstack-gate $GRENADE_OLD_BRANCH
setup_project openstack/nova $GRENADE_OLD_BRANCH
setup_project openstack/keystone $GRENADE_OLD_BRANCH
setup_project openstack/glance $GRENADE_OLD_BRANCH setup_project openstack/glance $GRENADE_OLD_BRANCH
setup_project openstack/swift $GRENADE_OLD_BRANCH setup_project openstack/swift $GRENADE_OLD_BRANCH
setup_project openstack/python-glanceclient $GRENADE_OLD_BRANCH setup_project openstack/python-glanceclient $GRENADE_OLD_BRANCH
#TODO: This is a test failure indicating a bug assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZE' $LINENO
#assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZC' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[nova]}" 'stable/havana' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/stable/havana/ZC' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[keystone]}" 'refs/zuul/stable/havana/ZE' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/stable/havana/ZE' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'stable/havana' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'stable/havana' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO
declare -A TEST_GIT_CHECKOUTS declare -A TEST_GIT_CHECKOUTS
setup_project openstack-infra/devstack-gate $GRENADE_NEW_BRANCH setup_project openstack-infra/devstack-gate $GRENADE_NEW_BRANCH
setup_project openstack/nova $GRENADE_NEW_BRANCH
setup_project openstack/keystone $GRENADE_NEW_BRANCH
setup_project openstack/glance $GRENADE_NEW_BRANCH setup_project openstack/glance $GRENADE_NEW_BRANCH
setup_project openstack/swift $GRENADE_NEW_BRANCH setup_project openstack/swift $GRENADE_NEW_BRANCH
setup_project openstack/python-glanceclient $GRENADE_NEW_BRANCH setup_project openstack/python-glanceclient $GRENADE_NEW_BRANCH
#TODO: This is a test failure indicating a bug assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZE' $LINENO
#assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZC' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[nova]}" 'refs/zuul/master/ZE' $LINENO
#TODO: This is a test failure indicating a bug assert_equal "${TEST_GIT_CHECKOUTS[keystone]}" 'refs/zuul/master/ZE' $LINENO
#assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/master/ZC' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'master' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'master' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'master' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO
} }
@ -288,25 +323,37 @@ function test_branch_override {
declare -A TEST_GIT_CHECKOUTS declare -A TEST_GIT_CHECKOUTS
declare -A TEST_ZUUL_REFS declare -A TEST_ZUUL_REFS
ZUUL_PROJECT='openstack-infra/devstack-gate' ZUUL_PROJECT='openstack-infra/devstack-gate'
ZUUL_BRANCH='stable/havana' # branch override ZUUL_BRANCH='master'
ZUUL_REF='refs/zuul/master/ZB' ZUUL_REF='refs/zuul/master/ZB'
OVERRIDE_ZUUL_BRANCH='stable/havana'
TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZB' TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZB'
TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZA' TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZA'
TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZB' TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZB'
setup_project openstack-infra/devstack-gate $ZUUL_BRANCH setup_project openstack-infra/devstack-gate $OVERRIDE_ZUUL_BRANCH
setup_project openstack/glance $ZUUL_BRANCH setup_project openstack/glance $OVERRIDE_ZUUL_BRANCH
setup_project openstack/swift $ZUUL_BRANCH setup_project openstack/swift $OVERRIDE_ZUUL_BRANCH
setup_project openstack/python-glanceclient $ZUUL_BRANCH setup_project openstack/python-glanceclient $OVERRIDE_ZUUL_BRANCH
#TODO: This is a test failure indicating a bug assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZB' $LINENO
#assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZB' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/stable/havana/ZB' $LINENO
#TODO: This is a test failure indicating a bug
#assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/stable/havana/ZB' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'stable/havana' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[swift]}" 'stable/havana' $LINENO
assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master' $LINENO
} }
function test_periodic {
# No queue
echo "== Test periodic"
declare -A TEST_GIT_CHECKOUTS
declare -A TEST_ZUUL_REFS
ZUUL_BRANCH='stable/havana'
setup_project openstack/glance $ZUUL_BRANCH
assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'stable/havana' $LINENO
}
# Run tests: # Run tests:
#set -o xtrace #set -o xtrace
test_two_on_master test_two_on_master
@ -316,3 +363,4 @@ test_multi_branch_on_stable
test_grenade_backward test_grenade_backward
test_grenade_forward test_grenade_forward
test_branch_override test_branch_override
test_periodic