#!/bin/sh # # Test RunScript # TestName="runscript-test" JobName=backup . scripts/functions copy_test_confs rm -f bin/bacula-dir.conf 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" >${cwd}/tmp/file-list start_test cat <${cwd}/tmp/bconcmds @$out /dev/null messages label volume=TestVolume001 @$out ${cwd}/tmp/RUN_FD_WARNING.log run job=RUN_FD_WARNING yes wait messages @sleep 1 @$out ${cwd}/tmp/RUN_ALL_OK.log run job=RUN_ALL_OK yes wait messages @sleep 1 @$out ${cwd}/tmp/RUN_FD_FAILED.log run job=RUN_FD_FAILED yes wait messages @sleep 1 @$out ${cwd}/tmp/RUN_DIR_FAILED.log run job=RUN_DIR_FAILED yes wait messages @sleep 1 @$out ${cwd}/tmp/RUN_FD_FAILED2.log run job=RUN_FD_FAILED2 yes wait messages st dir quit END_OF_DATA run_bacula check_for_zombie_jobs storage=File stop_bacula 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 2>&1 a=$? grep 'ClientRunBeforeJob: ClientRunBeforeJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1 b=$? grep 'shell command: run ClientAfterJob "/bin/echo ClientRunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1 c=$? grep 'shell command: run AfterJob "/bin/echo RunAfterJob' ${cwd}/tmp/RUN_ALL_OK.log >/dev/null 2>&1 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 fi grep 'shell command: run BeforeJob "/bin/false RUN_DIR_FAILED"' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null 2>&1 a=$? grep 'AfterJob: RunAfterFailedJob' ${cwd}/tmp/RUN_DIR_FAILED.log >/dev/null 2>&1 b=$? if [ $a = 0 -a $b = 0 ] then [ "$debug" = 1 ] && echo RUN_DIR_FAILED ok else echo "RUN_DIR_FAILED in error" rstat=1 fi grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 a=$? grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 b=$? grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 c=$? grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 d=$? grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 e=$? grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null 2>&1 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 fi grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 a=$? grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 b=$? grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 c=$? grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 d=$? grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null 2>&1 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" rstat=1 fi grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_WARNING"' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1 a=$? grep 'RunAfterFailedJob' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1 b=$? grep 'Backup OK -- with warnings' ${cwd}/tmp/RUN_FD_WARNING.log >/dev/null 2>&1 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" rstat=1 fi end_test