1#!/bin/sh 2# 3# Do some tests with statistics commands 4# 5TestName="stats-test" 6JobName=backup 7. scripts/functions 8 9scripts/cleanup 10scripts/copy-confs 11 12# 13# Zap out any schedule in default conf file so that 14# it doesn't start during our test 15# 16outf="tmp/sed_tmp" 17echo "s% Schedule =%# Schedule =%g" > $outf 18echo "s% QueryFile%Statistics Retention = 1 sec; QueryFile%g" >> $outf 19cp ${cwd}/bin/bareos-dir.conf ${cwd}/tmp/1 20sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bareos-dir.conf 21 22change_jobname BackupClient1 $JobName 23start_test 24 25cat <<END_OF_DATA >${cwd}/tmp/bconcmds 26@$out /dev/null 27messages 28@$out ${cwd}/tmp/log1.out 29label volume=TestVolume001 storage=File pool=Full 30run job=$JobName yes 31wait 32messages 33update stats days=1 34sql 35SELECT 'FOUND' AS test FROM JobHisto; 36 37run job=$JobName yes 38wait 39messages 40@sleep 5 41@$out ${cwd}/tmp/log2.out 42update stats 43sql 44SELECT 'FOUND' AS test FROM JobHisto; 45 46list jobs 47prune stats yes 48@$out ${cwd}/tmp/log3.out 49sql 50SELECT 'FOUND' AS test FROM JobHisto; 51 52quit 53END_OF_DATA 54 55run_bareos 56 57dstat=0 58rstat=0 59bstat=0 60 61check_for_zombie_jobs storage=File 62stop_bareos 63 64 65COUNT=`grep FOUND ${cwd}/tmp/log1.out | wc -l` 66if [ $COUNT -ne 1 ]; then 67 print_debug "Bad count in JobHisto table" 68 bstat=1 69fi 70 71COUNT=`grep FOUND ${cwd}/tmp/log2.out | wc -l` 72if [ $COUNT -ne 3 ]; then 73 print_debug "Bad count in JobHisto table" 74 bstat=2 75fi 76 77COUNT=`grep FOUND ${cwd}/tmp/log3.out | wc -l` 78if [ $COUNT -ne 1 ]; then 79 print_debug "Bad count in JobHisto table" 80 bstat=3 81fi 82 83end_test 84