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