From a7c77266e690087581b48d19f9dae9776537d27a Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 9 May 2009 13:50:33 +0000 Subject: [PATCH] First cut parameterize better regression tests git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8816 91ce42f0-d328-0410-95d8-f526ca767f89 --- regress/do_disk | 1 - regress/scripts/check_for_zombie_jobs | 28 ++++--- regress/scripts/functions | 104 ++++++++++++++------------ regress/tests/backup-bacula-test | 22 +++--- regress/tests/incremental-test | 78 +++++++++---------- 5 files changed, 119 insertions(+), 114 deletions(-) diff --git a/regress/do_disk b/regress/do_disk index 275e108119..9bb975f79b 100755 --- a/regress/do_disk +++ b/regress/do_disk @@ -1,5 +1,4 @@ #!/bin/sh -# /home/kern/bacula/bin/startmysql nice make setup echo " " >test.out cat build/config.out >>test.out diff --git a/regress/scripts/check_for_zombie_jobs b/regress/scripts/check_for_zombie_jobs index 62ba3bece6..69c25c1734 100755 --- a/regress/scripts/check_for_zombie_jobs +++ b/regress/scripts/check_for_zombie_jobs @@ -4,8 +4,6 @@ # Also scan logs for ERROR messages # -. ./config - # check_for_zombie_jobs storage=STORAGE [client=localhost-fd] if [ $# = 2 ] ; then @@ -14,19 +12,19 @@ else client=${HOST}-fd fi -$bin/bconsole -c bin/bconsole.conf <&1 >/dev/null -@output tmp/dir.out +${bin}/bconsole -c ${scripts}/bconsole.conf <&1 >/dev/null +@output ${tmp}/dir.out status dir -@output tmp/fd.out +@output ${tmp}/fd.out status client=${client} -@output tmp/sd.out +@output ${tmp}/sd.out status $1 @output quit END_OF_DATA export zstat -grep "No Jobs running." tmp/dir.out 2>&1 >/dev/null +grep "No Jobs running." ${tmp}/dir.out 2>&1 >/dev/null if [ $? != 0 ] ; then echo " " echo " !!!! Zombie Jobs in Director !!!!" @@ -35,7 +33,7 @@ if [ $? != 0 ] ; then zstat=1 exit 1 fi -grep "No Jobs running." tmp/fd.out 2>&1 >/dev/null +grep "No Jobs running." ${tmp}/fd.out 2>&1 >/dev/null if [ $? != 0 ] ; then echo " " echo " !!!! Zombie Jobs in File daemon !!!!" @@ -44,7 +42,7 @@ if [ $? != 0 ] ; then zstat=1 exit 1 fi -grep "No Jobs running." tmp/sd.out 2>&1 >/dev/null +grep "No Jobs running." ${tmp}/sd.out 2>&1 >/dev/null if [ $? != 0 ] ; then echo " " echo " !!!! Zombie Jobs in Storage daemon !!!!" @@ -53,33 +51,33 @@ if [ $? != 0 ] ; then zstat=1 exit 1 fi -grep "ERROR" tmp/log*.out 2>&1 >/dev/null +grep "ERROR" ${tmp}/log*.out 2>&1 >/dev/null if [ $? = 0 ] ; then echo " " echo " !!!! ERROR in log output !!!!" echo " !!!! ERROR in log output !!!!" >>test.out - grep "ERROR" tmp/log*.out + grep "ERROR" ${tmp}/log*.out echo " " zstat=1 exit 1 fi -grep "Fatal Error" tmp/log*.out 2>&1 >/dev/null +grep "Fatal Error" ${tmp}/log*.out 2>&1 >/dev/null if [ $? = 0 ] ; then echo " " echo " !!!! Fatal Error in log output !!!!" echo " !!!! Fatal Error in log output !!!!" >>test.out - grep "Fatal Error" tmp/log*.out + grep "Fatal Error" ${tmp}/log*.out echo " " zstat=1 exit 1 fi -grep "glibc detected" tmp/log*.out 2>&1 >/dev/null +grep "glibc detected" ${tmp}/log*.out 2>&1 >/dev/null if [ $? = 0 ] ; then echo " " echo " !!!! glibc detected Error in log output !!!!" echo " !!!! glibc detected Error in log output !!!!" >>test.out - grep "glibc detected" tmp/log*.out + grep "glibc detected" ${tmp}/log*.out echo " " zstat=1 exit 1 diff --git a/regress/scripts/functions b/regress/scripts/functions index a3cfe744c0..38033a99c7 100644 --- a/regress/scripts/functions +++ b/regress/scripts/functions @@ -5,7 +5,7 @@ check_encoding() { - $bin/bacula-dir -d50 -t -c bin/bacula-dir.conf 2>&1 | grep 'Wanted SQL_ASCII, got UTF8' >/dev/null + ${bin}/bacula-dir -d50 -t -c ${scripts}/bacula-dir.conf 2>&1 | grep 'Wanted SQL_ASCII, got UTF8' >/dev/null if [ $? = 0 ]; then echo "Found database encoding problem, please modify the database encoding (SQL_ASCII)" exit 1 @@ -16,11 +16,11 @@ start_test() { check_encoding # Turn off email - outf="tmp/sed_tmp" + outf="${tmp}/sed_tmp" echo "s% mail =%# mail = %g" >${outf} echo "s% operator =%# operator =%g" >>${outf} - cp bin/bacula-dir.conf tmp/1 - sed -f ${outf} tmp/1 > bin/bacula-dir.conf + cp ${scripts}/bacula-dir.conf ${tmp}/1 + sed -f ${outf} ${tmp}/1 > ${scripts}/bacula-dir.conf echo " " echo " " echo " === Starting $TestName at `date +%R:%S` ===" @@ -154,43 +154,43 @@ run_bacula() debug_wait zstat=0 if test "$debug" -eq 1 ; then - bin/bacula-ctl-sd start - bin/bacula-ctl-fd start $1 - bin/bacula-ctl-dir start - cat tmp/bconcmds | $bin/bconsole -c bin/bconsole.conf + ${scripts}/bacula-ctl-sd start + ${scripts}/bacula-ctl-fd start $1 + ${scripts}/bacula-ctl-dir start + cat ${tmp}/bconcmds | ${bin}/bconsole -c ${scripts}/bconsole.conf return $? else - bin/bacula start >/dev/null 2>&1 - cat tmp/bconcmds | $bin/bconsole -c bin/bconsole.conf >/dev/null 2>&1 + ${bin}/bacula start >/dev/null 2>&1 + cat ${tmp}/bconcmds | ${bin}/bconsole -c ${scripts}/bconsole.conf >/dev/null 2>&1 return $? fi } run_bconsole() { - bconsole_file=${1:-tmp/bconcmds} + bconsole_file=${1:-${tmp}/bconcmds} if test "$debug" -eq 1 ; then - cat $bconsole_file | $bin/bconsole -c bin/bconsole.conf + cat $bconsole_file | ${bin}/bconsole -c ${scripts}/bconsole.conf else - cat $bconsole_file | $bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null + cat $bconsole_file | ${bin}/bconsole -c ${scripts}/bconsole.conf 2>&1 >/dev/null fi } run_btape() { if test "$debug" -eq 1 ; then - cat tmp/bconcmds | $bin/btape -c bin/bacula-sd.conf DDS-4 | tee tmp/log1.out + cat ${tmp}/bconcmds | ${bin}/btape -c ${scripts}/bacula-sd.conf DDS-4 | tee ${tmp}/log1.out else - cat tmp/bconcmds | $bin/btape -c bin/bacula-sd.conf DDS-4 >tmp/log1.out 2>&1 + cat ${tmp}/bconcmds | ${bin}/btape -c ${scripts}/bacula-sd.conf DDS-4 >${tmp}/log1.out 2>&1 fi } run_bscan() { if test "$debug" -eq 1 ; then - $bin/bscan $* | tee tmp/log.out + ${bin}/bscan $* | tee ${tmp}/log.out else - $bin/bscan $* 2>&1 >/dev/null + ${bin}/bscan $* 2>&1 >/dev/null fi } @@ -212,7 +212,7 @@ bscan_libdbi() stop_bacula() { - bin/bacula stop 2>&1 >/dev/null + ${bin}/bacula stop 2>&1 >/dev/null zstat=0 bstat=0 rstat=0 @@ -221,7 +221,7 @@ stop_bacula() check_for_zombie_jobs() { - scripts/check_for_zombie_jobs $* + ${rscripts}/check_for_zombie_jobs $* } change_jobname() @@ -233,36 +233,36 @@ change_jobname() oldname=$1 newname=$2 fi - rm -f bin/1 - mv bin/bacula-dir.conf bin/1 - echo "s%${oldname}%${newname}%g" >tmp/1 - sed -f tmp/1 bin/1 >bin/bacula-dir.conf + rm -f ${bin}/1 + mv ${scripts}/bacula-dir.conf ${bin}/1 + echo "s%${oldname}%${newname}%g" >${tmp}/1 + sed -f ${tmp}/1 ${bin}/1 >${scripts}/bacula-dir.conf # echo "Job ${oldname} changed to ${newname}" } check_two_logs() { - grep "^ Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null + grep "^ Termination: *Backup OK" ${tmp}/log1.out 2>&1 >/dev/null bstat=${bstat:-$?} - grep "^ Termination: .*Backup Error" tmp/log1.out 2>&1 >/dev/null + grep "^ Termination: .*Backup Error" ${tmp}/log1.out 2>&1 >/dev/null if test $? -eq 0; then bstat=2 fi - grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null + grep "^ Termination: *Restore OK" ${tmp}/log2.out 2>&1 >/dev/null rstat=${rstat:-$?} - grep "^ Termination: .*Restore Error" tmp/log2.out 2>&1 >/dev/null + grep "^ Termination: .*Restore Error" ${tmp}/log2.out 2>&1 >/dev/null if test $? -eq 0; then rstat=2 fi - grep "^ Termination: *Restore OK -- warning file count mismatch" tmp/log2.out 2>&1 >/dev/null + grep "^ Termination: *Restore OK -- warning file count mismatch" ${tmp}/log2.out 2>&1 >/dev/null if test $? -eq 0; then rstat=3 fi - grep "^ Termination: .*Verify Differences" tmp/log2.out 2>&1 >/dev/null + grep "^ Termination: .*Verify Differences" ${tmp}/log2.out 2>&1 >/dev/null if test $? -eq 0; then rstat=4 fi - grep "Encoding error for database" tmp/log1.out > /dev/null + grep "Encoding error for database" ${tmp}/log1.out > /dev/null if test $? -eq 0; then print_debug "Found database encoding error" bstat=2 @@ -272,9 +272,9 @@ check_two_logs() check_restore_diff() { if test "$debug" -eq 1 ; then - diff -ur build tmp/bacula-restores${cwd}/build + diff -ur build ${tmp}/bacula-restores${cwd}/build else - diff -ur build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null + diff -ur build ${tmp}/bacula-restores${cwd}/build 2>&1 >/dev/null fi dstat=$? } @@ -282,9 +282,9 @@ check_restore_diff() check_restore_tmp_build_diff() { if test "$debug" -eq 1 ; then - diff -ur tmp/build tmp/bacula-restores${cwd}/tmp/build + diff -ur ${tmp}/build ${tmp}/bacula-restores${cwd}/tmp/build else - diff -ur tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null + diff -ur ${tmp}/build ${tmp}/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null fi dstat=$? } @@ -322,21 +322,21 @@ end_test() echo " ===== $TestName OK `date +%R:%S` ===== " echo " ===== $TestName OK `date +%R:%S` ===== " >>test.out if test "$debug" -eq 0 ; then - scripts/cleanup + ${rscripts}/cleanup fi fi } copy_tape_confs() { - scripts/copy-tape-confs - scripts/cleanup-tape + ${rscripts}/copy-tape-confs + ${rscripts}/cleanup-tape } copy_test_confs() { - scripts/copy-test-confs - scripts/cleanup + ${rscripts}/copy-test-confs + ${rscripts}/cleanup } debug_wait() @@ -379,10 +379,10 @@ rewind_drive() load_slot1() { # Get a tape from slot1 -slot=`$scripts/$MTX ${AUTOCHANGER} loaded 0 ${TAPE_DRIVE} $DRIVE1` +slot=`${scripts}/$MTX ${AUTOCHANGER} loaded 0 ${TAPE_DRIVE} $DRIVE1` case $slot in 0) - $scripts/$MTX ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1 + ${scripts}/$MTX ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1 slot=$SLOT1 ;; $SLOT1) @@ -390,8 +390,8 @@ case $slot in ;; *) rewind_drive ${TAPE_DRIVE} - $scripts/$MTX ${AUTOCHANGER} unload $slot ${TAPE_DRIVE} $DRIVE1 - $scripts/$MTX ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1 + ${scripts}/$MTX ${AUTOCHANGER} unload $slot ${TAPE_DRIVE} $DRIVE1 + ${scripts}/$MTX ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1 slot=$SLOT1 ;; esac @@ -406,17 +406,17 @@ load_other_slot() rewind_drive ${TAPE_DRIVE} case $1 in 0) - $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1 + ${scripts}/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1 slot=1 ;; $SLOT1) - $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $1 ${TAPE_DRIVE} $DRIVE1 - $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT2 ${TAPE_DRIVE} $DRIVE1 + ${scripts}/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $1 ${TAPE_DRIVE} $DRIVE1 + ${scripts}/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT2 ${TAPE_DRIVE} $DRIVE1 slot=2 ;; $SLOT2) - $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $1 ${TAPE_DRIVE} $DRIVE1 - $scripts/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1 + ${scripts}/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} unload $1 ${TAPE_DRIVE} $DRIVE1 + ${scripts}/${AUTOCHANGER_SCRIPT} ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1 slot=1 ;; *) @@ -442,11 +442,19 @@ db_user=${db_user:-"regress"} db_password=${db_password:-""} working=${working:-"$cwd/working"} bin=${bin:-"$cwd/bin"} +# Bacula scripts scripts=${scripts:-"$bin"} +# Regress scripts +rscripts=${rscripts:-"$cwd/scripts"} +tmp=${tmp:-"$cwd/tmp"} export bin export working export scripts +export rscripts +export tmp + +touch ${tmp}/dir.out ${tmp}/fd.out ${tmp}/sd.out CLIENT=${HOST}-fd diff --git a/regress/tests/backup-bacula-test b/regress/tests/backup-bacula-test index d4ab848716..8cf65cf560 100755 --- a/regress/tests/backup-bacula-test +++ b/regress/tests/backup-bacula-test @@ -14,18 +14,18 @@ scripts/copy-confs # Zap out any schedule in default conf file so that # it doesn't start during our test # -outf="tmp/sed_tmp" +outf="$tmp/sed_tmp" echo "s% Schedule =%# Schedule =%g" >${outf} -cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1 -sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf +cp $scripts/bacula-dir.conf $tmp/1 +sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf change_jobname Client1 $JobName start_test -cat <${cwd}/tmp/bconcmds +cat <$tmp/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out $tmp/log1.out setdebug level=100 storage=File label volume=TestVolume001 storage=File pool=Default run job=$JobName yes @@ -52,8 +52,8 @@ messages @# @# now do a restore @# -@$out ${cwd}/tmp/log2.out -restore where=${cwd}/tmp/bacula-restores select all done +@$out $tmp/log2.out +restore where=$tmp/bacula-restores select all done yes wait messages @@ -65,10 +65,10 @@ run_bacula check_for_zombie_jobs storage=File stop_bacula -cat <${cwd}/tmp/bconcmds +cat <$tmp/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out $tmp/log1.out @#setdebug level=100 storage=File run job=$JobName yes wait @@ -76,8 +76,8 @@ messages @# @# now do a restore @# -@$out ${cwd}/tmp/log2.out -restore where=${cwd}/tmp/bacula-restores select all done +@$out $tmp/log2.out +restore where=$tmp/bacula-restores select all done yes wait messages diff --git a/regress/tests/incremental-test b/regress/tests/incremental-test index f41a84fe3e..0d8afba264 100755 --- a/regress/tests/incremental-test +++ b/regress/tests/incremental-test @@ -7,23 +7,23 @@ TestName="incremental-test" JobName=Incremental . scripts/functions -scripts/cleanup -scripts/copy-test-confs -echo "${cwd}/tmp/build" >${cwd}/tmp/file-list -mkdir ${cwd}/tmp/build -cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build +${rscripts}/cleanup +${rscripts}/copy-test-confs +echo "${tmp}/build" >${tmp}/file-list +mkdir ${tmp}/build +cp -p ${cwd}/build/src/dird/*.c ${tmp}/build cd ${cwd}/tmp -echo "${cwd}/tmp/build/ficheriro1.txt" >restore-list -echo "${cwd}/tmp/build/ficheriro2.txt" >>restore-list +echo "${tmp}/build/ficheriro1.txt" >restore-list +echo "${tmp}/build/ficheriro2.txt" >>restore-list cd ${cwd} change_jobname CompressedTest $JobName start_test -cat <${cwd}/tmp/bconcmds +cat <${tmp}/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out ${tmp}/log1.out @#setdebug level=100 storage=File label storage=File volume=TestVolume001 label storage=File volume=TestVolume002 @@ -39,13 +39,13 @@ check_for_zombie_jobs storage=File # Now create two new files to be restored later # sleep 1 -echo "ficheriro1.txt" >${cwd}/tmp/build/ficheriro1.txt -cp -f ${cwd}/tmp/build/dird.c ${cwd}/tmp/build/ficheriro2.txt +echo "ficheriro1.txt" >${tmp}/build/ficheriro1.txt +cp -f ${tmp}/build/dird.c ${tmp}/build/ficheriro2.txt -cat <${cwd}/tmp/bconcmds +cat <${tmp}/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out ${tmp}/log1.out @# Force Incremental on the second Volume update volume=TestVolume001 VolStatus=Used run level=Differential job=$JobName yes @@ -57,13 +57,13 @@ END_OF_DATA run_bconsole sleep 1 -touch ${cwd}/tmp/build/ficheriro1.txt -touch ${cwd}/tmp/build/ficheriro2.txt +touch ${tmp}/build/ficheriro1.txt +touch ${tmp}/build/ficheriro2.txt -cat <${cwd}/tmp/bconcmds +cat <${tmp}/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out ${tmp}/log1.out run level=Incremental job=$JobName yes wait messages @@ -73,15 +73,15 @@ END_OF_DATA run_bconsole sleep 1 -cd ${cwd}/tmp/build +cd ${tmp}/build cp -f ficheriro2.txt 1 sed "s%a%b%g" 1 >ficheriro2.txt rm -f 1 cd ${cwd} -cat <${cwd}/tmp/bconcmds +cat <${tmp}/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out ${tmp}/log1.out run level=Differential job=$JobName yes wait messages @@ -91,12 +91,12 @@ END_OF_DATA run_bconsole sleep 1 -touch ${cwd}/tmp/build/ficheriro1.txt -touch ${cwd}/tmp/build/ficheriro2.txt -cat <${cwd}/tmp/bconcmds +touch ${tmp}/build/ficheriro1.txt +touch ${tmp}/build/ficheriro2.txt +cat <${tmp}/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out ${tmp}/log1.out run level=Incremental job=$JobName yes wait messages @@ -106,12 +106,12 @@ END_OF_DATA run_bconsole sleep 1 -touch ${cwd}/tmp/build/ficheriro1.txt -touch ${cwd}/tmp/build/ficheriro2.txt -cat <${cwd}/tmp/bconcmds +touch ${tmp}/build/ficheriro1.txt +touch ${tmp}/build/ficheriro2.txt +cat <${tmp}/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out ${tmp}/log1.out run level=Incremental job=$JobName yes wait messages @@ -121,12 +121,12 @@ END_OF_DATA run_bconsole sleep 1 -touch ${cwd}/tmp/build/ficheriro1.txt -touch ${cwd}/tmp/build/ficheriro2.txt -cat <${cwd}/tmp/bconcmds +touch ${tmp}/build/ficheriro1.txt +touch ${tmp}/build/ficheriro2.txt +cat <${tmp}/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out ${tmp}/log1.out run level=Incremental job=$JobName yes wait messages @@ -135,13 +135,13 @@ END_OF_DATA run_bconsole sleep 1 -touch ${cwd}/tmp/build/ficheriro1.txt -touch ${cwd}/tmp/build/ficheriro2.txt +touch ${tmp}/build/ficheriro1.txt +touch ${tmp}/build/ficheriro2.txt -cat <${cwd}/tmp/bconcmds +cat <${tmp}/bconcmds @output /dev/null messages -@$out ${cwd}/tmp/log1.out +@$out ${tmp}/log1.out setdebug level=200 storage=File run level=Incremental job=$JobName yes wait @@ -149,9 +149,9 @@ messages @# @# now do a restore @# -@$out ${cwd}/tmp/log2.out +@$out ${tmp}/log2.out setdebug level=10 storage=File -restore where=${cwd}/tmp/bacula-restores storage=File file=<${cwd}/tmp/restore-list +restore where=${tmp}/bacula-restores storage=File file=<${tmp}/restore-list yes wait status storage=File @@ -168,6 +168,6 @@ check_two_logs # # Delete .c files because we will only restored the txt files # -rm -f ${cwd}/tmp/build/*.c +rm -f ${tmp}/build/*.c check_restore_tmp_build_diff end_test -- 2.39.5