]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/virtual-changer-test
Backport from BEE
[bacula/bacula] / regress / tests / virtual-changer-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory. Create three
4 #   tapes, each in a different pool, then run two jobs both of which
5 #   want the disk that is not loaded.  Note, they both have     
6 #   prefers non-mounted tapes.  This should expose bug #801
7 #
8 #  This test the SD Virtual autochanger feature.  It is a disk based
9 #    "autochanger", but does not use any changer script.
10 #
11 #  Note, because we limit each drive to a maximum of 3 jobs,
12 #  the first three start on Drive-0, and the second three start
13 #  on drive-1 (Prefer Mounted Volumes = no).  Thus since there
14 #  is only one Volume (TestVolume001) that is valid, three jobs
15 #  block and ask the user to create a new volume.  However, at some
16 #  point, the first three jobs finish and free up TestVolum001, and
17 #  Since we set a poll interval of 15 seconds, after a short wait
18 #  TestVolume001 will be mounted on drive-1 and the job will
19 #  complete.  This tests a good number of things.
20 #
21 TestName="virtual-changer-test"
22 JobName="virtualchangertest"
23 . scripts/functions
24
25 scripts/cleanup
26 scripts/copy-2disk-drive-confs
27 scripts/prepare-disk-changer
28
29 CLIENT=2drive2disk
30
31 echo "${cwd}/build" >${cwd}/tmp/file-list
32 #change_jobname Virtual $JobName
33 start_test
34
35 # Turn off Prefer Mounted Volumes so we use 2 drives
36 outf="${cwd}/tmp/sed_tmp"
37 echo "s%# Prefer Mounted Volumes%  Prefer Mounted Volumes%g" >${outf}
38 cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1
39 # Comment the next line out to write everything to one drive
40 #  otherwise, it writes the two jobs to different drives
41 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
42
43 # Write out bconsole commands
44 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
45 @$out /dev/null
46 messages
47 @$out ${cwd}/tmp/log1.out
48 setdebug level=200 storage=Virtual
49 @#setdebug level=200 client=$CLIENT 
50 label storage=Virtual volume=TestVolume001 slot=1 Pool=Default drive=0
51 label storage=Virtual volume=TestVolume002 slot=2 Pool=Full    drive=0
52 label storage=Virtual volume=TestVolume003 slot=3 Pool=Inc     drive=1
53 status storage=Virtual
54 run job=Virtual level=Full Pool=Default yes
55 run job=Virtual level=Full Pool=Default yes
56 run job=Virtual level=Full Pool=Default yes
57 run job=Virtual level=Full Pool=Default yes
58 run job=Virtual level=Full Pool=Default yes
59 @sleep 10
60 status storage=Virtual
61 list volumes
62 wait
63 list volumes
64 list jobs
65 status storage=Virtual
66 messages
67 quit
68 END_OF_DATA
69
70 # exit
71
72 run_bacula
73 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
74 @$out /dev/null
75 messages
76 @# 
77 @# now do a restore
78 @#
79 @$out ${cwd}/tmp/log2.out
80 restore where=${cwd}/tmp/bacula-restores select all storage=Virtual done
81 yes
82 wait
83 messages
84 quit
85 END_OF_DATA
86
87 run_bconsole
88
89 check_for_zombie_jobs storage=Virtual
90 stop_bacula
91
92 check_two_logs
93 check_restore_diff
94
95 end_test