]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/2drive-offline-test
Big backport from Enterprise
[bacula/bacula] / regress / tests / 2drive-offline-test
1 #!/bin/sh
2 #
3 # Set prefer mounted volumes to no to try to force use of
4 #   the drive swap code.
5 #
6 # This script uses the virtual disk autochanger and two drives
7 #
8 # It tests starting job 1, which will not complete because FD is
9 #   offline, then starting job 2, which wants to swap the volume.
10 #
11 TestName="2drive-offline"
12 JobName="2driveoffline"
13 . scripts/functions
14
15 scripts/cleanup
16 scripts/copy-2client-confs
17 scripts/prepare-disk-changer
18 CLIENT=2drive2disk
19
20 change_jobname NightlySave $JobName
21 start_test
22
23 echo "${cwd}/build" >${cwd}/tmp/file-list
24
25 # Turn off Prefer Mounted Volumes so we use 2 drives
26 outf="${cwd}/tmp/sed_tmp"
27 echo "s%# Prefer Mounted Volumes%  Prefer Mounted Volumes%g" >${outf}
28 cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1
29 # Comment the next line out to write everything to one drive
30 #  otherwise, it writes the two jobs to different drives
31 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
32
33 # One FD is not reachable, try to speed up the test
34 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "FdConnectTimeout", "10", "Director")'
35
36 # Write out bconsole commands
37 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
38 @$out /dev/null
39 messages
40 @$out ${cwd}/tmp/log1.out
41 label storage=tape volume=TestVolume001 slot=2 Pool=Default drive=0
42 label storage=tape volume=TestVolume002 slot=1 Pool=Default drive=1
43 status storage=tape
44 @#setdebug level=120 storage=tape
45 run job=Offline comment="This job will fail, the client is not here" level=Full yes
46 @sleep 2
47 run job=$JobName spooldata=no level=Full yes
48 status storage=tape
49 wait
50 list volumes
51 list jobs
52 messages
53 @$out ${cwd}/tmp/log3.out
54 @# TODO: We see that one volume is still reserved while the job is not here
55 status storage=tape
56 quit
57 END_OF_DATA
58
59 run_bacula
60
61 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
62 @$out /dev/null
63 messages
64 @# now do a restore
65 @#
66 @$out ${cwd}/tmp/log2.out
67 @#unmount storage=tape drive=0
68 @#unmount storage=tape drive=1
69 @#mount storage=tape slot=1 drive=0
70 @#mount storage=tape slot=2 drive=1
71 restore where=${cwd}/tmp/bacula-restores client=$HOST-fd select all storage=tape done
72 yes
73 wait
74 messages
75 quit
76 END_OF_DATA
77
78 run_bconsole
79 check_for_zombie_jobs storage=tape client=$HOST-fd
80 stop_bacula
81
82 grep 'Reserved volume: TestVolume002 on File device "Drive-0"' $tmp/log1.out
83 if [ $? -eq 0 ]; then
84     print_debug "ERROR: TestVolume001 should be used on Drive-0, not TestVolume002"
85     estat=1
86 fi
87
88 grep 'Reserved volume: TestVolume001 on File device "Drive-1"' $tmp/log1.out
89 if [ $? -eq 0 ]; then
90     print_debug "ERROR: TestVolume002 should be used on Drive-1, not TestVolume001"
91     estat=1
92 fi
93
94 grep 'No Jobs running.' $tmp/log3.out > /dev/null
95 if [ $? -eq 0 ]; then
96     grep 'Reserved volume: TestVolume001 on File device "Drive-0"' $tmp/log3.out
97     if [ $? -eq 0 ]; then
98         print_debug "WARNING: TestVolume001 is still reserved on Drive-0 in $tmp/log3.out"
99         #estat=1
100     fi
101 fi
102
103 check_restore_diff
104
105 end_test