From: Norbert Bizet Date: Fri, 4 Sep 2020 11:35:14 +0000 (+0200) Subject: BEE Backport regress/scripts/cleanup X-Git-Tag: Release-11.3.2~1098 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd4faec2817f214bf3d6fe9507a59dd18d547455;p=thirdparty%2Fbacula.git BEE Backport regress/scripts/cleanup This commit is the result of the squash of the following main commits: Author: Norbert Bizet Date: Fri Mar 22 15:23:16 2019 +0100 cloud: fix bcloud cleanup Author: Norbert Bizet Date: Mon Jan 7 15:03:34 2019 +0100 Update regress tests for further swift support. Author: Norbert Bizet Date: Fri Nov 16 15:33:09 2018 +0100 regress: Add multi cloud test Author: Norbert Bizet Date: Thu Sep 6 11:18:48 2018 +0200 cloud: add plugin path to bcloud call. Author: Norbert Bizet Date: Sat Aug 4 12:55:01 2018 +0200 regress: Add generic cloud driver to cleanup script Author: Norbert Bizet Date: Thu Jul 26 13:55:19 2018 +0200 cloud: bcloud driver_command handling, based on cloud type Author: Norbert Bizet Date: Wed Aug 30 17:38:13 2017 +0200 improve bcloud for regress tests clean. --- diff --git a/regress/scripts/cleanup b/regress/scripts/cleanup index b41e35e62..6cc332a16 100755 --- a/regress/scripts/cleanup +++ b/regress/scripts/cleanup @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/bash # -# Copyright (C) 2000-2016 Kern Sibbald +# Copyright (C) 2000-2020 Kern Sibbald # License: BSD 2-Clause; see file LICENSE-FOSS # # Cleanup left over files -- both before and after test run @@ -49,59 +49,95 @@ fi # Remove cloud test volumes if [ x$FORCE_CLOUD = xyes ]; then - drv=`echo $CLOUD_DRIVER | tr 'A-Z' 'a-z'` - if [ "${drv}" = s3 -o "${drv}" = fakes3 ]; then - if [ x${CLOUD_HOSTNAME} != x ]; then - if [ x${CLOUD_PROTOCOL} = xHTTPS ]; then - endpoint="" - else - endpoint="--endpoint-url=http://${CLOUD_HOSTNAME}" - fi - fi - if [ x${CLOUD_REGION} != x ]; then - region="--region ${CLOUD_REGION}" - else - region="" - fi - aws configure set default.s3.signature_version s3v4 - aws s3 rm s3://${CLOUD_BUCKETNAME} $endpoint --recursive --include 'TestVol*' --include 'Vol*' $region 2>/dev/null >/dev/null + + # update cloud before cleanup so we can retrieve accurate information + update_cloud + + args="" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'HostName')") + if [ "${cloud_attr}" ]; then + args="${args} -h ${cloud_attr}" + fi + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'BucketName')") + if [ "${cloud_attr}" ]; then + args="${args} -n ${cloud_attr}" + fi + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'AccessKey')") + if [ "${cloud_attr}" ]; then + args="${args} -a ${cloud_attr}" fi - if [ x${CLOUD_BUCKETNAME} != x ]; then - args="${args} -n ${CLOUD_BUCKETNAME}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'SecretKey')") + if [ "${cloud_attr}" ]; then + args="${args} -s ${cloud_attr}" fi - if [ x${CLOUD_ACCESSKEY} != x ]; then - args="${args} -a ${CLOUD_ACCESSKEY}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'Protocol')") + if [ "${cloud_attr}" ]; then + args="${args} -p ${cloud_attr}" fi - if [ x${CLOUD_SECRETKEY} != x ]; then - args="${args} -s ${CLOUD_SECRETKEY}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'Region')") + if [ "${cloud_attr}" ]; then + args="${args} -r ${cloud_attr}" fi - if [ x${CLOUD_PROTOCOL} != x ]; then - args="${args} -p ${CLOUD_PROTOCOL}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'Driver')") + if [ "${cloud_attr}" ]; then + args="${args} -y ${cloud_attr}" + + shopt -s nocasematch + case "${cloud_attr}" in + "google") + args="${args} -c ${cwd}/bin/plugins/google_cloud_driver" + ;; + "oracle") + args="${args} -c ${cwd}/bin/plugins/oracle_cloud_driver" + ;; + "swift") + args="${args} -c ${cwd}/bin/plugins/swift_cloud_driver" + ;; + "generic") + args="${args} -c ${cwd}/bin/plugins/generic_cloud_driver" + ;; + "azure") + args="${args} -c ${cwd}/bin/plugins/was_cloud_driver" + ;; + *) + ;; + esac fi - if [ x${CLOUD_REGION} != x ]; then - args="${args} -r ${CLOUD_REGION}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'UriStyle')") + if [ "${cloud_attr}" ]; then + args="${args} -u ${cloud_attr}" fi - if [ x${CLOUD_DRIVER} != x ]; then - args="${args} -y ${CLOUD_DRIVER}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'BlobEndpoint')") + if [ "${cloud_attr}" ]; then + args="${args} -b ${cloud_attr}" fi - if [ x${CLOUD_URISTYLE} != x ]; then - args="${args} -u ${CLOUD_URISTYLE}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'TableEndpoint')") + if [ "${cloud_attr}" ]; then + args="${args} -t ${cloud_attr}" fi - if [ x${CLOUD_BLOBENDPOINT} != x ]; then - args="${args} -b ${CLOUD_BLOBENDPOINT}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'QueueEndpoint')") + if [ "${cloud_attr}" ]; then + args="${args} -q ${cloud_attr}" fi - if [ x${CLOUD_TABLEENDPOINT} != x ]; then - args="${args} -t ${CLOUD_TABLEENDPOINT}" + cloud_attr=$($bperl -e "get_attribute('$conf/bacula-sd.conf', 'Cloud', '$CLOUD_NAME', 'DriverCommand')") + if [ "${cloud_attr}" ]; then + args="${args} -c ${cloud_attr}" fi - if [ x${CLOUD_QUEUEENDPOINT} != x ]; then - args="${args} -q ${CLOUD_QUEUEENDPOINT}" + args="${args} -l ${cwd}/bin/plugins/" + + if [ -d ${bin} ] ; then + if [ -f ${bin}/bcloud ] ; then + ${bin}/bcloud ${args} -v 'Vol' clean + ${bin}/bcloud ${args} -v 'vol' clean + ${bin}/bcloud ${args} -v 'TestVol' clean + ${bin}/bcloud ${args} -v 'Small' clean + ${bin}/bcloud ${args} -v 'TEST' clean + ${bin}/bcloud ${args} -v 'Backup-' clean + fi fi - #${bin}/bcloud ${args} -v 'Vol' clean - #${bin}/bcloud ${args} -v 'vol' clean - #${bin}/bcloud ${args} -v 'TestVol' clean - #${bin}/bcloud ${args} -v 'Small' clean - #${bin}/bcloud ${args} -v 'TEST' clean - #${bin}/bcloud ${args} -v 'Backup-' clean + + # try to shutdown emulators + # Might report incorrect error if not setup correctly true fi