1#!/bin/sh 2 3. scripts/functions 4 5# 6# Run a backup of generated data and check if the soft quota limits are respected 7# 8# 9TestName="quota-softquota-test" 10 11# set other test specific variables 12Client=bareos-fd 13JobName=backup-bareos-fd 14 15check_backup() 16{ 17 jobid=$1 18 if grep "^ Termination: *Backup OK" ${tmp}/log${jobid}.out 2>&1 >/dev/null; then 19 print_debug "jobid ${jobid}: Backup OK => OK" 20 else 21 print_debug "jobid ${jobid}: Backup failed => NOK" 22 estat=${jobid} 23 fi 24 return $estat 25} 26 27scripts/cleanup 28 29# Config files will be copied to required location. 30# Base configuration files come from the 31# configs/BASE/ directory, see 32# configs/BASE/README.txt for an overview of the provides resources. 33# Store your additonal resources to 34# configs/$TestName. 35# It is also possible to overwrite resources from configs/BASE. 36# If you define a full config file (instead of config files for individual resources), 37# only these will be taken. 38copy_configs 39 40# create test data 41MEGABYTE=1000000 42dd if=/dev/zero of=${cwd}/tmp/testdata bs=$MEGABYTE count=10 >/dev/null 43 44echo "${cwd}/tmp/testdata" >${cwd}/tmp/file-list 45start_test 46 47# 48# we store each job to log${jobid}.out 49# 50# verify logs by: 51# grep -E -i '(quota|grace)' tmp/log*.out 52 53cat >${cwd}/tmp/bconcmds <<END_OF_DATA 54messages 55label storage=File1 pool=Default volume=TestVolume001 56 57 58 59@$out ${cwd}/tmp/log1.out 60@# 1: backup data less than the Soft Quota => ok - 10MB 61 62run job=$JobName Level=Full yes 63wait 64messages 65 66 67 68@$out ${cwd}/tmp/log2.out 69@# 2: backup data less than the Soft Quota => ok - 20MB 70 71run job=$JobName Level=Full yes 72wait 73messages 74 75 76 77@$out ${cwd}/tmp/log3.out 78@# 3: backup data. "Quota Used" > "Soft Quota" => ok - 30MB ("Soft Quota exceeded, Grace Period starts now.") 79 80run job=$JobName Level=Full yes 81wait 82messages 83 84 85 86@$out ${cwd}/tmp/log4.out 87@# 4: backup data. job notices that quota is exceeded but continues => ok - 40MB ("Soft Quota exceeded, will be enforced after Grace Period expires.") 88 89run job=$JobName Level=Full yes 90wait 91messages 92 93 94 95@$out ${cwd}/tmp/log5.out 96@# 5: wait till the grace time is over. 97@# backup data outside the grace time => fail - 40MB 98 99@sleep 15 100 101run job=$JobName Level=Full yes 102wait 103messages 104 105 106 107@$out ${cwd}/tmp/log6.out 108@# 6: delete jobs, so that "Quota Used" < "Soft Quota", 109@# backup data => ok - 20MB 110 111delete job jobid=1 yes 112delete job jobid=2 yes 113delete job jobid=3 yes 114 115run job=$JobName Level=Full yes 116wait 117messages 118 119END_OF_DATA 120 121run_bareos 122check_for_zombie_jobs storage=File1 123stop_bareos 124 125# check if backup run successful 126check_backup 1 127check_backup 2 128 129# check if job gets a over quota warning 130check_backup 3 131jobid=3 132if grep -i "Soft Quota exceeded," ${tmp}/log${jobid}.out 2>&1 >/dev/null; then 133 print_debug "jobid ${jobid}: Soft Quota exceeded => OK" 134else 135 print_debug "jobid ${jobid}: no 'Soft Quota exceeded' message found => NOK" 136 estat=${jobid} 137fi 138 139check_backup 4 140jobid=4 141if grep -i "Soft Quota exceeded," ${tmp}/log${jobid}.out 2>&1 >/dev/null; then 142 print_debug "jobid ${jobid}: Soft Quota exceeded => OK" 143else 144 print_debug "jobid ${jobid}: no 'Soft Quota exceeded' message found => NOK" 145 estat=${jobid} 146fi 147 148# check if job is gets the Grace Time expired and Over Quota warning 149jobid=5 150if grep -i "Fatal error: Soft Quota exceeded / Grace Time expired" ${tmp}/log${jobid}.out 2>&1 >/dev/null; then 151 print_debug "jobid ${jobid}: Soft Quota exceeded and Grace Time expired => OK" 152else 153 print_debug "jobid ${jobid}: no 'Soft Quota exceeded' message found => NOK" 154 estat=${jobid} 155fi 156# check if job is canceled as expected (some job as previous test) 157if grep -i "^ Termination: .*Backup Error" ${tmp}/log${jobid}.out 2>&1 >/dev/null; then 158 print_debug "jobid ${jobid}: Backup failed (quota exceeded) => OK" 159else 160 print_debug "jobid ${jobid}: no 'Backup Error' message found => NOK" 161 estat=${jobid} 162fi 163 164# check if job is successful 165check_backup 6 166jobid=6 167if grep -i "Soft Quota reset" ${tmp}/log${jobid}.out 2>&1 >/dev/null; then 168 print_debug "jobid ${jobid}: Soft Quota reset => OK" 169else 170 print_debug "jobid ${jobid}: no 'Soft Quota reset' message found => NOK" 171 estat=${jobid} 172fi 173 174end_test 175