Skip to content

Commit 94964b4

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Allow for git base override"
2 parents 43a9630 + e4ca0a1 commit 94964b4

File tree

2 files changed

+83
-25
lines changed

2 files changed

+83
-25
lines changed

functions.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function git_remote_set_url {
292292
function git_clone_and_cd {
293293
local project=$1
294294
local short_project=$2
295-
local git_base=${GIT_BASE:-https://git.openstack.org}
295+
local git_base=$3
296296

297297
if [[ ! -e $short_project ]]; then
298298
echo " Need to clone $short_project"
@@ -407,24 +407,35 @@ function fix_disk_layout {
407407
# The tip of the indicated branch
408408
# The tip of the master branch
409409
#
410+
# If you would like to use a particular git base for a project other than
411+
# GIT_BASE or https://git.openstack.org, for example in order to use
412+
# a particular repositories for a third party CI, then supply that using
413+
# variable OVERRIDE_${PROJECT}_GIT_BASE instead.
414+
# (e.g. OVERRIDE_TEMPEST_GIT_BASE=http://example.com)
415+
#
410416
function setup_project {
411417
local project=$1
412418
local branch=$2
413419
local short_project=`basename $project`
414420
local git_base=${GIT_BASE:-https://git.openstack.org}
415-
416-
echo "Setting up $project @ $branch"
417-
git_clone_and_cd $project $short_project
418-
419-
git_remote_set_url origin $git_base/$project
420-
421421
# allow for possible project branch override
422422
local uc_project=`echo $short_project | tr [:lower:] [:upper:] | tr '-' '_' | sed 's/[^A-Z_]//'`
423423
local project_branch_var="\$OVERRIDE_${uc_project}_PROJECT_BRANCH"
424424
local project_branch=`eval echo ${project_branch_var}`
425425
if [[ "$project_branch" != "" ]]; then
426426
branch=$project_branch
427427
fi
428+
# allow for possible git_base override
429+
local project_git_base_var="\$OVERRIDE_${uc_project}_GIT_BASE"
430+
local project_git_base=`eval echo ${project_git_base_var}`
431+
if [[ "$project_git_base" != "" ]]; then
432+
git_base=$project_git_base
433+
fi
434+
435+
echo "Setting up $project @ $branch"
436+
git_clone_and_cd $project $short_project $git_base
437+
438+
git_remote_set_url origin $git_base/$project
428439

429440
# Try the specified branch before the ZUUL_BRANCH.
430441
if [[ ! -z $ZUUL_BRANCH ]]; then

test-functions.sh

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
source functions.sh
2222

2323
SUDO=""
24+
LOCAL_AAR_VARS="TEST_GIT_CHECKOUTS TEST_ZUUL_REFS GIT_CLONE_AND_CD_ARG"
2425

2526
# Mock out the checkout function since the refs we're checking out do
2627
# not exist.
@@ -86,6 +87,12 @@ function git_remote_set_url {
8687
}
8788

8889
function git_clone_and_cd {
90+
if [[ "x${2}" == "x" ]]; then
91+
GIT_CLONE_AND_CD_ARG["ERROR"]="ERROR"
92+
return 1
93+
else
94+
GIT_CLONE_AND_CD_ARG[$2]="$1,$3"
95+
fi
8996
return 0
9097
}
9198

@@ -114,8 +121,9 @@ function assert_raises {
114121
# Tests follow:
115122
function test_one_on_master {
116123
# devstack-gate master ZA
117-
declare -A TEST_GIT_CHECKOUTS
118-
declare -A TEST_ZUUL_REFS
124+
for aar_var in $LOCAL_AAR_VARS; do
125+
eval `echo "declare -A $aar_var"`
126+
done
119127
local ZUUL_PROJECT='openstack-infra/devstack-gate'
120128
local ZUUL_BRANCH='master'
121129
local ZUUL_REF='refs/zuul/master/ZA'
@@ -129,8 +137,9 @@ function test_one_on_master {
129137
function test_two_on_master {
130138
# devstack-gate master ZA
131139
# glance master ZB
132-
declare -A TEST_GIT_CHECKOUTS
133-
declare -A TEST_ZUUL_REFS
140+
for aar_var in $LOCAL_AAR_VARS; do
141+
eval `echo "declare -A $aar_var"`
142+
done
134143
local ZUUL_PROJECT='openstack/glance'
135144
local ZUUL_BRANCH='master'
136145
local ZUUL_REF='refs/zuul/master/ZB'
@@ -149,8 +158,9 @@ function test_multi_branch_on_master {
149158
# devstack-gate master ZA
150159
# glance stable/havana ZB
151160
# python-glanceclient master ZC
152-
declare -A TEST_GIT_CHECKOUTS
153-
declare -A TEST_ZUUL_REFS
161+
for aar_var in $LOCAL_AAR_VARS; do
162+
eval `echo "declare -A $aar_var"`
163+
done
154164
local ZUUL_PROJECT='openstack/python-glanceclient'
155165
local ZUUL_BRANCH='master'
156166
local ZUUL_REF='refs/zuul/master/ZC'
@@ -179,8 +189,9 @@ function test_multi_branch_project_override {
179189
# tempest not in queue (override to master)
180190
# oslo.config not in queue (master because no stable/havana branch)
181191
# nova not in queue (stable/havana)
182-
declare -A TEST_GIT_CHECKOUTS
183-
declare -A TEST_ZUUL_REFS
192+
for aar_var in $LOCAL_AAR_VARS; do
193+
eval `echo "declare -A $aar_var"`
194+
done
184195
local ZUUL_PROJECT='openstack/glance'
185196
local ZUUL_BRANCH='stable/havana'
186197
local OVERRIDE_TEMPEST_PROJECT_BRANCH='master'
@@ -212,8 +223,9 @@ function test_multi_branch_on_stable {
212223
# devstack-gate master ZA
213224
# glance stable/havana ZB
214225
# python-glanceclient not in queue
215-
declare -A TEST_GIT_CHECKOUTS
216-
declare -A TEST_ZUUL_REFS
226+
for aar_var in $LOCAL_AAR_VARS; do
227+
eval `echo "declare -A $aar_var"`
228+
done
217229
local ZUUL_PROJECT='openstack/glance'
218230
local ZUUL_BRANCH='stable/havana'
219231
local ZUUL_REF='refs/zuul/stable/havana/ZB'
@@ -230,6 +242,36 @@ function test_multi_branch_on_stable {
230242
assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'master'
231243
}
232244

245+
function test_multi_git_base_project_override {
246+
# osrg/ryu https://github.com
247+
# test/devstack-gate https://example.com
248+
# openstack/keystone https://git.openstack.org
249+
# openstack/glance http://tarballs.openstack.org
250+
for aar_var in $LOCAL_AAR_VARS; do
251+
eval `echo "declare -A $aar_var"`
252+
done
253+
GIT_CLONE_AND_CD_ARG["ERROR"]="NULL"
254+
local ZUUL_PROJECT='openstack/neutron'
255+
local ZUUL_BRANCH='master'
256+
local ZUUL_REF='refs/zuul/master/ZA'
257+
local GIT_BASE=""
258+
local GIT_BASE_DEF="https://git.openstack.org"
259+
260+
local OVERRIDE_RYU_GIT_BASE='https://github.com'
261+
setup_project "osrg/ryu" $ZUUL_BRANCH
262+
local OVERRIDE_DEVSTACK_GATE_GIT_BASE='https://example.com'
263+
setup_project "test/devstack-gate" $ZUUL_BRANCH
264+
setup_project "openstack/keystone" $ZUUL_BRANCH
265+
local GIT_BASE="http://tarballs.openstack.org"
266+
setup_project "openstack/glance" $ZUUL_BRANCH
267+
268+
assert_equal "${GIT_CLONE_AND_CD_ARG["ryu"]}" "osrg/ryu,$OVERRIDE_RYU_GIT_BASE"
269+
assert_equal "${GIT_CLONE_AND_CD_ARG["devstack-gate"]}" "test/devstack-gate,$OVERRIDE_DEVSTACK_GATE_GIT_BASE"
270+
assert_equal "${GIT_CLONE_AND_CD_ARG["keystone"]}" "openstack/keystone,$GIT_BASE_DEF"
271+
assert_equal "${GIT_CLONE_AND_CD_ARG["glance"]}" "openstack/glance,$GIT_BASE"
272+
assert_equal "${GIT_CLONE_AND_CD_ARG["ERROR"]}" "NULL"
273+
}
274+
233275
function test_grenade_backward {
234276
# devstack-gate master ZA
235277
# nova stable/havana ZB
@@ -240,8 +282,9 @@ function test_grenade_backward {
240282
# python-glanceclient not in queue
241283
# havana -> master (with changes)
242284

243-
declare -A TEST_GIT_CHECKOUTS
244-
declare -A TEST_ZUUL_REFS
285+
for aar_var in $LOCAL_AAR_VARS; do
286+
eval `echo "declare -A $aar_var"`
287+
done
245288
local ZUUL_PROJECT='openstack/glance'
246289
local ZUUL_BRANCH='master'
247290
local ZUUL_REF='refs/zuul/master/ZE'
@@ -304,8 +347,9 @@ function test_grenade_forward {
304347
# python-glanceclient not in queue
305348
# havana (with changes) -> master
306349

307-
declare -A TEST_GIT_CHECKOUTS
308-
declare -A TEST_ZUUL_REFS
350+
for aar_var in $LOCAL_AAR_VARS; do
351+
eval `echo "declare -A $aar_var"`
352+
done
309353
local ZUUL_PROJECT='openstack/glance'
310354
local ZUUL_BRANCH='stable/havana'
311355
local ZUUL_REF='refs/zuul/stable/havana/ZE'
@@ -364,8 +408,9 @@ function test_branch_override {
364408
# swift not in queue
365409
# python-glanceclient not in queue
366410

367-
declare -A TEST_GIT_CHECKOUTS
368-
declare -A TEST_ZUUL_REFS
411+
for aar_var in $LOCAL_AAR_VARS; do
412+
eval `echo "declare -A $aar_var"`
413+
done
369414
local ZUUL_PROJECT='openstack-infra/devstack-gate'
370415
local ZUUL_BRANCH='master'
371416
local ZUUL_REF='refs/zuul/master/ZB'
@@ -388,8 +433,9 @@ function test_branch_override {
388433
function test_periodic {
389434
# No queue
390435

391-
declare -A TEST_GIT_CHECKOUTS
392-
declare -A TEST_ZUUL_REFS
436+
for aar_var in $LOCAL_AAR_VARS; do
437+
eval `echo "declare -A $aar_var"`
438+
done
393439
local ZUUL_BRANCH='stable/havana'
394440
local ZUUL_PROJECT='openstack/glance'
395441

@@ -477,6 +523,7 @@ test_grenade_forward
477523
test_multi_branch_on_master
478524
test_multi_branch_on_stable
479525
test_multi_branch_project_override
526+
test_multi_git_base_project_override
480527
test_one_on_master
481528
test_periodic
482529
test_periodic_no_branch

0 commit comments

Comments
 (0)