]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/cancel-test
ebl Remove debug level
[bacula/bacula] / regress / tests / cancel-test
index 4b869b4e0ad43f4378397882e9141b04f9e47a2d..87c9486336cc00298b8c05d92e48b04748b2cbaf 100755 (executable)
@@ -56,11 +56,23 @@ 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
 start_test
 
+when=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+6000))"`
+
 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 @output /dev/null
 messages
@@ -149,8 +161,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 +178,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 +196,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 +214,61 @@ 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
+time
+cancel
+yes
+@sleep 5
+messages
+st dir
+wait
+time
+messages
+@$out ${cwd}/tmp/logfile11.out
+@################################################################
+@# Test to cancel the job immediately
+@# Expect: duration < 30
+@################################################################
+label volume=TestVolume005 storage=File pool=Default
+run job=$JobName yes
+time
+cancel
+yes
+@sleep 5
+messages
+st dir
+wait
+time
+messages
+@$out ${cwd}/tmp/logfile12.out
+@################################################################
+@# Test to cancel the job before it starts
+@# Expect: 
+@################################################################
+run job=$JobName when="$when" yes
+@sleep 5
+st dir
+cancel
+yes
+time
+@sleep 5
+messages
+st dir
+wait
+time
+messages
 @$out ${cwd}/tmp/logfile20.out
 @################################################################
 @# test with a broken connexion between DIR/FD
@@ -207,9 +276,9 @@ messages
 @# 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
+update volume=TestVolume005 volstatus=Used
+label volume=TestVolume006 storage=File pool=Default
+update volume=TestVolume006 MaxVolBytes=1MB
 run job=$JobName yes
 @sleep 5
 messages
@@ -220,7 +289,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 <<END_OF_DATA >${cwd}/tmp/bconcmds
 @$out ${cwd}/tmp/logfile20.out
@@ -243,11 +312,33 @@ 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 lt
+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 lt
+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
+check_duration ${cwd}/tmp/logfile20.out 400 lt
 
 end_test