Allow for git base override
This patch allows us to override a git base to repository of a project
specified by OVERRIDE_${PROJECT}_GIT_BASE.
If specify OVERRIDE_DEVSTACK_GATE_GIT_BASE=https://github.com,
devstack-gate project will be accessed using https://github.com
as git base.
Change-Id: I7354f9957be2faec800d448473fdc743cb55a91e
This commit is contained in:
25
functions.sh
25
functions.sh
@@ -248,7 +248,7 @@ function git_remote_set_url {
|
||||
function git_clone_and_cd {
|
||||
local project=$1
|
||||
local short_project=$2
|
||||
local git_base=${GIT_BASE:-https://git.openstack.org}
|
||||
local git_base=$3
|
||||
|
||||
if [[ ! -e $short_project ]]; then
|
||||
echo " Need to clone $short_project"
|
||||
@@ -353,17 +353,17 @@ function fix_disk_layout {
|
||||
# The tip of the indicated branch
|
||||
# The tip of the master branch
|
||||
#
|
||||
# If you would like to use a particular git base for a project other than
|
||||
# GIT_BASE or https://git.openstack.org, for example in order to use
|
||||
# a particular repositories for a third party CI, then supply that using
|
||||
# variable OVERRIDE_${PROJECT}_GIT_BASE instead.
|
||||
# (e.g. OVERRIDE_TEMPEST_GIT_BASE=http://example.com)
|
||||
#
|
||||
function setup_project {
|
||||
local project=$1
|
||||
local branch=$2
|
||||
local short_project=`basename $project`
|
||||
local git_base=${GIT_BASE:-https://git.openstack.org}
|
||||
|
||||
echo "Setting up $project @ $branch"
|
||||
git_clone_and_cd $project $short_project
|
||||
|
||||
git_remote_set_url origin $git_base/$project
|
||||
|
||||
# allow for possible project branch override
|
||||
local uc_project=`echo $short_project | tr [:lower:] [:upper:] | tr '-' '_' | sed 's/[^A-Z_]//'`
|
||||
local project_branch_var="\$OVERRIDE_${uc_project}_PROJECT_BRANCH"
|
||||
@@ -371,6 +371,17 @@ function setup_project {
|
||||
if [[ "$project_branch" != "" ]]; then
|
||||
branch=$project_branch
|
||||
fi
|
||||
# allow for possible git_base override
|
||||
local project_git_base_var="\$OVERRIDE_${uc_project}_GIT_BASE"
|
||||
local project_git_base=`eval echo ${project_git_base_var}`
|
||||
if [[ "$project_git_base" != "" ]]; then
|
||||
git_base=$project_git_base
|
||||
fi
|
||||
|
||||
echo "Setting up $project @ $branch"
|
||||
git_clone_and_cd $project $short_project $git_base
|
||||
|
||||
git_remote_set_url origin $git_base/$project
|
||||
|
||||
# Try the specified branch before the ZUUL_BRANCH.
|
||||
if [[ ! -z $ZUUL_BRANCH ]]; then
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
source functions.sh
|
||||
|
||||
SUDO=""
|
||||
LOCAL_AAR_VARS="TEST_GIT_CHECKOUTS TEST_ZUUL_REFS GIT_CLONE_AND_CD_ARG"
|
||||
|
||||
# Mock out the checkout function since the refs we're checking out do
|
||||
# not exist.
|
||||
@@ -86,6 +87,12 @@ function git_remote_set_url {
|
||||
}
|
||||
|
||||
function git_clone_and_cd {
|
||||
if [[ "x${2}" == "x" ]]; then
|
||||
GIT_CLONE_AND_CD_ARG["ERROR"]="ERROR"
|
||||
return 1
|
||||
else
|
||||
GIT_CLONE_AND_CD_ARG[$2]="$1,$3"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -114,8 +121,9 @@ function assert_raises {
|
||||
# Tests follow:
|
||||
function test_one_on_master {
|
||||
# devstack-gate master ZA
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_PROJECT='openstack-infra/devstack-gate'
|
||||
local ZUUL_BRANCH='master'
|
||||
local ZUUL_REF='refs/zuul/master/ZA'
|
||||
@@ -129,8 +137,9 @@ function test_one_on_master {
|
||||
function test_two_on_master {
|
||||
# devstack-gate master ZA
|
||||
# glance master ZB
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_PROJECT='openstack/glance'
|
||||
local ZUUL_BRANCH='master'
|
||||
local ZUUL_REF='refs/zuul/master/ZB'
|
||||
@@ -149,8 +158,9 @@ function test_multi_branch_on_master {
|
||||
# devstack-gate master ZA
|
||||
# glance stable/havana ZB
|
||||
# python-glanceclient master ZC
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_PROJECT='openstack/python-glanceclient'
|
||||
local ZUUL_BRANCH='master'
|
||||
local ZUUL_REF='refs/zuul/master/ZC'
|
||||
@@ -179,8 +189,9 @@ function test_multi_branch_project_override {
|
||||
# tempest not in queue (override to master)
|
||||
# oslo.config not in queue (master because no stable/havana branch)
|
||||
# nova not in queue (stable/havana)
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_PROJECT='openstack/glance'
|
||||
local ZUUL_BRANCH='stable/havana'
|
||||
local OVERRIDE_TEMPEST_PROJECT_BRANCH='master'
|
||||
@@ -212,8 +223,9 @@ function test_multi_branch_on_stable {
|
||||
# devstack-gate master ZA
|
||||
# glance stable/havana ZB
|
||||
# python-glanceclient not in queue
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_PROJECT='openstack/glance'
|
||||
local ZUUL_BRANCH='stable/havana'
|
||||
local ZUUL_REF='refs/zuul/stable/havana/ZB'
|
||||
@@ -230,6 +242,36 @@ function test_multi_branch_on_stable {
|
||||
assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master'
|
||||
}
|
||||
|
||||
function test_multi_git_base_project_override {
|
||||
# osrg/ryu https://github.com
|
||||
# test/devstack-gate https://example.com
|
||||
# openstack/keystone https://git.openstack.org
|
||||
# openstack/glance http://tarballs.openstack.org
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
GIT_CLONE_AND_CD_ARG["ERROR"]="NULL"
|
||||
local ZUUL_PROJECT='openstack/neutron'
|
||||
local ZUUL_BRANCH='master'
|
||||
local ZUUL_REF='refs/zuul/master/ZA'
|
||||
local GIT_BASE=""
|
||||
local GIT_BASE_DEF="https://git.openstack.org"
|
||||
|
||||
local OVERRIDE_RYU_GIT_BASE='https://github.com'
|
||||
setup_project "osrg/ryu" $ZUUL_BRANCH
|
||||
local OVERRIDE_DEVSTACK_GATE_GIT_BASE='https://example.com'
|
||||
setup_project "test/devstack-gate" $ZUUL_BRANCH
|
||||
setup_project "openstack/keystone" $ZUUL_BRANCH
|
||||
local GIT_BASE="http://tarballs.openstack.org"
|
||||
setup_project "openstack/glance" $ZUUL_BRANCH
|
||||
|
||||
assert_equal "${GIT_CLONE_AND_CD_ARG["ryu"]}" "osrg/ryu,$OVERRIDE_RYU_GIT_BASE"
|
||||
assert_equal "${GIT_CLONE_AND_CD_ARG["devstack-gate"]}" "test/devstack-gate,$OVERRIDE_DEVSTACK_GATE_GIT_BASE"
|
||||
assert_equal "${GIT_CLONE_AND_CD_ARG["keystone"]}" "openstack/keystone,$GIT_BASE_DEF"
|
||||
assert_equal "${GIT_CLONE_AND_CD_ARG["glance"]}" "openstack/glance,$GIT_BASE"
|
||||
assert_equal "${GIT_CLONE_AND_CD_ARG["ERROR"]}" "NULL"
|
||||
}
|
||||
|
||||
function test_grenade_backward {
|
||||
# devstack-gate master ZA
|
||||
# nova stable/havana ZB
|
||||
@@ -240,8 +282,9 @@ function test_grenade_backward {
|
||||
# python-glanceclient not in queue
|
||||
# havana -> master (with changes)
|
||||
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_PROJECT='openstack/glance'
|
||||
local ZUUL_BRANCH='master'
|
||||
local ZUUL_REF='refs/zuul/master/ZE'
|
||||
@@ -304,8 +347,9 @@ function test_grenade_forward {
|
||||
# python-glanceclient not in queue
|
||||
# havana (with changes) -> master
|
||||
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_PROJECT='openstack/glance'
|
||||
local ZUUL_BRANCH='stable/havana'
|
||||
local ZUUL_REF='refs/zuul/stable/havana/ZE'
|
||||
@@ -364,8 +408,9 @@ function test_branch_override {
|
||||
# swift not in queue
|
||||
# python-glanceclient not in queue
|
||||
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_PROJECT='openstack-infra/devstack-gate'
|
||||
local ZUUL_BRANCH='master'
|
||||
local ZUUL_REF='refs/zuul/master/ZB'
|
||||
@@ -388,8 +433,9 @@ function test_branch_override {
|
||||
function test_periodic {
|
||||
# No queue
|
||||
|
||||
declare -A TEST_GIT_CHECKOUTS
|
||||
declare -A TEST_ZUUL_REFS
|
||||
for aar_var in $LOCAL_AAR_VARS; do
|
||||
eval `echo "declare -A $aar_var"`
|
||||
done
|
||||
local ZUUL_BRANCH='stable/havana'
|
||||
local ZUUL_PROJECT='openstack/glance'
|
||||
|
||||
@@ -477,6 +523,7 @@ test_grenade_forward
|
||||
test_multi_branch_on_master
|
||||
test_multi_branch_on_stable
|
||||
test_multi_branch_project_override
|
||||
test_multi_git_base_project_override
|
||||
test_one_on_master
|
||||
test_periodic
|
||||
test_periodic_no_branch
|
||||
|
||||
Reference in New Issue
Block a user