]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/jobmedia-bug-test
regress: enhance btape-test to detect NOT correct message
[bacula/bacula] / regress / tests / jobmedia-bug-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # By setting VolUse duration small and switching Volume
7 #  we create bad JobMedia records.  EndBlock < StartBlock.
8 #
9 #
10 TestName="jobmedia-bug-test"
11 JobName=jobmedia-bug
12 . scripts/functions
13
14 ${rscripts}/cleanup
15 ${rscripts}/copy-test-confs
16 echo $tmp/big >${tmp}/file-list
17 echo $cwd/build/po >>${tmp}/file-list
18
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
24
25 change_jobname NightlySave $JobName
26 start_test
27
28 cat <<END_OF_DATA >${tmp}/bconcmds
29 @output /dev/null
30 messages
31 @$out ${tmp}/log1.out
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
41 sql
42 select VolumeName, MediaId FROM Media;
43
44 run job=$JobName level=full yes
45 @sleep 15
46 setbandwidth limit="5000 kb/s" client=$CLIENT
47 run job=$JobName level=full yes
48 run job=$JobName level=full yes
49 @sleep 20
50 run job=$JobName level=full yes
51 @sleep 10
52 @#status client
53 @#status dir
54 @#status storage
55 @sleep 10
56 setbandwidth limit=0 client=$CLIENT
57 wait
58 messages
59 sql
60 select jobid, mediaid, firstindex,lastindex,volindex from JobMedia order by jobid,volindex;
61 select * from JobMedia order by jobid,volindex;
62
63 @$out $tmp/jobmedia2
64 list jobmedia jobid=2
65 @$out $tmp/jobmedia3
66 list jobmedia jobid=3
67 quit
68 END_OF_DATA
69
70 run_bacula
71 check_for_zombie_jobs storage=File
72
73 cat <<END_OF_DATA >${tmp}/bconcmds
74 @# 
75 @# now do a restore that will fail (JobId 2)
76 @#
77 @$out ${tmp}/log2.out
78 @#setdebug level=10 storage=File
79 @# Select by JobId to restore JobId 1
80 restore where=${tmp}/bacula-restores storage=File
81 3
82 1
83 cd $tmp
84 m big
85 done
86 yes
87 wait
88 @# Select by JobId to restore JobId 2
89 restore where=${tmp}/bacula-restores storage=File
90 3
91 2
92 cd $tmp
93 m big
94 done
95 yes
96 wait
97 @# Select by JobId to restore JobId 3
98 restore where=${tmp}/bacula-restores2 storage=File
99 3
100 3
101 cd $tmp
102 m big
103 done
104 yes
105 wait
106 @#status client
107 @#status storage=File
108 messages
109 quit
110 END_OF_DATA
111
112 run_bconsole
113 check_for_zombie_jobs storage=File
114 stop_bacula
115
116 check_two_logs
117 end_test