]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/pool-attributes-test
Big backport from Enterprise
[bacula/bacula] / regress / tests / pool-attributes-test
1 #!/bin/sh
2 #
3 # See if Pool/Media attributes are correctly handled
4 #
5 TestName="pool-attributes-test"
6 JobName=backup
7 . scripts/functions
8
9 scripts/cleanup
10 scripts/copy-confs
11
12 #
13 # Zap out any schedule in default conf file so that
14 #  it doesn't start during our test
15 #
16 outf="$tmp/sed_tmp"
17 echo "s%  Schedule =%# Schedule =%g" >${outf}
18 cp $scripts/bacula-dir.conf $tmp/1
19 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
20
21 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'CacheRetention', '10', 'Pool', 'File')"
22 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'CacheRetention', '20', 'Pool', 'Default')"
23
24 change_jobname BackupClient1 $JobName
25 start_test
26
27 cat <<END_OF_DATA >$tmp/bconcmds
28 @output /dev/null
29 messages
30 @$out $tmp/log1.out
31 setdebug level=4 storage=File1
32 label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
33 label volume=TestVolume002 storage=File1 pool=Default slot=1 drive=0
34 @$out $tmp/01.log
35 llist volume=TestVolume001
36 @$out $tmp/02.log
37 llist volume=TestVolume002
38 quit
39 END_OF_DATA
40
41 run_bacula
42
43 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'CacheRetention', '30', 'Pool', 'File')"
44 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'CacheRetention', '40', 'Pool', 'Default')"
45 $bperl -e "add_attribute('$conf/bacula-sd.conf', 'AutoLabel', 'yes', 'Device')"
46
47
48 cat <<END_OF_DATA >$tmp/bconcmds
49 @$out $tmp/log1.out
50 reload
51 update pool=File
52 update pool=Default
53 update allfrompool=File volume
54 update allfrompool=Default volume
55 @$out $tmp/11.log
56 llist volume=TestVolume001
57 @$out $tmp/22.log
58 llist volume=TestVolume002
59 @$out $tmp/log1.out
60 @# Check volumes from Scratch
61 delete volume=TestVolume001 yes
62 update volume=TestVolume002 pool=Scratch cacheretention=0
63 run job=$JobName yes
64 wait
65 messages
66 @$out $tmp/31.log
67 llist volume=TestVolume001
68 @$out $tmp/32.log
69 llist volume=TestVolume002
70 @# Delete all volumes and check autolabel
71 @$out $tmp/log1.out
72 delete volume=TestVolume002 yes
73 run job=$JobName yes
74 wait
75 messages
76 @$out $tmp/41.log
77 llist volume
78 @$out $tmp/42.log
79 llist volume pool=File
80 quit
81 END_OF_DATA
82
83 run_bconsole
84
85 stop_bacula
86
87 check_cacheretention()
88 {
89     FILE=$1
90     VAL=$2
91     MSG=$3
92     HAVE=`cat $FILE | tr 'A-Z' 'a-z' | awk '/cacheretention/ { print $2 }'`
93     if [ "$VAL" -ne "$HAVE" ]; then
94         print_debug "ERROR: Expect CacheRetention $VAL in $FILE, got $HAVE. $MSG"
95         estat=1
96     fi
97 }
98
99 check_cacheretention $tmp/01.log 10 "Check cacheretention with label command"
100 check_cacheretention $tmp/02.log 20 "Check cacheretention with label command"
101 check_cacheretention $tmp/11.log 30 "Check cacheretention with update frompool command"
102 check_cacheretention $tmp/22.log 40 "Check cacheretention with update frompool command"
103 check_cacheretention $tmp/32.log 30 "Check cacheretention that when we pull a volume from the scratch"
104 check_cacheretention $tmp/41.log 30 "Check cacheretention when we create a volume"
105 check_cacheretention $tmp/42.log 30 "Check cacheretention with pool= parameter"
106
107
108
109 end_test