From aecd189f80533b2680184d648f393bd0f5479882 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 19 Nov 2014 15:19:51 -0500 Subject: [PATCH] add unit tests for GIT* definitions This adds unit tests for all the GIT* definitions, ensuring that for libraries we think should be defined, they are. It exposed a bug in glance_store definitions in the process. The GITDIR definition for python-openstackclient is moved to stackrc for testability. Change-Id: Ibd9ab665f0362a84f4f7e80e80da56a4737f584e --- lib/glance | 2 +- stack.sh | 3 -- stackrc | 2 + tests/test_libs_from_pypi.sh | 96 ++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100755 tests/test_libs_from_pypi.sh diff --git a/lib/glance b/lib/glance index 04c088aa6d..0c1045fd12 100644 --- a/lib/glance +++ b/lib/glance @@ -28,7 +28,7 @@ set +o xtrace # Set up default directories GITDIR["python-glanceclient"]=$DEST/python-glanceclient -GIRDIR["glance_store"]=$DEST/glance_store +GITDIR["glance_store"]=$DEST/glance_store GLANCE_DIR=$DEST/glance GLANCE_CACHE_DIR=${GLANCE_CACHE_DIR:=$DATA_DIR/glance/cache} diff --git a/stack.sh b/stack.sh index 93e4541990..24bda01782 100755 --- a/stack.sh +++ b/stack.sh @@ -575,9 +575,6 @@ if [[ -d $TOP_DIR/extras.d ]]; then done fi -# Set the destination directories for other OpenStack projects -GITDIR["python-openstackclient"]=$DEST/python-openstackclient - # Interactive Configuration # ------------------------- diff --git a/stackrc b/stackrc index e0e886d22c..5c5acb137c 100644 --- a/stackrc +++ b/stackrc @@ -273,6 +273,8 @@ GITBRANCH["python-troveclient"]=${TROVECLIENT_BRANCH:-master} # consolidated openstack python client GITREPO["python-openstackclient"]=${OPENSTACKCLIENT_REPO:-${GIT_BASE}/openstack/python-openstackclient.git} GITBRANCH["python-openstackclient"]=${OPENSTACKCLIENT_BRANCH:-master} +# this doesn't exist in a lib file, so set it here +GITDIR["python-openstackclient"]=$DEST/python-openstackclient ################### # diff --git a/tests/test_libs_from_pypi.sh b/tests/test_libs_from_pypi.sh new file mode 100755 index 0000000000..1b576d87c2 --- /dev/null +++ b/tests/test_libs_from_pypi.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +TOP=$(cd $(dirname "$0")/.. && pwd) + +export TOP_DIR=$TOP + +# Import common functions +source $TOP/functions +source $TOP/stackrc +source $TOP/lib/tls +for i in $TOP/lib/*; do + if [[ -f $i ]]; then + source $i + fi +done + +ALL_LIBS="python-novaclient oslo.config pbr oslo.context python-troveclient python-keystoneclient taskflow oslo.middleware pycadf python-glanceclient python-ironicclient tempest-lib oslo.messaging oslo.log cliff python-heatclient stevedore python-cinderclient glance_store oslo.concurrency oslo.db oslo.vmware keystonemiddleware oslo.serialization python-saharaclient django_openstack_auth python-openstackclient oslo.rootwrap oslo.i18n python-ceilometerclient oslo.utils python-swiftclient python-neutronclient" + +# Generate the above list with +# echo ${!GITREPO[@]} + +function check_exists { + local thing=$1 + local hash=$2 + local key=$3 + if [[ ! -z "$VERBOSE" ]]; then + echo "Checking for $hash[$key]" + fi + if [[ -z $thing ]]; then + echo "$hash[$key] does not exit!" + exit 1 + else + if [[ ! -z "$VERBOSE" ]]; then + echo "$hash[$key] => $thing" + fi + fi +} + +function test_all_libs_upto_date { + # this is all the magics + local found_libs=${!GITREPO[@]} + declare -A all_libs + for lib in $ALL_LIBS; do + all_libs[$lib]=1 + done + + for lib in $found_libs; do + if [[ -z ${all_libs[$lib]} ]]; then + echo "Library '$lib' not listed in unit tests, please add to ALL_LIBS" + exit 1 + fi + + done + echo "test_all_libs_upto_date PASSED" +} + +function test_libs_exist { + local lib="" + for lib in $ALL_LIBS; do + check_exists "${GITREPO[$lib]}" "GITREPO" "$lib" + check_exists "${GITBRANCH[$lib]}" "GITBRANCH" "$lib" + check_exists "${GITDIR[$lib]}" "GITDIR" "$lib" + done + + echo "test_libs_exist PASSED" +} + +function test_branch_master { + for lib in $ALL_LIBS; do + if [[ ${GITBRANCH[$lib]} != "master" ]]; then + echo "GITBRANCH for $lib not master (${GITBRANCH[$lib]})" + exit 1 + fi + done + + echo "test_branch_master PASSED" +} + +set -o errexit + +test_libs_exist +test_branch_master +test_all_libs_upto_date