3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # By setting VolUse duration small and switching Volume
7 # we create bad JobMedia records. EndBlock < StartBlock.
10 TestName="jobmedia-bug-test"
15 ${rscripts}/copy-test-confs
16 echo $tmp/big >${tmp}/file-list
17 echo $cwd/build/po >>${tmp}/file-list
19 dd if=/dev/zero of=$tmp/big seek=1000000 count=1 >/dev/null 2>&1
20 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "SpoolData", "No", "Job")'
21 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "ClientRunBeforeJob", "\"sleep 30\"", "Job", "NightlySave")'
22 $bperl -e 'add_attribute("$conf/bacula-sd.conf", "MaximumConcurrentJobs", "10", "Device")'
23 sed -i 's/sparse=yes;//' $conf/bacula-dir.conf
25 change_jobname NightlySave $JobName
28 cat <<END_OF_DATA >${tmp}/bconcmds
32 label storage=File volume=TestVolume000
33 label storage=File volume=TestVolume001
34 label storage=File volume=TestVolume002
35 @#setdebug level=150 storage
36 @# With VolUse=15s nothing restored for JobId 2
37 @#update volume=TestVolume000 VolUse=15s
38 @# With VolUse=20s both JobId 2 and 3 restore wrong size
39 update volume=TestVolume000 VolUse=20s
40 update volume=TestVolume001 maxvolbytes=100MB
42 select VolumeName, MediaId FROM Media;
44 run job=$JobName level=full yes
46 setbandwidth limit="5000 kb/s" client=$CLIENT
47 run job=$JobName level=full yes
48 run job=$JobName level=full yes
50 run job=$JobName level=full yes
56 setbandwidth limit=0 client=$CLIENT
60 select jobid, mediaid, firstindex,lastindex,volindex from JobMedia order by jobid,volindex;
61 select * from JobMedia order by jobid,volindex;
71 check_for_zombie_jobs storage=File
73 cat <<END_OF_DATA >${tmp}/bconcmds
75 @# now do a restore that will fail (JobId 2)
78 @#setdebug level=10 storage=File
79 @# Select by JobId to restore JobId 1
80 restore where=${tmp}/bacula-restores storage=File
88 @# Select by JobId to restore JobId 2
89 restore where=${tmp}/bacula-restores storage=File
97 @# Select by JobId to restore JobId 3
98 restore where=${tmp}/bacula-restores2 storage=File
107 @#status storage=File
113 check_for_zombie_jobs storage=File