]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/two-vol-manual-tape
Update
[bacula/bacula] / regress / tests / two-vol-manual-tape
1 #!/bin/sh
2 #
3 # Run a job with a limited tape size so that the tape fills up.
4 #  Then manually unload the tape and load a new one, label
5 #  it.
6 #
7 TestName="two-vol-manual-tape"
8 JobName=twovolmanualtape
9 . scripts/functions
10
11 require_tape_drive
12 require_autochanger
13
14 scripts/cleanup
15 scripts/copy-tape-confs
16 echo "${cwd}/build" >${cwd}/tmp/file-list
17
18 # Get a tape in the drive either from slot 1 or slot 2
19 slot=`bin/mtx-changer ${AUTOCHANGER} loaded 0 ${TAPE_DRIVE} $DRIVE1`
20 case $slot in
21  0)
22     bin/mtx-changer ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
23     slot=$SLOT1
24     ;;
25  $SLOT1)
26     slot=$SLOT1
27     ;;
28  $SLOT2)
29     slot=$SLOT2
30     ;;
31  default)
32     mt -f ${TAPE_DRIVE} rewind                
33     bin/mtx-changer ${AUTOCHANGER} unload $slot ${TAPE_DRIVE} $DRIVE1
34     bin/mtx-changer ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
35     slot=$SLOT1
36     ;;
37 esac
38 mt -f ${TAPE_DRIVE} rewind
39 mt -f ${TAPE_DRIVE} weof
40
41
42 change_jobname $JobName
43 start_test
44
45 # Write out bconsole commands
46 cat <<END_OF_DATA >tmp/bconcmds
47 @out /dev/null
48 messages
49 @$out tmp/log1.out
50 label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default drive=0
51 update Volume=TestVolume001 MaxVolBytes=4000000 pool=Default drive=0
52 sql                               
53 select * from Storage;
54 select VolumeName,InChanger,StorageId from Media;
55
56 @#setdebug level=150 storage=DDS-4
57 run job=$JobName yes
58 @# This sleep must be long enough for the first tape to fill (4MB)
59 @#  otherwise the following mtx-changer commands will fail
60 @sleep 80
61 sql                               
62 select * from Storage;
63 select VolumeName,InChanger,StorageId from Media;
64
65 unmount storage=DDS-4
66 list volumes
67 status storage=DDS-4
68 messages
69 quit
70 END_OF_DATA
71
72 run_bacula
73
74 # load the other slot
75 mt -f ${TAPE_DRIVE} rewind
76 case $slot in
77  $SLOT1)
78     bin/mtx-changer ${AUTOCHANGER} unload $slot ${TAPE_DRIVE} $DRIVE1
79     bin/mtx-changer ${AUTOCHANGER} load $SLOT2 ${TAPE_DRIVE} $DRIVE1
80     ;;
81  $SLOT2)
82     bin/mtx-changer ${AUTOCHANGER} unload $slot ${TAPE_DRIVE} $DRIVE1
83     bin/mtx-changer ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
84     ;;
85  default)
86     echo "Something went wrong. Expected $SLOT1 or $SLOT2, got $slot"
87     exit 1
88 esac
89
90 mt -f ${TAPE_DRIVE} rewind
91 mt -f ${TAPE_DRIVE} weof
92
93 # second half of job -- write on next tape
94 cat <<END_OF_DATA >tmp/bconcmds
95 @$out tmp/log1.out
96 label storage=DDS-4 volume=TestVolume002 slot=0 pool=Default drive=0
97 mount storage=DDS-4
98 @# 
99 @# now do a restore
100 @#
101 @#restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
102 @#yes
103 wait
104 list volumes
105 messages
106 @$out
107 quit
108 END_OF_DATA
109
110 # run second half
111 run_bconsole
112
113 touch tmp/log2.out
114  
115 check_for_zombie_jobs storage=DDS-4
116 stop_bacula
117
118 check_two_logs
119 #check_restore_diff
120 dstat=0   # no diff
121 rstat=0   # no restore
122 end_test