1#!/bin/sh 2# 3# Test MaxWaitTime, MaxRunTime and MaxStartDelay 4# 5 6TestName="maxtime-test" 7JobName=backup 8 9. scripts/functions 10 11copy_test_confs 12 13cp -f ${cwd}/scripts/bareos-dir.conf.maxtime ${conf}/bareos-dir.conf 14WHEN=`date '+%Y-%m-%d %H:%M:%S'` 15 16# Directory to backup. 17# This directory will be created by setup_data(). 18BackupDirectory="${tmp}/data" 19 20# Use a tgz to setup data to be backuped. 21# Data will be placed at "${tmp}/data/". 22setup_data data/small.tgz 23 24# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list". 25echo "${BackupDirectory}" >${tmp}/file-list 26 27 28start_test 29 30cat <<END_OF_DATA >${cwd}/tmp/bconcmds 31@$out /dev/null 32messages 33@$out ${cwd}/tmp/log1.out 34label volume=TestVolume001 pool=PoolA 35@$out ${cwd}/tmp/RUN_MAXTIME.log 36@# no media => have to wait (MaxWaitTime=30sec) 37run job=RUN_MAXWAITTIME comment="Should fail" pool=Default yes 38@sleep 2 39@# storage is used by RUN_MAXWAITTIME => have to wait 40run job=RUN_MAXSTARTDELAY comment="Should fail" pool=PoolA when="$WHEN" yes 41@sleep 2 42@# storage is used by the first MAXWAITTIME, but should work 43run job=RUN_MAXWAITTIME comment="Should work" pool=PoolA yes 44@sleep 120 45label volume=TestVolume002 pool=Default 46mount 47@sleep 2 48mount 49wait 50messages 51run job=RUN_MAXRUNTIME comment="Should fail" pool=PoolA yes 52wait 53messages 54st dir 55quit 56END_OF_DATA 57 58mkfifo ${tmp}/fifo1 59mkfifo ${tmp}/fifo2 60mkfifo ${tmp}/fifo3 61 62run_bareos 63check_for_zombie_jobs storage=File 64stop_bareos 65 66dstat=0 67bstat=0 68rstat=0 69touch ${cwd}/tmp/log2.out 70 71grep -e '1: Fatal error: Max wait time exceeded. Job canceled.' ${cwd}/tmp/RUN_MAXTIME.log >/dev/null 72if [ $? -eq 0 ]; then 73 print_debug "MAXWAITTIME ok" 74else 75 echo "MAXWAITTIME in error" 76 bstat=1 77fi 78 79grep -e '2: Fatal error: Job canceled because max start delay time exceeded.' ${cwd}/tmp/RUN_MAXTIME.log > /dev/null 80f=$? 81 82grep -e 'NEVER start this' ${cwd}/tmp/RUN_MAXTIME.log >/dev/null 83s=$? 84 85if [ $f -eq 0 -a $s -ne 0 ]; then 86 print_debug "MAXSTARTDELAY ok" 87else 88 echo "MAXSTARTDELAY in error" 89 bstat=1 90fi 91 92grep -e '4: Fatal error: Max run time exceeded. Job canceled.' ${cwd}/tmp/RUN_MAXTIME.log >/dev/null 93if [ $? -eq 0 ]; then 94 print_debug "MAXRUNTIME ok" 95else 96 echo "MAXRUNTIME in error" 97 bstat=1 98fi 99 100grep 'Termination: *Backup OK' ${cwd}/tmp/RUN_MAXTIME.log >/dev/null 101if [ $? -eq 0 ]; then 102 print_debug "MAXRUNTIME2 ok" 103else 104 echo "MAXRUNTIME2 in error" 105 bstat=1 106fi 107 108end_test 109