]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Update bscan's restore/plugin objects tests to check for duplicates
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Tue, 1 Dec 2020 13:31:32 +0000 (14:31 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:59 +0000 (09:02 +0100)
regress/tests/bscan-plugin-objects-test
regress/tests/bscan-restore-objects-test

index 79c217cbbdca2851ec46a0a6b8deea36bf029a20..02a6de6b0fe10ff288a96211043c1cf52a211b3d 100755 (executable)
@@ -38,11 +38,18 @@ status client=$CLIENT
 messages
 @$out ${cwd}/tmp/log2.out
 list objects
+sql
+@$out $tmp/objs_count
+select count(*) from restoreobject;
+
 quit
 END_OF_DATA
 
 run_bacula
 
+# See how many plugin objects were created in the first place
+objs_orig=`cat tmp/objs_count | grep '|' | cut -d'|' -f2 | tail -1`
+
 vm_objects_orig=`cat ${cwd}/tmp/log2.out | grep 'VMWare' | wc -l`
 if [ ${vm_objects_orig} -ne 2 ]; then
    estat=1
@@ -118,5 +125,31 @@ if [ ${objects_lines} -ne ${db_objects_orig} ]; then
    print_debug "Wrong plugin objects count found in output: ${objects_lines}, expected ${db_objects_orig}"
 fi
 
+# Check if running bscan once more won't create any duplicates
+if test "$debug" -eq 1 ; then
+  $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf ${cwd}/tmp
+else
+  $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf ${cwd}/tmp >tmp/log6.out 2>&1
+fi
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+sql
+@$out $tmp/objs_count_double_bscan
+select count(*) from restoreobject;
+
+quit
+quit
+END_OF_DATA
+
+run_bconsole
+
+# Check if there are no duplicates
+objs_after_bscan=`cat tmp/objs_count_double_bscan | grep '|' | cut -d'|' -f2 | tail -1`
+if [ $objs_after_bscan -ne ${objs_orig} ]; then
+    print_debug "ERROR: Running bscan twice produced some duplicates of plugin objects. \
+                 Original count: ${objs_orig}, after second bscan: ${objs_after_bscan}"
+    bstat=1
+fi
+
 stop_bacula
 end_test
index 33f2dc8416313fd29b5958636f6ef812bedaf46a..0b941203a3534645bbd1dc0af99877b40bef20b1 100755 (executable)
@@ -41,10 +41,18 @@ cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 list jobs
 @$out $tmp/list
 llist pluginrestoreconf jobid=1
+sql
+@$out $tmp/robjs_count
+select count(*) from restoreobject;
+
+quit
 END_OF_DATA
 
 run_bconsole
 
+# See how many restore objects were created in the first place
+robjs_orig=`cat tmp/robjs_count | grep '|' | cut -d'|' -f2 | tail -1`
+
 nb=`grep $file $tmp/list | wc -l`
 if [ $nb -ne 1 ]; then
     print_debug "ERROR: Should find the RestoreObject for $file in $tmp/list"
@@ -66,6 +74,7 @@ messages
 purge volume=TestVolume001
 @$out ${cwd}/tmp/log4.out
 list objects
+quit
 END_OF_DATA
 
 run_bconsole
@@ -75,6 +84,7 @@ cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 list jobs
 @$out $tmp/list_after_purge
 llist pluginrestoreconf jobid=1
+quit
 END_OF_DATA
 
 run_bconsole
@@ -114,6 +124,7 @@ fi
 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 @$out tmp/list_job_after_bscan
 list jobs
+quit
 END_OF_DATA
 
 run_bconsole
@@ -125,6 +136,7 @@ fi
 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 @$out $tmp/list_after_bscan
 llist pluginrestoreconf jobid=$newJobId
+quit
 END_OF_DATA
 
 run_bconsole
@@ -142,6 +154,34 @@ if [ $nb -ne 1 ]; then
 fi
 
 run_bconsole
+
+# Check for bug #7098
+# Check if running bscan once more won't create any duplicates
+if test "$debug" -eq 1 ; then
+  $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf ${cwd}/tmp
+else
+  $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -m -s -v -b tmp/bscan.bsr -c bin/bacula-sd.conf ${cwd}/tmp >tmp/log6.out 2>&1
+fi
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+sql
+@$out $tmp/robjs_count_double_bscan
+select count(*) from restoreobject;
+
+quit
+quit
+END_OF_DATA
+
+run_bconsole
+
+# Check if there are no duplicates
+robjs_after_bscan=`cat tmp/robjs_count_double_bscan  | grep '|' | cut -d'|' -f2 | tail -1`
+if [ $robjs_after_bscan -ne ${robjs_orig} ]; then
+    print_debug "ERROR: Running bscan twice produced some duplicates of restore objects. \
+                 Original count: ${robjs_orig}, after second bscan: ${robjs_after_bscan}"
+    bstat=1
+fi
+
 stop_bacula
 
 end_test