1#!/bin/sh
2
3. scripts/functions
4
5# Define the Name of the test as "TestName".
6# Should be the same as the filename, therefore we use the filename as default.
7TestName="`basename $0`"
8
9# set other test specific variables
10Client=bareos-fd
11JobName=backup-bareos-fd
12when=`perl -Mscripts::functions -e "get_time(300)"`
13
14# Remove old configuration, working and tmp files. Setup the database.
15cleanup
16
17# Config files will be copied to required location.
18# Base configuration files come from the
19# configs/BASE/ directory, see
20# configs/BASE/README.txt for an overview of the provides resources.
21# Store your additonal resources to
22# configs/$TestName.
23# It is also possible to overwrite resources from configs/BASE.
24# If you define a full config file (instead of config files for individual resources),
25# only these will be taken.
26copy_configs
27
28# increase the maximum concurrent jobs for FD, SD and DIR
29#perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bareos-dir.conf",100)'
30#perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bareos-sd.conf",100)'
31#perl -Mscripts::functions -e 'set_maximum_concurrent_jobs("$conf/bareos-fd.conf",100)'
32
33
34# Directory to backup.
35# This directory will be created by setup_data().
36BackupDirectory="${tmp}/data"
37
38# Use a tgz to setup data to be backuped.
39# Data will be placed at "${tmp}/data/".
40setup_data data/small.tgz
41
42# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
43echo "${BackupDirectory}" >${tmp}/file-list
44
45
46# start the test
47start_test
48
49cat <<END_OF_DATA >${cwd}/tmp/bconcmds
50@$out /dev/null
51messages
52@$out ${cwd}/tmp/log1.out
53messages
54label storage=File1 pool=Default volume=TestVolume001
55@#setdebug level=100 storage=File
56@##############################################
57@# AllowDuplicates = Yes, both jobs should work
58@##############################################
59run comment="Should work" level=Full job=AllowDuplicateYes yes
60@sleep 2
61run comment="Should work" level=Full job=AllowDuplicateYes yes
62wait
63messages
64@$out $tmp/log3.out
65@###############################################################
66@# Run two jobs with the same level and see wich one is canceled
67@###############################################################
68run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
69@sleep 2
70run comment="Should fail" level=Full job=CancelLowerLevelDuplicatesYes yes
71wait
72messages
73@####################################################################
74@# Run two jobs with the different level and see wich one is canceled
75@####################################################################
76run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
77@sleep 2
78run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
79wait
80messages
81run comment="Should fail" level=Differential job=CancelLowerLevelDuplicatesYes yes
82@sleep 2
83run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
84wait
85messages
86run comment="Should work" level=Differential job=CancelLowerLevelDuplicatesYes yes
87@sleep 2
88run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
89wait
90messages
91@#####################################################################################
92@# Run two jobs with the different level and see wich one is canceled (reversed order)
93@#####################################################################################
94run comment="Should work" level=Full job=CancelLowerLevelDuplicatesYes yes
95@sleep 2
96run comment="Should fail" level=Incremental job=CancelLowerLevelDuplicatesYes yes
97wait
98messages
99@$out $tmp/log4.out
100@####################################################################
101@# Run two jobs, the second one can't cancel the 1st, and should fail
102@####################################################################
103run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
104@sleep 2
105run comment="Should fail" level=Full job=CancelQueueDuplicatesYes yes
106wait
107messages
108@#################################################################
109@# The first job should stay queued, the second one will cancel it
110@#################################################################
111run comment="Should fail" level=Full job=CancelQueueDuplicatesYes when="$when" yes
112@sleep 2
113run comment="Should work" level=Full job=CancelQueueDuplicatesYes yes
114wait
115messages
116@$out $tmp/log5.out
117@########################################
118@# The second job will kill the first one
119@########################################
120run comment="Should fail" level=Full job=CancelRunningDuplicatesYes yes
121@sleep 2
122run comment="Should work" level=Full job=CancelRunningDuplicatesYes yes
123wait
124messages
125@$out $tmp/log6.out
126@##########################
127@# The second job won't run
128@##########################
129run comment="Should work" level=Full job=CancelRunningDuplicatesNo yes
130@sleep 1
131run comment="Should fail" level=Full job=CancelRunningDuplicatesNo yes
132wait
133messages
134@$out $tmp/log7.out
135sql
136SELECT JobId, Name, Level, Comment, JobStatus from Job
137WHERE Comment='Should fail' and JobStatus='T' ORDER By JobId;
138
139@$out $tmp/log8.out
140sql
141SELECT JobId, Name, Level, Comment, JobStatus from Job
142WHERE Comment='Should work' and JobStatus != 'T' ORDER By JobId;
143
144@$out $tmp/log9.out
145sql
146SELECT JobId, Name, Level, Comment, JobStatus from Job order by JobId;
147
148quit
149END_OF_DATA
150
151run_bareos
152
153# verify that all are terminated
154check_for_zombie_jobs storage=File1 client=${Client}
155
156# stop bareos
157stop_bareos
158
159touch $tmp/log2.out
160check_two_logs
161
162grep '^| *[0-9]' $tmp/log7.out > /dev/null
163if [ $? = 0 ]; then
164    print_debug "ERROR: Found errors in $tmp/log7.out"
165    print_debug "`cat $tmp/log7.out`"
166    estat=1
167fi
168
169grep '^| *[0-9]' $tmp/log8.out > /dev/null
170if [ $? = 0 ]; then
171    print_debug "ERROR: Found errors in $tmp/log8.out"
172    print_debug "`cat $tmp/log8.out`"
173    estat=1
174fi
175
176nb=`grep '^| *[0-9]' $tmp/log9.out | wc -l`
177if [ $nb -lt 10 ]; then
178    print_debug "ERROR: no enough results in $tmp/log9.out"
179    print_debug "`cat $tmp/log9.out`"
180    estat=1
181fi
182
183# end tests and check for error codes
184end_test
185
186