From b73688794a4746a95d3c07023d38d652f63a990c Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 23 Dec 2008 16:06:14 +0000 Subject: [PATCH] ebl Add a test for pooluncopied copy type git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8241 91ce42f0-d328-0410-95d8-f526ca767f89 --- regress/tests/copy-uncopied-test | 156 +++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100755 regress/tests/copy-uncopied-test diff --git a/regress/tests/copy-uncopied-test b/regress/tests/copy-uncopied-test new file mode 100755 index 0000000000..e4dfb24017 --- /dev/null +++ b/regress/tests/copy-uncopied-test @@ -0,0 +1,156 @@ +#!/bin/sh +# +# Run a backup of the Bacula build directory on two Volumes +# then copy it to another device. +# +# This script uses the virtual disk autochanger and migration scripts +# +TestName="copy-uncopied-test" +JobName=MigVolBackup +. scripts/functions + + +scripts/cleanup +scripts/copy-migration-confs +scripts/prepare-disk-changer +echo "${cwd}/build" >${cwd}/tmp/file-list +#cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1 +#sed "s%# Maximum File Size% Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf + +change_jobname NightlySave $JobName +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 +rm -f ${cwd}/build/po/test.po >/dev/null + +touch ${cwd}/tmp/log2.out + +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=Scratch +label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0 +label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0 +@# +run job=$JobName level=Full yes +wait +run job=$JobName level=Full yes +wait +update volume=FileVolume001 VolStatus=Used +run job=$JobName level=Full yes +wait +messages +@$out ${cwd}/tmp/log11.out +@############################################################ +@# should copy job 1,2,3 +@# Expect: 3 copies (1,2,3) +@############################################################ +@#setdebug level=100 dir +run job=copy-uncopied yes +@sleep 5 +wait +messages +list jobs +list volumes +list copies +@$out ${cwd}/tmp/log12.out +@############################################################ +@# should not copy jobs +@# Expect: 3 copies (1,2,3) +@############################################################ +run job=copy-uncopied yes +wait +messages +list copies +@$out ${cwd}/tmp/log13.out +@############################################################ +@# should not have a copy of the copy +@# Expect: 2 copies (2,3) +@############################################################ +delete jobid=1 +run job=copy-uncopied yes +wait +messages +list copies +@$out ${cwd}/tmp/log14.out +@############################################################ +@# should copy jobid=2 +@# Expect: 2 copies (2,3) +@############################################################ +delete jobid=8 +run job=copy-uncopied yes +wait +messages +list copies +END_OF_DATA + +run_bacula +check_for_zombie_jobs storage=File +stop_bacula + +bstat=0 +rstat=0 +dstat=0 +zstat=0 + +for i in tmp/log1[0-9].out; do + awk -F '|' ' + /list copies/ { ok=1; delete already } + /^[|][ ]+[0-9]+/ { + if (ok) { + jobid=$2 + copyid=$4 + + if (already[jobid]) { + print "ERROR: " jobid " " copyid " " already[jobid] + } else { + print "OK: " jobid " " copyid + } + + already[jobid]=copyid + } +}' $i > $i.result +done + +grep ERROR tmp/log*result +if [ $? -eq 0 ]; then + print_debug "Found multiple copies" + bstat=2 +fi + +n=`wc -l tmp/log11.out.result | awk '{ print $1 }'` +if [ $n -ne 3 ]; then + print_debug "log11: Bad copies number" + bstat=3 +fi + +n=`wc -l tmp/log12.out.result| awk '{ print $1 }'` +if [ $n -ne 3 ]; then + print_debug "log12: Bad copies number" + bstat=3 +fi + +n=`wc -l tmp/log13.out.result| awk '{ print $1 }'` +if [ $n -ne 2 ]; then + print_debug "log13: Bad copies number" + bstat=3 +fi + +n=`wc -l tmp/log14.out.result| awk '{ print $1 }'` +if [ $n -ne 2 ]; then + print_debug "log14: Bad copies number" + bstat=3 +fi + +check_two_logs +end_test -- 2.39.5