From 6287ca6c9f787efa3404624f11c45e22a6957393 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 2 Apr 2014 14:17:31 -0400 Subject: [PATCH] allow for generic branch overrides This allows us to specify project specific branch overrides in jjb definitions. For instance, OVERRIDE_TEMPEST_PROJECT_BRANCH=master to always test with tempest master. Now with support for projects like oslo.foo Change-Id: Ic259c5b60a307b87771514849a6a78eb1bc32c75 --- functions.sh | 10 ++++++++++ test-functions.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/functions.sh b/functions.sh index e37a873e..1559c4ad 100644 --- a/functions.sh +++ b/functions.sh @@ -187,8 +187,10 @@ function fix_disk_layout { # compatibility, then supply that as the argument instead. This # function will try to check out the following (in order): # +# The zuul ref for the project specific OVERRIDE_$PROJECT_PROJECT_BRANCH if specified # The zuul ref for the indicated branch # The zuul ref for the master branch +# The tip of the project specific OVERRIDE_$PROJECT_PROJECT_BRANCH if specified # The tip of the indicated branch # The tip of the master branch # @@ -202,6 +204,14 @@ function setup_project { git_remote_set_url origin https://git.openstack.org/$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" + local project_branch=`eval echo ${project_branch_var}` + if [[ "$project_branch" != "" ]]; then + branch=$project_branch + fi + # Try the specified branch before the ZUUL_BRANCH. OVERRIDE_ZUUL_REF=$(echo $ZUUL_REF | sed -e "s,$ZUUL_BRANCH,$branch,") diff --git a/test-functions.sh b/test-functions.sh index 9d18b866..8b2445e5 100755 --- a/test-functions.sh +++ b/test-functions.sh @@ -65,6 +65,7 @@ function git_has_branch { openstack/swift) return 0 ;; openstack/nova) return 0 ;; openstack/keystone) return 0 ;; + opestnack/tempest) return 0 ;; esac esac return 1 @@ -159,6 +160,46 @@ function test_multi_branch_on_master { assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'refs/zuul/master/ZC' $LINENO } +function test_multi_branch_project_override { + # main branch is stable/havana + # devstack-gate master ZA + # devstack-gate master ZB + # python-glanceclient master ZC + # glance stable/havana ZD + # tempest not in queue (override to master) + # oslo.config not in queue (master because no stable/havana branch) + # nova not in queue (stable/havana) + echo "== Test multi branch project override" + + declare -A TEST_GIT_CHECKOUTS + declare -A TEST_ZUUL_REFS + ZUUL_PROJECT='openstack/glance' + ZUUL_BRANCH='stable/havana' + local OVERRIDE_TEMPEST_PROJECT_BRANCH='master' + ZUUL_REF='refs/zuul/stable/havana/ZD' + 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/ZC' + TEST_ZUUL_REFS[devstack-gate]+=' refs/zuul/master/ZD' + TEST_ZUUL_REFS[python-glanceclient]+=' refs/zuul/master/ZC' + TEST_ZUUL_REFS[python-glanceclient]+=' refs/zuul/master/ZD' + TEST_ZUUL_REFS[glance]+=' refs/zuul/stable/havana/ZD' + + setup_project openstack-infra/devstack-gate $ZUUL_BRANCH + setup_project openstack/glance $ZUUL_BRANCH + setup_project openstack/python-glanceclient $ZUUL_BRANCH + setup_project openstack/tempest $ZUUL_BRANCH + setup_project openstack/nova $ZUUL_BRANCH + setup_project openstack/oslo.config $ZUUL_BRANCH + + assert_equal "${TEST_GIT_CHECKOUTS[devstack-gate]}" 'refs/zuul/master/ZD' $LINENO + assert_equal "${TEST_GIT_CHECKOUTS[glance]}" 'refs/zuul/stable/havana/ZD' $LINENO + assert_equal "${TEST_GIT_CHECKOUTS[tempest]}" 'master' $LINENO + assert_equal "${TEST_GIT_CHECKOUTS[nova]}" 'stable/havana' $LINENO + assert_equal "${TEST_GIT_CHECKOUTS[oslo.config]}" 'master' $LINENO + assert_equal "${TEST_GIT_CHECKOUTS[python-glanceclient]}" 'refs/zuul/master/ZD' $LINENO +} + function test_multi_branch_on_stable { # devstack-gate master ZA # glance stable/havana ZB @@ -360,6 +401,7 @@ function test_periodic { test_two_on_master test_one_on_master test_multi_branch_on_master +test_multi_branch_project_override test_multi_branch_on_stable test_grenade_backward test_grenade_forward