From 7f4575ef87d0e31cbec40c7a8c082e4f959cc4fa Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 9 Apr 2008 21:06:18 +0000 Subject: [PATCH] ebl Add Runscript tests for restore jobs git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6782 91ce42f0-d328-0410-95d8-f526ca767f89 --- .../scripts/bacula-dir.conf.testrunscript.in | 62 +++++++++++----- regress/tests/runscript-test | 72 ++++++++++++------- 2 files changed, 90 insertions(+), 44 deletions(-) diff --git a/regress/scripts/bacula-dir.conf.testrunscript.in b/regress/scripts/bacula-dir.conf.testrunscript.in index d569dd4b62..f1c5192313 100644 --- a/regress/scripts/bacula-dir.conf.testrunscript.in +++ b/regress/scripts/bacula-dir.conf.testrunscript.in @@ -80,6 +80,7 @@ Job { #@hostname@-fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1" #@hostname@-fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2" +#@hostname@-fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED3" #@hostname@-dir: AfterJob: run command "/bin/echo RunAfterFailedJob" Job { Name = "RUN_FD_FAILED" @@ -151,31 +152,54 @@ Job { Run After Failed Job = "/bin/echo RunAfterFailedJob" } -FileSet { - Name = FS_FIFO - Include { - Options { readfifo = yes } - File=<@tmpdir@/file-list - } -} - Job { - Name = BUG_897 + Name = "RUN_CONSOLE_CMD" + FileSet = FS_TESTJOB JobDefs = DefaultJob - FileSet = FS_FIFO - - RunScript { - Command = "/bin/echo touching @tmpdir@/RUN_BUG_897" - RunsWhen = after - RunsOnFailure = yes - } RunScript { - Command = "/bin/touch @tmpdir@/RUN_BUG_897" - RunsWhen = after - RunsOnFailure = yes + Console = "purge volume=TestVolume001 yes" + Console = "st dir" + RunsWhen = Before + runsonclient = no } } +Job { + Name = "Restore" + Type = Restore + Client = @hostname@-fd + FileSet = FS_TESTJOB + Storage = File + Messages = Standard + Pool = Default + + RunScript { + RunsWhen = Before + RunsOnClient = Yes + Command = "echo ClientBeforeRestore" + } + + RunScript { + RunsOnFailure = No + RunsWhen = After + RunsOnClient = Yes + Command = "echo ClientAfterRestore" + } + + RunScript { + RunsWhen = Before + RunsOnClient = No + Command = "echo DirBeforeRestore" + } + + RunScript { + RunsOnFailure = No + RunsWhen = After + RunsOnClient = Yes + Command = "echo DirAfterRestore" + } +} + # Client (File Services) to backup Client { Name = @hostname@-fd diff --git a/regress/tests/runscript-test b/regress/tests/runscript-test index 3f15cb6444..cd53433e15 100755 --- a/regress/tests/runscript-test +++ b/regress/tests/runscript-test @@ -23,7 +23,7 @@ start_test cat <${cwd}/tmp/bconcmds @$out /dev/null messages -label volume=TestVolume001 +label volume=TestVolume001 pool=Scratch @$out ${cwd}/tmp/RUN_FD_WARNING.log run job=RUN_FD_WARNING yes wait @@ -48,6 +48,11 @@ messages run job=RUN_FD_FAILED2 yes wait messages +@sleep 1 +@$out ${cwd}/tmp/RUN_RESTO.log +restore where=${cwd}/tmp/bacula-restores select all done yes +wait +messages st dir quit END_OF_DATA @@ -63,84 +68,101 @@ export dstat export bstat export rstat -grep 'shell command: run BeforeJob "/bin/echo RunBeforeJob"' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1 +grep 'shell command: run BeforeJob "/bin/echo RunBeforeJob"' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null a=$? -grep 'ClientRunBeforeJob: ClientRunBeforeJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1 +grep 'ClientRunBeforeJob: ClientRunBeforeJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null b=$? -grep 'shell command: run ClientAfterJob "/bin/echo ClientRunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1 +grep 'shell command: run ClientAfterJob "/bin/echo ClientRunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null c=$? -grep 'shell command: run AfterJob "/bin/echo RunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1 +grep 'shell command: run AfterJob "/bin/echo RunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null d=$? if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 ] then [ "$debug" = 1 ] && echo RUN_ALL_OK ok else echo "RUN_ALL_OK in error" - rstat=1 + bstat=1 fi -grep 'shell command: run BeforeJob "/bin/false RUN_DIR_FAILED"' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null 2>&1 +grep 'shell command: run BeforeJob "/bin/false RUN_DIR_FAILED"' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null a=$? -grep 'AfterJob: RunAfterFailedJob' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null 2>&1 +grep 'AfterJob: RunAfterFailedJob' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null b=$? if [ $a = 0 -a $b = 0 ] then [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok else echo "RUN_DIR_FAILED in error" - rstat=1 + bstat=1 fi -grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 +grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null a=$? -grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 +grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null b=$? -grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 +grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null c=$? -grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 +grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null d=$? -grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 +grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null e=$? -grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 +grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null f=$? if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 -a $f = 0 ] then [ "$debug" = 1 ] && echo RUN_FD_FAILED ok else echo "RUN_FD_FAILED in error a=$a b=$b c=$c d=$d e=$e f=$f" - rstat=1 + bstat=1 fi -grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 +grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null a=$? -grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 +grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null b=$? -grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 +grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null c=$? -grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 +grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null d=$? -grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 +grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null e=$? if [ $a = 0 -a $b != 0 -a $c = 0 -a $d = 0 -a $e = 0 ] then [ "$debug" = 1 ] && echo RUN_FD_FAILED ok else echo "RUN_FD_FAILED2 in error a=$a b=$b c=$d d=$d e=$e" - rstat=1 + bstat=1 fi -grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_WARNING"' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1 +grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_WARNING"' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null a=$? -grep 'RunAfterFailedJob' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1 +grep 'RunAfterFailedJob' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null b=$? -grep 'Backup OK -- with warnings' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1 +grep 'Backup OK -- with warnings' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null c=$? if [ $a = 0 -a $b != 0 -a $c = 0 ] then [ "$debug" = 1 ] && echo RUN_FD_WARNING ok else echo "RUN_FD_WARNING in error" + bstat=1 +fi + +grep 'ClientBeforeRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null +a=$? +grep 'ClientAfterRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null +b=$? +grep 'DirBeforeRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null +c=$? +grep 'DirAfterRestore' ${cwd}/tmp/RUN_RESTO.log >/dev/null +d=$? +if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 ] +then + [ "$debug" = 1 ] && echo RUN_RESTO ok +else + echo "RUN_RESTO in error" rstat=1 fi + end_test -- 2.39.5