From cc05b0e97f0999a130d24899aac3f635a3d98af8 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 10 Oct 2008 21:10:23 +0000 Subject: [PATCH] ebl update cancel test git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7755 91ce42f0-d328-0410-95d8-f526ca767f89 --- regress/scripts/functions | 14 ++++++-- regress/tests/cancel-test | 68 +++++++++++++++++++++++++++++++++++---- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/regress/scripts/functions b/regress/scripts/functions index 3a38be04af..d7a92413da 100644 --- a/regress/scripts/functions +++ b/regress/scripts/functions @@ -110,14 +110,22 @@ 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 - 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` + OP=${3-gt} - if [ "$T" -gt $TIME ]; then - print_debug "Expect less than $TIME sec, get $T" + T=$(get_duration $LOG) + if [ "$T" -$OP "$TIME" ]; then + print_debug "Expect $OP than $TIME sec, get $T" bstat=2 fi } diff --git a/regress/tests/cancel-test b/regress/tests/cancel-test index 4b869b4e0a..622df2a7a7 100755 --- a/regress/tests/cancel-test +++ b/regress/tests/cancel-test @@ -56,6 +56,16 @@ Job { } JobDefs = DefaultJob } +Job { + Name = RUN_ERR4 + ClientRunBeforeJob="/bin/sleep 10" + RunScript { + Command = "/bin/sleep 40" + RunsWhen = After + RunsOnFailure = Yes + } + JobDefs = DefaultJob +} EOF change_jobname Client1 $JobName @@ -149,8 +159,8 @@ 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 +@# we break the backup during the ClientRunBeforeJob +@# Expect: duration > 550 @################################################################ run job=RUN_ERR3 yes @sleep 5 @@ -166,8 +176,9 @@ 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 +@# we break the backup during the ClientRunAfterJob +@# Expect: duration > 550 +@# print sleep 600 @################################################################ run job=RUN_ERR3 yes @sleep 20 @@ -183,8 +194,9 @@ 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 +@# we break the backup during the backup +@# Expect: duration > 550 +@# print sleep 600 @################################################################ update volume=TestVolume002 volstatus=Used label volume=TestVolume003 storage=File pool=Default @@ -200,6 +212,26 @@ messages st dir wait messages +@$out ${cwd}/tmp/logfile10.out +@################################################################ +@# test with a broken runscript and a short AfterJob +@# we break the backup during the backup +@# Expect: print sleep 40 +@################################################################ +update volume=TestVolume003 volstatus=Used +label volume=TestVolume004 storage=File pool=Default +update volume=TestVolume004 MaxVolBytes=1MB +run job=RUN_ERR4 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 @@ -220,7 +252,7 @@ run_bacula print_debug "Stopping FD" # stop the bacula-fd and cancel the job -#kill -STOP $(pidof bacula-fd) +kill -STOP $(pidof bacula-fd) cat <${cwd}/tmp/bconcmds @$out ${cwd}/tmp/logfile20.out @@ -243,10 +275,32 @@ check_for_zombie_jobs storage=File stop_bacula # A fileset or runscript error goes fast +check_duration ${cwd}/tmp/logfile1.out 30 +check_duration ${cwd}/tmp/logfile3.out 30 check_duration ${cwd}/tmp/logfile4.out 30 check_duration ${cwd}/tmp/logfile5.out 30 check_duration ${cwd}/tmp/logfile6.out 30 +check_duration ${cwd}/tmp/logfile8.out 550 gt +grep 'ClientAfterJob "/bin/sleep 600"' tmp/logfile8.out >/dev/null +if [ $? -ne 0 ]; then + print_debug "Can't find ClientAfterJob" + bstat=2 +fi + +check_duration ${cwd}/tmp/logfile9.out 550 gt +grep 'ClientAfterJob "/bin/sleep 600"' tmp/logfile9.out >/dev/null +if [ $? -ne 0 ]; then + print_debug "Can't find ClientAfterJob" + bstat=2 +fi + +grep 'ClientAfterJob "/bin/sleep 40"' tmp/logfile10.out >/dev/null +if [ $? -ne 0 ]; then + print_debug "Can't find ClientAfterJob" + bstat=2 +fi + # Verify the broken connection check_duration ${cwd}/tmp/logfile20.out 400 -- 2.39.5