]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/broken-media-bug-2-test
Backport from Bacula Enterprise
[bacula/bacula] / regress / tests / broken-media-bug-2-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # Show the broken media bug(s) again. Test by Graham Keeling.
9 #
10 # This test will wait forever whilst the last job waits for an appendable
11 # volume.
12 # You can run ./bin/bconsole -c bin/bconsole.conf from within the regress
13 # directory, and use 'list media' to see where the volumes have ended up, as
14 # well as any other commands you like.
15 #
16 # The problem(s):
17 # - Write two jobs to two different volumes.
18 # - Purge them manually. The two volumes end up in the Scratch pool.
19 # - Start a large job. It takes a volume from the Scratch pool, places it
20 #   in its own pool and starts writing to it.
21 # - While the first job is still running, start a second job.
22 # - A sort of chaos then follows.
23 #   The second job sees that there are no JobMedia records associated with the 
24 #   first volume (which is in a separate pool), and purges it, moving it
25 #   through Scratch and into its own pool. It then decides not to use that
26 #   volume and hangs around 'waiting for an appendable Volume' - even though
27 #   there is the other purged volume sitting untouched in the Scratch pool.
28 #   Meanwhile, the first job finishes and sets the volume status of its volume
29 #   (that is now in the wrong pool) to 'Used'.
30
31 TestName="broken-media-bug-2-test"
32 . scripts/functions
33
34 cwd=`pwd`
35 scripts/cleanup
36 /bin/cp -f scripts/broken-media-bug-2-bacula-dir.conf bin/bacula-dir.conf
37 /bin/cp -f scripts/broken-media-bug-2-bacula-sd.conf bin/bacula-sd.conf
38 /bin/cp -f scripts/test-bacula-fd.conf bin/bacula-fd.conf
39 /bin/cp -f scripts/test-console.conf bin/bconsole.conf
40 hugefile=${cwd}/build/hugefile
41 hugefilesize=300
42 echo "${cwd}/build" >${cwd}/tmp/file-list
43
44 start_test
45
46 echo "Creating huge ${hugefilesize}M file..."
47 dd if=/dev/urandom of="$hugefile" bs=1M count="$hugefilesize"
48 echo "Done"
49
50 cat >tmp/bconcmds <<END_OF_DATA
51 @$out /dev/null
52 messages
53 @$out tmp/log1.out
54 setdebug level=150  storage=File
55 setdebug level=150  Director
56 label storage=File volume=TestVolume0001 pool=Scratch
57 label storage=File volume=TestVolume0002 pool=Scratch
58 list media
59 llist media
60 run job=Second yes
61 wait
62 run job=Second yes
63 wait
64 list media
65 llist media
66 purge volume
67 3
68 1
69 purge volume
70 3
71 2
72 list media
73 llist media
74 messages
75 run job=First yes
76 messages
77 quit
78 END_OF_DATA
79
80 run_bacula
81
82 # Give the first job a bit of time to get going.
83 sleep 5
84
85 cat >tmp/bconcmds <<END_OF_DATA
86 setdebug level=150  storage=File
87 setdebug level=150  Director
88 list media
89 llist media
90 messages
91 @$out tmp/log2.out
92 run job=Second yes
93 wait
94 messages
95 restore fileset=Set1 where=${cwd}/tmp/bacula-restores select all storage=File done
96 yes
97 wait
98 list media
99 llist media
100 messages
101 quit
102 END_OF_DATA
103
104 run_bconsole
105 check_for_zombie_jobs storage=File
106 stop_bacula
107
108 check_two_logs
109 check_restore_diff
110 rm -f "$hugefile"
111 end_test