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