From 4f5a5962fa8e419bcdb8b3bfd2d2b473e280b4b8 Mon Sep 17 00:00:00 2001 From: "Erlon R. Cruz" Date: Tue, 27 Sep 2016 17:20:01 -0300 Subject: [PATCH] Gate migration tests: Add Cinder tempest hook This patch is part of the effort to add migration tests to OpenStack gate. It will rely in 2 tempest tests that are on the dependency list and that the gate job will configure the following backends: ceph nfs glusterfs lvm. Once running, the script will configure 2 tempest backends and run the migration tests on all possible combinations of the backend listed above. The output of the test run will be something like: ceph nfs ceph --- SUCCESS nfs SUCCESS --- If all tests in the matrix result in SUCCESS, then the test script returns. Otherwise, other value is returned and the job is marked as failed. Depends-on: I4ed9b1f30d4e4e595c44a0ce243c2463069833d7 Depends-on: Iff4d880a0f8e928cbc07b84ff0c357ad59ef929c Change-Id: I17b5cd9dafb3ad17e8721376ae1e6790bd93108c --- tools/hooks/README | 4 + tools/hooks/run_multi_backend_matrix.sh | 99 +++++++++++++++++++++++++ tools/hooks/utils.sh | 10 +++ 3 files changed, 113 insertions(+) create mode 100644 tools/hooks/README create mode 100755 tools/hooks/run_multi_backend_matrix.sh create mode 100755 tools/hooks/utils.sh 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} +}