]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/two-vol-manual-tape
b7477f73ced1ab783cec7a90a706f26abbd4adfa
[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 MTX=$AUTOCHANGER_SCRIPT
18
19 init_slot $TAPE_DRIVE $SLOT1
20 init_slot $TAPE_DRIVE $SLOT2
21
22 # Get a tape in the drive either from slot 1 or slot 2
23 slot=`bin/$MTX ${AUTOCHANGER} loaded 0 ${TAPE_DRIVE} $DRIVE1`
24 case $slot in
25  0)
26     bin/$MTX ${AUTOCHANGER} load $SLOT1 ${TAPE_DRIVE} $DRIVE1
27     slot=$SLOT1
28     ;;
29  $SLOT1)
30     slot=$SLOT1
31     ;;
32  $SLOT2)
33     slot=$SLOT2
34     ;;
35  *)
36     bin/$MTX ${AUTOCHANGER} unload $slot  ${TAPE_DRIVE} $DRIVE1
37     bin/$MTX ${AUTOCHANGER} load   $SLOT1 ${TAPE_DRIVE} $DRIVE1
38     slot=$SLOT1
39     ;;
40 esac
41
42 init_drive ${TAPE_DRIVE}
43
44 change_jobname $JobName
45 start_test
46
47 # Write out bconsole commands
48 cat <<END_OF_DATA >tmp/bconcmds
49 @out /dev/null
50 messages
51 @$out tmp/log1.out
52 label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default drive=0
53 update Volume=TestVolume001 MaxVolBytes=4000000 pool=Default drive=0
54 sql                               
55 select * from Storage;
56 select VolumeName,InChanger,StorageId from Media;
57
58 @#setdebug level=150 storage=DDS-4
59 run job=$JobName yes
60 @# This sleep must be long enough for the first tape to fill (4MB)
61 @#  otherwise the following mtx-changer commands will fail
62 @sleep 80
63 sql                               
64 select * from Storage;
65 select VolumeName,InChanger,StorageId from Media;
66
67 unmount storage=DDS-4
68 list volumes
69 status storage=DDS-4
70 messages
71 quit
72 END_OF_DATA
73
74 run_bacula
75
76 # load the other slot
77 case $slot in
78  $SLOT1)
79     bin/$MTX ${AUTOCHANGER} unload $slot  ${TAPE_DRIVE} $DRIVE1
80     bin/$MTX ${AUTOCHANGER} load   $SLOT2 ${TAPE_DRIVE} $DRIVE1
81     ;;
82  $SLOT2)
83     bin/$MTX ${AUTOCHANGER} unload $slot  ${TAPE_DRIVE} $DRIVE1
84     bin/$MTX ${AUTOCHANGER} load   $SLOT1 ${TAPE_DRIVE} $DRIVE1
85     ;;
86  *)
87     echo "Something went wrong. Expected $SLOT1 or $SLOT2, got $slot"
88     exit 1
89 esac
90
91 init_drive ${TAPE_DRIVE}
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