]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/copy-swap-fail-test
Pull regression truncate-test from Branch-9.1
[bacula/bacula] / regress / tests / copy-swap-fail-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # Run backups with dummy tape driver
7 # This test setups an Autochanger with 80 slots
8 # and 5 drives (5 LTO3)
9 #
10
11
12 TestName="copy-swap-fail-test"
13 JobName=backup
14 . scripts/functions
15
16 require_vtape
17
18 scripts/cleanup
19 scripts/copy-tape-confs
20 cp $rscripts/bacula-dir-vtape.conf $conf/bacula-dir.conf
21 sed 's/LTO1/LTO3/g' $rscripts/bacula-sd-vtape.conf > $conf/bacula-sd.conf
22 scripts/prepare-fake-autochanger
23
24 echo "${cwd}/build" >${cwd}/tmp/file-list
25
26 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum Concurrent Jobs", "1", "Device")'
27 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum Volume Size", "100MB", "Device")'
28 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "LabelMedia", "Yes", "Device", "FileStorage")'
29
30 $bperl -e 'add_attribute("$conf/bacula-fd.conf", "MaximumBandwidthPerJob", "1200Kb/s", "FileDaemon")'
31
32 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Label Format",        "TestVolume", "Pool", "Full")'
33 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Maximum Volume Jobs", "1",    "Pool")'
34 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "SpoolData",           "no",   "Job")'
35 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "NextPool",            "Full", "Pool", "Inc")'
36 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Storage",             "File", "Pool", "Full")'
37
38 cat <<EOF >> $conf/bacula-dir.conf
39 Job {
40   Name = "copy-job"
41   Type = Copy
42   Level = Full
43   Client=${HOST}-fd
44   FileSet="Full Set"
45   Messages = Standard
46   Storage = LTO3
47   Write Bootstrap = "$working/migratejob.bsr"
48   Pool = Default
49   Maximum Concurrent Jobs = 4
50   Selection Type = Job
51   Selection Pattern = ".*Save.*"
52 # Allow Duplicate Jobs = No
53 }
54 EOF
55
56 perl -Mscripts::functions -e "extract_resource('$conf/bacula-dir.conf', 'Job', 'NightlySave')" > $tmp/1
57 cat $tmp/1 | sed s/NightlySave/NightlySave4/ >> $conf/bacula-dir.conf
58 cat $tmp/1 | sed s/NightlySave/NightlySave5/ >> $conf/bacula-dir.conf
59 cat $tmp/1 | sed s/NightlySave/NightlySave6/ >> $conf/bacula-dir.conf
60 cat $tmp/1 | sed s/NightlySave/NightlySave7/ >> $conf/bacula-dir.conf
61 cat $tmp/1 | sed s/NightlySave/NightlySave8/ >> $conf/bacula-dir.conf
62 cat $tmp/1 | sed s/NightlySave/NightlySave9/ >> $conf/bacula-dir.conf
63 cat $tmp/1 | sed s/NightlySave/NightlySave10/ >> $conf/bacula-dir.conf
64
65 start_test
66
67 clientname=`awk '/Name = .*-fd/ { if (!ok) { print $3 ; ok=1 } }' bin/bacula-dir.conf`
68
69 when1=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+20))"`
70 when2=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+35))"`
71 when3=`perl -MPOSIX -e "print strftime('%F %T', localtime(time+50))"`
72
73 # Catalog record for cleaning tape "CLN01" successfully created.
74 # CLN01      | Cleaning
75
76 # Write out bconsole commands
77 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
78 @output /dev/null
79 messages
80 @$out ${cwd}/tmp/log6.out
81 @#setdebug level=200 storage=LTO1
82 label barcodes pool=Scratch slots=1-10 storage=LTO3 drive=0
83 yes
84 messages
85 list volumes
86 END_OF_DATA
87
88 run_bacula
89
90 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
91 @$out ${cwd}/tmp/log1.out
92 setdebug trace=1 level=200 storage=LTO3
93 mount storage=LTO3_2 slot=60 drive=2
94 run storage=LTO3 when="$when1" job=NightlySave   pool=Inc     yes
95 run storage=LTO3 when="$when2" job=NightlySave2  pool=Inc     yes
96 run storage=LTO3 when="$when3" job=NightlySave3  pool=Inc     yes
97 wait jobid=1
98 status storage=LTO3
99 messages
100 run storage=LTO3_2  job=copy-job jobid=1 pool=Inc yes
101 wait jobid=2
102 messages
103 run storage=LTO3_2  job=copy-job jobid=2 pool=Inc yes
104 wait jobid=3
105 messages
106 run storage=LTO3_2  job=copy-job jobid=3 pool=Inc yes
107 wait
108 messages
109 quit
110 END_OF_DATA
111
112 run_bconsole
113 check_for_zombie_jobs storage=LTO3 client=$clientname
114
115 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
116 setdebug trace=1 level=0 storage=LTO3
117 @$out ${cwd}/tmp/log2.out  
118 @# 
119 @# now do a restore
120 @#
121 restore client=$clientname fileset="Full Set" where=${cwd}/tmp/bacula-restores select all done
122 yes
123 wait
124 messages
125 END_OF_DATA
126
127 run_bconsole
128 check_for_zombie_jobs storage=LTO3 client=$clientname
129
130 stop_bacula
131
132 check_two_logs
133 check_restore_diff
134 perl -ne '
135 # foreach Job, we store the drive and we count the total
136 # job number per drive
137 m/(\d+): Using Device "(.+?)"/ 
138   and $drive_info[$i++]="$1 $2" and $drive{$2}++;
139
140 END {
141  $err=0;
142  foreach $k (sort keys %drive) { 
143     if ($drive{$k} > 3) {
144        print "ERR $k has more than 3 jobs ($drive{$k})\n";
145        $err++;
146     }
147  }
148  if ($err) {
149     foreach $k (@drive_info) { print "$k\n"}
150     exit 1;
151  }
152 }
153 ' $tmp/log1.out
154
155 if [ $? -ne 0 ]; then
156     print_debug "ERR: Problem during log analysis"
157     estat=1
158 fi
159 end_test