From 1358f397235ee74d0d29e2772c6a1b118611923a Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 17 Oct 2008 12:52:35 +0000 Subject: [PATCH] ebl Add more copy tests git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7830 91ce42f0-d328-0410-95d8-f526ca767f89 --- regress/scripts/bacula-dir-migration.conf.in | 14 +++ regress/scripts/functions | 47 ++++++---- regress/tests/copy-job-test | 97 ++++++++++++++++++++ regress/tests/copy-time-test | 94 +++++++++++++++++++ regress/tests/copy-volume-test | 15 +-- 5 files changed, 236 insertions(+), 31 deletions(-) create mode 100755 regress/tests/copy-job-test create mode 100755 regress/tests/copy-time-test diff --git a/regress/scripts/bacula-dir-migration.conf.in b/regress/scripts/bacula-dir-migration.conf.in index 5100cd1e9d..a8c2335531 100644 --- a/regress/scripts/bacula-dir-migration.conf.in +++ b/regress/scripts/bacula-dir-migration.conf.in @@ -222,6 +222,19 @@ Pool { Migration Time = 1 } +Pool { + Name = Special + Pool Type = Backup + Recycle = yes # Bacula can automatically recycle Volumes + AutoPrune = yes # Prune expired volumes + Volume Retention = 365d # one year + NextPool = Full + Storage = File + Migration High Bytes = 40M + Migration Low Bytes = 20M + Migration Time = 5h +} + Pool { Name = Full Pool Type = Backup @@ -236,4 +249,5 @@ Pool { Recycle = yes AutoPrune = yes Pool Type = Scratch + RecyclePool = Scratch } diff --git a/regress/scripts/functions b/regress/scripts/functions index da90b4cbf0..f62807d1db 100644 --- a/regress/scripts/functions +++ b/regress/scripts/functions @@ -110,25 +110,34 @@ check_files_written() fi } -#get_duration() -#{ -# LOG=$1 -# T=`awk 'BEGIN {t["secs"]=1;t["sec"]=1;t["min"]=60;t["mins"]=60}; /Elapsed time:/ { last=$3*t[$4] } END { print last }' $LOG` -# echo $T -#} - -#check_duration() -#{ -# LOG=$1 -# TIME=$2 -# OP=${3-gt} - -# T=$(get_duration $LOG) -# if [ "$T" -$OP "$TIME" ]; then -# print_debug "Expect $OP than $TIME sec, get $T" -# bstat=2 -# fi -#} +################################################################ +# Get information from logs +get_mig_info() +{ + # index of the job in the log (start from 0) + IDX=$1 + LOG=$2 + RET=`awk -v idx=$IDX -F: '/Prev Backup JobId/ { pbid[j++]=$2 } /New Backup JobId/ { nbid[i++]=$2 } END { print pbid[idx] " " nbid[idx] }' $LOG` +} + +get_duration() +{ + LOG=$1 + RET=`awk 'BEGIN {t["secs"]=1;t["sec"]=1;t["min"]=60;t["mins"]=60}; /Elapsed time:/ { last=$3*t[$4] } END { print last }' $LOG` +} + +check_duration() +{ + LOG=$1 + TIME=$2 + OP=${3-gt} + + get_duration $LOG + if [ "$RET" -$OP "$TIME" ]; then + print_debug "Expect $OP than $TIME sec, get $RET" + bstat=2 + fi +} run_bacula() { diff --git a/regress/tests/copy-job-test b/regress/tests/copy-job-test new file mode 100755 index 0000000000..b19368ecf8 --- /dev/null +++ b/regress/tests/copy-job-test @@ -0,0 +1,97 @@ +#!/bin/sh +# +# Run a simple backup of the Bacula build directory then copy it +# to another device. +# +# This script uses the virtual disk autochanger +# +TestName="copy-job-test" +JobName=CopyJobSave +. scripts/functions + + +scripts/cleanup +scripts/copy-migration-confs +scripts/prepare-disk-changer +echo "${cwd}/build" >${cwd}/tmp/file-list +sed -i 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf +sed -i 's/Migrate/Copy/g' ${cwd}/bin/bacula-dir.conf + + +change_jobname NightlySave $JobName +start_test + +# +# Note, we first backup into Pool Default, +# then Copy into Pool Full. +# Pool Default uses Storage=File +# Pool Full uses Storage=DiskChanger + +# Write out bconsole commands +cat <${cwd}/tmp/bconcmds +@output +messages +@$out ${cwd}/tmp/log1.out +setdebug level=100 storage=File +label storage=File volume=FileVolume001 Pool=Default +label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0 +label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0 +@# run two jobs (both will be copied) +run job=$JobName yes +run job=$JobName yes +wait +list jobs +list volumes +@#setdebug level=100 dir +@# should copy two jobs +@#setdebug level=51 storage=DiskChanger +run job=copy-job yes +wait +messages +purge volume=FileVolume001 +list jobs +list volumes +wait +messages +@$out ${cwd}/tmp/log3.out +@# +@# Now do another backup, but level Incremental +@# +run job=$JobName level=Incremental yes +wait +messages +@# +@# This final job that runs should be Incremental and +@# not upgraded to full. +list jobs +@# +@# now do a restore +@# +@$out ${cwd}/tmp/log2.out +list volumes +restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger +unmark * +mark * +done +yes +list volumes +wait +messages +@output +quit +END_OF_DATA + +run_bacula +check_for_zombie_jobs storage=File +stop_bacula + +check_two_logs +check_restore_diff + +grep 'Backup Level:' tmp/log3.out | grep Incremental > /dev/null +if [ $? != 0 ]; then + bstat=2 + print_debug "The incremental job must use copied jobs" +fi + +end_test diff --git a/regress/tests/copy-time-test b/regress/tests/copy-time-test new file mode 100755 index 0000000000..bdea327494 --- /dev/null +++ b/regress/tests/copy-time-test @@ -0,0 +1,94 @@ +#!/bin/sh +# +# Run a simple backup of the Bacula build directory then copy it +# to another device. +# +# This script uses the virtual disk autochanger +# +TestName="copy-time-test" +JobName=CopyJobSave +. scripts/functions + + +scripts/cleanup +scripts/copy-migration-confs +scripts/prepare-disk-changer +echo "${cwd}/build" >${cwd}/tmp/file-list +sed -i 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf +sed -i 's/Migrate/Copy/g' ${cwd}/bin/bacula-dir.conf + +change_jobname NightlySave $JobName +start_test + +# +# Note, we first backup into Pool Default, +# then Copy into Pool Full. +# Pool Default uses Storage=File +# Pool Full uses Storage=DiskChanger + +# Write out bconsole commands +cat <${cwd}/tmp/bconcmds +@output +messages +@$out ${cwd}/tmp/log1.out +label storage=File volume=FileVolume001 Pool=Default +label storage=File volume=FileVolume002 Pool=Special +label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0 +label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0 +list volumes +@# run three jobs +run job=$JobName Pool=Special level=Full yes +run job=$JobName level=Full yes +run job=$JobName level=Full yes +wait +messages +update volume=FileVolume001 VolStatus=Used +update volume=FileVolume002 VolStatus=Used +llist jobid=2,3 +list jobs +list volumes +@#setdebug level=20 dir +@# should copy only jobid=2 and 3 +run job=copy-time yes +run job=copy-time pool=Special yes +wait +messages +wait +list jobs +list volumes +purge volume=FileVolume001 +purge volume=FileVolume002 +@# +@# now do a restore +@# +@$out ${cwd}/tmp/log2.out +restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger +unmark * +mark * +done +yes +wait +messages +@output +quit +END_OF_DATA + +run_bacula +check_for_zombie_jobs storage=File +stop_bacula + +print_debug "We must find 3 copy jobs into the log" +for i in 0 1 2; do + get_mig_info $i ${cwd}/tmp/log1.out + set $RET >/dev/null + + if [ -n "$1" -a "$1" != 1 ]; then + bstat=2 + print_debug "The first job should not been copied" + fi +done + + +check_two_logs +check_restore_diff +end_test diff --git a/regress/tests/copy-volume-test b/regress/tests/copy-volume-test index f018d8e5c4..a2f596a4d1 100755 --- a/regress/tests/copy-volume-test +++ b/regress/tests/copy-volume-test @@ -166,16 +166,7 @@ check_restore_diff stop_bacula -################################################################ -# Get information from logs -get_info() -{ - IDX=$1 - LOG=$2 - RET=`awk -v idx=$IDX -F: '/Prev Backup JobId/ { pbid[j++]=$2 } /New Backup JobId/ { nbid[i++]=$2 } END { print pbid[idx] " " nbid[idx] }' $LOG` -} - -get_info 0 ${cwd}/tmp/log11.out +get_mig_info 0 ${cwd}/tmp/log11.out set $RET if [ -z "$2" -o "$2" = 0 ]; then @@ -183,7 +174,7 @@ if [ -z "$2" -o "$2" = 0 ]; then print_debug "The first job must have been copied" fi -get_info 1 ${cwd}/tmp/log11.out +get_mig_info 1 ${cwd}/tmp/log11.out set $RET if [ -z "$2" -o "$2" != 0 ]; then @@ -191,7 +182,7 @@ if [ -z "$2" -o "$2" != 0 ]; then print_debug "The second job have no files, it can't have been copied" fi -get_info 0 ${cwd}/tmp/log4.out +get_mig_info 0 ${cwd}/tmp/log4.out set $RET if [ -z "$2" -o "$2" = 0 ]; then -- 2.39.5