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