diff --git a/tools/hooks/README b/tools/hooks/README new file mode 100644 index 000000000..edde18cb1 --- /dev/null +++ b/tools/hooks/README @@ -0,0 +1,4 @@ +These are hooks to be used by the OpenStack infra test system. These scripts +may be called by certain jobs at important times to do extra testing, setup, +etc. They are really only relevant within the scope of the OpenStack infra +system and are not expected to be useful to anyone else. \ No newline at end of file diff --git a/tools/hooks/run_multi_backend_matrix.sh b/tools/hooks/run_multi_backend_matrix.sh new file mode 100755 index 000000000..af83e2c07 --- /dev/null +++ b/tools/hooks/run_multi_backend_matrix.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# Copyright (c) 2016, Hitachi, Erlon Cruz +# All Rights Reserved. +# +# 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. + +set -x +export TEMPEST_USER=${TEMPEST_USER:-tempest} +chmod +w $BASE/new/tempest +cd $BASE/new/tempest +source $BASE/new/devstack/functions +source $BASE/new/devstack/functions-common +source $WORKSPACE/devstack-gate/functions.sh +source $BASE/new/cinder/tools/hooks/utils.sh +export TEMPEST_CONFIG=$BASE/new/tempest/etc/tempest.conf + +# Disable bash verbose so we have a cleaner output. Also, exit on error must +# be disable as we will run several tests that can return error. +set +x +e + +function configure_tempest_backends { + be1=$1 + be2=$2 + echo "Configuring tempest conf in ${TEMPEST_CONFIG}" + # TODO(erlon): Call iniset using sudo + #sudo -HE -u ${TEMPEST_USER} iniset $TEMPEST_CONFIG 'volume' \ + #'backend_names' ${be1},${be2} + iniset $TEMPEST_CONFIG 'volume' 'backend_names' ${be1},${be2} + +} + +BACKENDS='lvm ceph nfs' +# NOTE(erlon): Skipping test_volume_migrate_attached while bug #1644214 is not +# fixed. +RGEX="(.*test_volume_retype_with_migration.*)" +final_result=0 +final_message='Migrations tests finished SUCCESSFULLY!' +declare -A TEST_RESULTS +start_time=`date +%s` +for be1 in ${BACKENDS}; do + for be2 in ${BACKENDS}; do + if [ ${be1} != ${be2} ]; then + configure_tempest_backends ${be1} ${be2} + echo "============================================================" + echo "Testing multibackend features: ${be1} vs ${be2}" + echo "============================================================" + run_tempest "${be1} vs ${be2}" ${RGEX} + result=$? + # If any of the test fail, we keep running but return failure as + # the final result + if [ ${result} -ne 0 ]; then + TEST_RESULTS[${be1},${be2}]="FAILURE" + final_message='Migrations tests FAILED!' + final_result=1 + else + TEST_RESULTS[${be1},${be2}]="SUCCESS" + fi + fi + done +done +end_time=`date +%s` +elapsed=$(expr $(expr ${end_time} - ${start_time}) / 60) + +# Print the results +num_rows=$(echo $BACKENDS | wc -w) +fmt=" %15s" +echo "============================================================" +echo " ${final_message} In ${elapsed} minutes." +echo "============================================================" + +printf "$fmt" '' +for be1 in ${BACKENDS}; do + printf "$fmt" ${be1} +done +echo +for be1 in ${BACKENDS}; do + printf "$fmt" ${be1} + for be2 in ${BACKENDS}; do + if [ ${be1} == ${be2} ]; then + printf "$fmt" '---' + else + printf "$fmt" ${TEST_RESULTS[${be1},${be2}]} + fi + done + echo +done + +exit ${final_result} diff --git a/tools/hooks/utils.sh b/tools/hooks/utils.sh new file mode 100755 index 000000000..ab42e0e78 --- /dev/null +++ b/tools/hooks/utils.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +function run_tempest { + local message=$1 + local tempest_regex=$2 + sudo -H -u ${TEMPEST_USER} tox -eall -- $tempest_regex \ + --concurrency=${TEMPEST_CONCURRENCY} + exitcode=$? + return ${exitcode} +}