From 8d0af31e34466d4db5de2c1030aca0bc9d7ce1e9 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 22 Dec 2008 13:03:13 +0000 Subject: [PATCH] ebl Add test for multiple copies and automatic "upgrade" to normal backup git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8222 91ce42f0-d328-0410-95d8-f526ca767f89 --- regress/tests/copy-upgrade-test | 187 ++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100755 regress/tests/copy-upgrade-test diff --git a/regress/tests/copy-upgrade-test b/regress/tests/copy-upgrade-test new file mode 100755 index 0000000000..4a7282ca41 --- /dev/null +++ b/regress/tests/copy-upgrade-test @@ -0,0 +1,187 @@ +#!/bin/sh +# +# Run a simple backup of the Bacula build directory then copy it +# to another device. We test that when the original job is purged +# the next copy is "upgraded" to Type=B +# +# This script uses the virtual disk autochanger +# +TestName="copy-upgrade-test" +JobName=CopyJobSave +. scripts/functions + + +scripts/cleanup +scripts/copy-migration-confs +scripts/prepare-disk-changer +echo "${cwd}/build" >${cwd}/tmp/file-list +sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1 +sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${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 job=$JobName yes +wait +messages +END_OF_DATA + +run_bacula + +echo test > ${cwd}/build/po/test + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log1.out +run job=$JobName level=incremental yes +wait +messages +END_OF_DATA + +run_bconsole + +echo test1 > ${cwd}/build/po/test1 + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log1.out +run job=$JobName level=incremental yes +wait +messages +@# we should be able to purge jobid 1 3 times +update volume=FileVolume001 VolStatus=Used +@# 4,5 +run job=copy-job jobid=1 yes +wait +@# 6,7 +run job=copy-job jobid=2 yes +wait +@# 8,9 +run job=copy-job jobid=3 yes +wait +@# 10,11 +run job=copy-job jobid=1 yes +wait +@# 12,13 +run job=copy-job jobid=2 yes +wait +@# 14,15 +run job=copy-job jobid=3 yes +wait +@# 16,17 +run job=copy-job jobid=1 yes +wait +@# 18,19 +run job=copy-job jobid=1 yes +wait +messages +list jobs +list volumes +END_OF_DATA + +run_bconsole + +cat< ${cwd}/tmp/bconcmds.resto +@# +@# now do a restore +@# +@$out ${cwd}/tmp/log2.out +list volumes +restore copies where=${cwd}/tmp/bacula-restores select storage=DiskChanger +unmark * +mark * +done +yes +list volumes +wait +messages +@output +quit +END_OF_DATA + +run_bconsole ${cwd}/tmp/bconcmds.resto +check_two_logs +check_restore_diff + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log2.out +@# the last restore +@# should restore with 1,2,3 +delete jobid=1 +@# should restore with 5,2,3 +EOF +run_bconsole + +rm -rf ${cwd}/tmp/bacula-restores +run_bconsole ${cwd}/tmp/bconcmds.resto +check_two_logs +check_restore_diff + +# remove first copy of job=1 +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log2.out +delete jobid=5 +@# should restore with 11,2,3 +EOF +run_bconsole + +rm -rf ${cwd}/tmp/bacula-restores +run_bconsole ${cwd}/tmp/bconcmds.resto +check_two_logs +check_restore_diff + +# remove 2 copies at the same time +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log2.out +delete jobid=11,17 +@# should restore with 19,2,3 +EOF +run_bconsole + +rm -rf ${cwd}/tmp/bacula-restores +run_bconsole ${cwd}/tmp/bconcmds.resto +check_two_logs +check_restore_diff + +# remove job and copies of jobid=3 +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log2.out +delete jobid=3,9,15 +@# should restore with 19,2 +EOF +run_bconsole + +rm -f ${cwd}/build/po/test1 +rm -rf ${cwd}/tmp/bacula-restores +run_bconsole ${cwd}/tmp/bconcmds.resto +check_two_logs +check_restore_diff + +awk '/You have selected the following JobIds:/ { print $7 }' \ + ${cwd}/tmp/log2.out > ${cwd}/tmp/real +awk '/should restore with/ { print $5 }' \ + ${cwd}/tmp/log2.out > ${cwd}/tmp/should + +diff ${cwd}/tmp/real ${cwd}/tmp/should +if [ $? -ne 0 ]; then + print_debug "Bad job selection!!!" + rstat=2 +fi + +check_for_zombie_jobs storage=File +stop_bacula +end_test -- 2.39.5