]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/truncate-test
authorAlain Spineux <alain@baculasystems.com>
Wed, 2 Sep 2020 13:04:40 +0000 (15:04 +0200)
committerEric Bollengier <eric@baculasystems.com>
Tue, 1 Mar 2022 14:36:18 +0000 (15:36 +0100)
This commit is the result of the squash of the following main commits:

Author: Alain Spineux <alain@baculasystems.com>
Date:   Fri Sep 22 13:56:02 2017 +0200

    regress: truncate-test add check cannot truncate non purged volume

Author: Kern Sibbald <kern@sibbald.com>
Date:   Mon Sep 16 05:53:33 2013 +0200

    Add truncate test

regress/tests/truncate-test

index ae83aed0f823163596a5f601991ce9fd3742f683..fdc78e7cc0ea4f57ae0c5a086ac80727bc6e1598 100755 (executable)
@@ -53,7 +53,7 @@ messages
 @# Run a 3th job on TestVolume003
 @#########################################################
 @$out $tmp/log3.out
-update volume=TestVolume002 volstatus=Full
+update volume=TestVolume002 volstatus=Used
 label storage=File volume=TestVolume003
 messages
 show pool
@@ -82,19 +82,12 @@ messages
 @$out $tmp/log7.out
 @#########################################################
 @# test that we cannot truncate a volume that is not purged
-@# TestVolume001 - Used
-@# TestVolume002 - Full
-@# TestVolume005 - Append
 @#########################################################
-llist volume=TestVolume001
-llist volume=TestVolume002
-llist volume=TestVolume005
 @exec "du -s -b $tmp/TestVolume001"
-truncate volume=TestVolume001 storage=File
-truncate volume=TestVolume002 storage=File
-truncate volume=TestVolume005 storage=File
+truncate volume=TestVolume001  storage=File
 @exec "du -s -b $tmp/TestVolume001"
 messages
+@$out $tmp/log6.out
 @#########################################################
 @# tests
 @#########################################################
@@ -108,7 +101,6 @@ sql
 select VolumeName, VolStatus, ActionOnPurge FROM Media;
 
 setdebug level=100 director
-messages
 wait
 quit
 END_OF_DATA
@@ -117,18 +109,6 @@ run_bacula
 check_for_zombie_jobs storage=File
 
 cd $tmp
-
-# First check if volumes which were not purged were truncated
-TV1=`grep "The volume \"TestVolume001\" has been truncated" $tmp/log7.out`
-TV2=`grep "The volume \"TestVolume002\" has been truncated" $tmp/log7.out`
-TV3=`grep "The volume \"TestVolume005\" has been truncated" $tmp/log7.out`
-if test "x$TV1" != "x" -o "x$TV2" != "x" -o "x$TV3" != "x"
-then
-  # error, the volumes in non purge status should not be truncated
-  dstat=1
-  print_debug "ERROR 1: Volumes not in Purged status Truncated!!!"
-fi
-
 if test "$debug" -eq 1 ; then
   echo "Volume sizes before truncate ..."
   ls -l TestVolume*
@@ -202,6 +182,18 @@ for i in 1 3 4 ; do
   fi
 done
 
+if ! grep "No Volumes found to perform the command" log7.out > /dev/null ; then
+    print_debug "ERROR 10: Should not be able to truncate TestVolum001 that holds bakcups"
+    estat=1
+else
+   before=`grep $tmp/TestVolume001 log7.out | grep -v exec | head -n 1`
+   after=`grep $tmp/TestVolume001 log7.out | grep -v exec | tail -n 1`
+   if [ -z "$before" -o \( "$before" != "$after" \) ] ; then
+      print_debug "ERROR 11: TestVolum001 has been truncated while it was holding bakcups"
+      estat=1
+   fi
+fi
+
 cd $cwd
 
 cat <<END_OF_DATA > $tmp/bconcmds
@@ -215,7 +207,6 @@ select VolumeName, ActionOnPurge FROM Media;
 select Name, ActionOnPurge FROM Pool;
 
 wait
-messages
 quit
 END_OF_DATA
 
@@ -247,29 +238,4 @@ if [ "$r" != 0 ]; then
     estat=7
 fi
 
-# Now test if the truncate command truncates labeled Volumes
-cat >tmp/bconcmds <<END_OF_DATA
-truncate allpools storage=File
-messages
-wait
-@$out $tmp/log6.out
-@# These truncates should not truncate any Volumes
-truncate allpools storage=File
-truncate allpools storage=File
-truncate allpools storage=File
-wait
-messages
-quit
-END_OF_DATA
-
-run_bacula
-stop_bacula
-
-grep "has been truncated" $tmp/log6.out >$tmp/log8.out
-if [ $? = 0 ] ; then
-    cat $tmp/log8.out
-    print_debug "ERROR 8: truncated volumes are truncated multiple times"
-    estat=8
-fi
-
 end_test