From ce9ce640786bfa141653a2b5d5f44044a8b625f6 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 9 Oct 2008 19:30:23 +0000 Subject: [PATCH] ebl Add check_duration to functions Add cancel-test to check different cancel cases git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7740 91ce42f0-d328-0410-95d8-f526ca767f89 --- regress/scripts/functions | 12 ++ regress/tests/cancel-test | 253 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 265 insertions(+) create mode 100755 regress/tests/cancel-test diff --git a/regress/scripts/functions b/regress/scripts/functions index 2788149b1c..3a38be04af 100644 --- a/regress/scripts/functions +++ b/regress/scripts/functions @@ -110,6 +110,18 @@ check_files_written() fi } +check_duration() +{ + LOG=$1 + TIME=$2 + 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` + + if [ "$T" -gt $TIME ]; then + print_debug "Expect less than $TIME sec, get $T" + bstat=2 + fi +} + run_bacula() { debug_wait diff --git a/regress/tests/cancel-test b/regress/tests/cancel-test new file mode 100755 index 0000000000..4b869b4e0a --- /dev/null +++ b/regress/tests/cancel-test @@ -0,0 +1,253 @@ +#!/bin/sh +# +# Test different cancel cases +# Can be quite long + +# +TestName="cancel-test" +JobName=backup +. scripts/functions + +scripts/cleanup +scripts/copy-confs + +# +# Zap out any schedule in default conf file so that +# it doesn't start during our test +# +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 + +touch tmp/log1.out + +# Add some jobs and fileset for this test +cat <>${cwd}/bin/bacula-dir.conf +FileSet { + Name = FS_ERR + Include { + Options { + signature = MD5 + } + file = "\\${cwd}/tmp/bconcmds +@output /dev/null +messages +@$out ${cwd}/tmp/logfile1.out +@################################################################ +@# run a first test without volume +@# Expect: duration < 60 +@################################################################ +run job=$JobName yes +@sleep 5 +messages +cancel +yes +wait +messages +@$out ${cwd}/tmp/logfile2.out +@################################################################ +@# run test with a small volume +@# Expect: duration < 60 +@################################################################ +label volume=TestVolume001 storage=File pool=Default +update volume=TestVolume001 MaxVolBytes=1MB +run job=$JobName yes +@sleep 5 +messages +st dir +cancel +yes +wait +messages +@$out ${cwd}/tmp/logfile3.out +@################################################################ +@# run test with 2 jobs in // (limit 1) +@# expect that the second job don't stay in the list +@# Expect: Job2 not present at the end +@################################################################ +label volume=TestVolume002 storage=File pool=Default +run job=$JobName yes +@sleep 1 +messages +run job=$JobName yes +@sleep 1 +messages +st dir +cancel jobid=4 +@sleep 1 +st dir +cancel jobid=3 +@sleep 1 +st dir +wait +messages +@$out ${cwd}/tmp/logfile4.out +@################################################################ +@# test with a broken fileset +@# Expect: duration < 20s +@################################################################ +run job=$JobName fileset=FS_ERR yes +@sleep 3 +messages +st dir +wait +messages +@$out ${cwd}/tmp/logfile5.out +@################################################################ +@# test with a broken runscript +@# Expect: duration < 20s +@################################################################ +run job=RUN_ERR1 yes +@sleep 3 +messages +st dir +wait +messages +@$out ${cwd}/tmp/logfile6.out +@################################################################ +@# test with a broken runscript +@# Expect: duration < 20s +@################################################################ +run job=RUN_ERR2 yes +@sleep 3 +messages +st dir +wait +messages +@$out ${cwd}/tmp/logfile7.out +@################################################################ +@# test with a broken runscript and a very long AfterJob +@# we broke the backup during the ClientRunBeforeJob +@# Expect: duration > 600 +@################################################################ +run job=RUN_ERR3 yes +@sleep 5 +messages +st dir +cancel +yes +@sleep 5 +messages +st dir +wait +messages +@$out ${cwd}/tmp/logfile8.out +@################################################################ +@# test with a broken runscript and a very long AfterJob +@# we broke the backup during the ClientRunAfterJob +@# Expect: duration > 600 +@################################################################ +run job=RUN_ERR3 yes +@sleep 20 +messages +st dir +cancel +yes +@sleep 5 +messages +st dir +wait +messages +@$out ${cwd}/tmp/logfile9.out +@################################################################ +@# test with a broken runscript and a very long AfterJob +@# we broke the backup during the backup +@# Expect: duration > 600 +@################################################################ +update volume=TestVolume002 volstatus=Used +label volume=TestVolume003 storage=File pool=Default +update volume=TestVolume003 MaxVolBytes=1MB +run job=RUN_ERR3 yes +@sleep 20 +messages +st dir +cancel +yes +@sleep 5 +messages +st dir +wait +messages +@$out ${cwd}/tmp/logfile20.out +@################################################################ +@# test with a broken connexion between DIR/FD +@# the test will run a job that will stop, and we send +@# the STOP signal to the FD process +@# Expect: duration < 400 +@################################################################ +update volume=TestVolume003 volstatus=Used +label volume=TestVolume004 storage=File pool=Default +update volume=TestVolume004 MaxVolBytes=1MB +run job=$JobName yes +@sleep 5 +messages +quit +END_OF_DATA + +run_bacula + +print_debug "Stopping FD" +# stop the bacula-fd and cancel the job +#kill -STOP $(pidof bacula-fd) + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/logfile20.out +@sleep 3 +messages +st dir +cancel +yes +st dir +wait +messages +quit +END_OF_DATA + +run_bconsole + +kill -CONT $(pidof bacula-fd) + +check_for_zombie_jobs storage=File +stop_bacula + +# A fileset or runscript error goes fast +check_duration ${cwd}/tmp/logfile4.out 30 +check_duration ${cwd}/tmp/logfile5.out 30 +check_duration ${cwd}/tmp/logfile6.out 30 + +# Verify the broken connection +check_duration ${cwd}/tmp/logfile20.out 400 + +end_test -- 2.39.5