]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/cancel-multiple-test
fix #3269 obey the user choice of "Are you sure you want to delete X JobIds
[bacula/bacula] / regress / tests / cancel-multiple-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # Run four concurrent jobs and then cancel 2 of them
9 #
10
11 TestName="cancel-multiple-jobs-test"
12 JobName=concurrent-jobs
13 . scripts/functions
14
15 copy_test_confs
16
17 echo "${cwd}/tmp/largefile" >${cwd}/tmp/file-list
18 if test -c /dev/urandom ; then
19 # Create 56MB file with random data
20 #  echo "Creating a 56MB file with random data ..."
21    dd if=/dev/urandom of=${cwd}/tmp/largefile bs=1024 count=55000 2>&1 1>/dev/null
22 else
23 #  echo "Creating a 56MB file with bacula-dir data ..."
24    dd if=$bin/bacula-dir of=${cwd}/tmp/1 bs=1024 count=1000 2>&1 1>/dev/null
25    cat ${cwd}/tmp/1 ${cwd}/tmp/1 ${cwd}/tmp/1 ${cwd}/tmp/1 ${cwd}/tmp/1 >${cwd}/tmp/2
26    rm -f ${cwd}/tmp/1
27    cat ${cwd}/tmp/2 ${cwd}/tmp/2 ${cwd}/tmp/2 ${cwd}/tmp/2 ${cwd}/tmp/2 >>${cwd}/tmp/3
28    rm -f ${cwd}/tmp/2
29    cat ${cwd}/tmp/3 ${cwd}/tmp/3 ${cwd}/tmp/3 ${cwd}/tmp/3 ${cwd}/tmp/3 >${cwd}/tmp/largefile
30    rm -f ${cwd}/tmp/3
31 fi 
32
33 #echo "largefile created"
34
35 # Add some jobs and fileset for this test
36 cat <<EOF >>${cwd}/bin/bacula-dir.conf
37 JobDefs {
38   Name = "DefaultJob"
39   Type = Backup
40   Client=${HOST}-fd 
41   FileSet="Full Set"
42   Storage = File
43   Messages = Standard
44   Pool = Default
45   Maximum Concurrent Jobs = 10
46   SpoolData=yes
47   Max Run Time = 30min
48   Reschedule On Error = no
49   Reschedule Interval = 10
50   Reschedule Times = 1
51 }
52 Job {
53   Name = RUN4
54   ClientRunBeforeJob="sleep 20"
55   RunScript {
56     Command = "sleep 20"
57     RunsWhen = After
58   }
59   JobDefs = DefaultJob
60 }
61 EOF
62
63
64 change_jobname CompressedTest $JobName
65 start_test
66      
67 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
68 @$out /dev/null
69 messages
70 @$out  ${cwd}/tmp/log1.out
71 label storage=File volume=TestVolume001
72 run job=RUN4 level=Full yes
73 run job=RUN4 level=Full yes
74 run job=RUN4 level=Full yes
75 run job=RUN4 level=Full yes
76 cancel
77 1,3
78 yes
79 wait
80 messages
81 @# 
82 @# now do a restore
83 @#
84 @$out   ${cwd}/tmp/log2.out
85 restore where=${cwd}/tmp/bacula-restores select storage=File
86 unmark *
87 mark *
88 done
89 yes
90 wait
91 messages
92 @$out $tmp/log3.out
93 run job=RUN4 level=Full yes
94 @# it will cancel the jobid 6 even if jobid 1 is requested
95 cancel jobid=1 yes
96 wait
97 messages
98 quit
99 END_OF_DATA
100
101 run_bacula
102 check_for_zombie_jobs storage=File
103 stop_bacula
104
105 check_two_logs
106 diff ${cwd}/tmp/largefile  ${cwd}/tmp/bacula-restores${cwd}/tmp/largefile 2>&1 >/dev/null
107 dstat=$?
108
109 grep "Backup Canceled" $tmp/log3.out > /dev/null
110 if [ $? -eq 0 ]; then
111     print_debug "ERROR: 'cancel jobid=1 yes' command should not cancel an other job"
112     estat=1
113 fi
114
115
116 end_test