X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=regress%2Ftests%2Frunscript-test;h=ef024c21fda163408e96969d647428ca91dd5d71;hb=38b243eb09f97315282dd31dd4f162fcbb6c6778;hp=62c449a62755d1186e675a921d402ff293d0326d;hpb=8e5c5a30841d33748f604e318b7876eda6d97e5c;p=bacula%2Fbacula diff --git a/regress/tests/runscript-test b/regress/tests/runscript-test index 62c449a627..ef024c21fd 100755 --- a/regress/tests/runscript-test +++ b/regress/tests/runscript-test @@ -1,117 +1,176 @@ #!/bin/sh # -# Test if Bacula can automatically create a Volume label. +# Test RunScript # TestName="runscript-test" JobName=backup . scripts/functions -set_debug 0 copy_test_confs rm -f bin/bacula-dir.conf -rm -f tmp/RUN*log +rm -f ${cwd}/tmp/RUN*log +rm -f ${cwd}/tmp/RUN_FD_FAILED + +touch ${cwd}/tmp/log1.out /bin/cp -f scripts/bacula-dir.conf.testrunscript bin/bacula-dir.conf -echo "${cwd}/build/po" >/tmp/file-list +echo "${cwd}/build/po" >${cwd}/tmp/file-list start_test -cat <tmp/bconcmds +cat <${cwd}/tmp/bconcmds @$out /dev/null messages -label volume=TestVolume001 -@$out tmp/RUN_FD_WARNING.log +label volume=TestVolume001 pool=Scratch +setdebug dir level=200 +@$out ${cwd}/tmp/RUN_FD_WARNING.log run job=RUN_FD_WARNING yes wait messages @sleep 1 -@$out tmp/RUN_ALL_OK.log +@$out ${cwd}/tmp/RUN_ALL_OK.log run job=RUN_ALL_OK yes wait messages @sleep 1 -@$out tmp/RUN_FD_FAILED.log +@$out ${cwd}/tmp/RUN_FD_FAILED.log run job=RUN_FD_FAILED yes wait messages @sleep 1 -@$out tmp/RUN_DIR_FAILED.log +@$out ${cwd}/tmp/RUN_DIR_FAILED.log run job=RUN_DIR_FAILED yes wait messages @sleep 1 -@$out tmp/RUN_FD_FAILED2.log +@$out ${cwd}/tmp/RUN_FD_FAILED2.log 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 - -bin/bacula start -cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf > /dev/null +run_bacula +check_for_zombie_jobs storage=File stop_bacula -export dstat=0 -export bstat=0 -export rstat=0 - -if grep -q 'dir: BeforeJob: run command "/bin/echo RunBeforeJob"' tmp/RUN_ALL_OK.log && - grep -q 'fd: ClientRunBeforeJob: ClientRunBeforeJob' tmp/RUN_ALL_OK.log && - grep -q 'fd: ClientAfterJob: run command "/bin/echo ClientRunAfterJob' tmp/RUN_ALL_OK.log && - grep -q 'dir: AfterJob: run command "/bin/echo RunAfterJob' tmp/RUN_ALL_OK.log +dstat=0 +bstat=0 +rstat=0 +export dstat +export bstat +export rstat + +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 +b=$? +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 +d=$? +grep 'ClientRunBefore1' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null && \ +grep 'ClientRunBefore2' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null && \ +grep 'ClientRunBefore3' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null +e=$? + +if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 ] then [ "$debug" = 1 ] && echo RUN_ALL_OK ok else echo "RUN_ALL_OK in error" - rstat=1 + bstat=1 fi -if grep -q 'dir: BeforeJob: run command "/bin/false RUN_DIR_FAILED"' tmp/RUN_DIR_FAILED.log && - grep -q 'dir: AfterJob: RunAfterFailedJob' tmp/RUN_DIR_FAILED.log && - true # grep -q 'Backup OK -- with warnings' tmp/RUN_DIR_FAILED.log +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 +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 -if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' tmp/RUN_FD_FAILED.log && - grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED.log && - grep -q 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' tmp/RUN_FD_FAILED.log && - grep -q '*** Backup Error ***' tmp/RUN_FD_FAILED.log +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 +b=$? +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 +d=$? +grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null +e=$? +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" - rstat=1 + echo "RUN_FD_FAILED in error a=$a b=$b c=$c d=$d e=$e f=$f" + bstat=1 fi -if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED1"' tmp/RUN_FD_FAILED2.log && - ! grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED2"' tmp/RUN_FD_FAILED2.log && - grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_FAILED3"' tmp/RUN_FD_FAILED2.log && - grep -q 'dir: AfterJob: run command "/bin/echo RunAfterFailedJob"' tmp/RUN_FD_FAILED2.log && - grep -q '*** Backup Error ***' tmp/RUN_FD_FAILED2.log - +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 +b=$? +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 +d=$? +grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null +e=$? +grep 'RUN_FD_FAILED4' ${cwd}/tmp/RUN_FD_FAILED2.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_FAILED2 in error" - rstat=1 + echo "RUN_FD_FAILED2 in error a=$a b=$b c=$d d=$d e=$e" + bstat=1 fi -if grep -q 'fd: ClientBeforeJob: run command "/bin/false RUN_FD_WARNING"' tmp/RUN_FD_WARNING.log && - ! grep -q 'RunAfterFailedJob' tmp/RUN_FD_WARNING.log && - grep -q 'Backup OK -- with warnings' tmp/RUN_FD_WARNING.log +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 +b=$? +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 \ No newline at end of file + +end_test