]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Get regression testing working on FreeBSD
authorDan Langille <dan@langille.org>
Sun, 10 Oct 2021 20:12:12 +0000 (20:12 +0000)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:03 +0000 (09:03 +0100)
25 files changed:
regress/Makefile
regress/scripts/cleanup
regress/scripts/regress-utils.sh [changed mode: 0644->0755]
regress/test_duration
regress/tests/backup-bacula-test
regress/tests/dbcheck-test
regress/tests/docker-plugin-test
regress/tests/fast-nodisk-test
regress/tests/fdsourceaddress-tryout
regress/tests/hangup-blowup-test
regress/tests/json-test
regress/tests/maxdiffinterval-test
regress/tests/remote-console-duplicate-test
regress/tests/remote-console-test
regress/tests/runscript-test
regress/tests/show-test
regress/tests/simple-test
regress/tests/snapshot-btrfs-test
regress/tests/snapshot-cmd-test
regress/tests/snapshot-lvm-test
regress/tests/snapshot-mountopts-test
regress/tests/snapshot-zfs-test
regress/tests/stop-waiting-for-res-job-test
regress/tests/truncate-test
regress/tests/truncate-test.orig [new file with mode: 0755]

index fc6c5712a1cd77d37b30ea6f212693ed1feb097d..8b4986a9dec83a25e5841ffefe8a5e7bbcab2f04 100644 (file)
@@ -52,7 +52,7 @@ root_test:
        ./all-root-tests
 
 clean:
-       scripts/cleanup
+       ./scripts/cleanup
        rm -f tmp/file-list
        rm -fr tmp/* tmp2/* working/* dumps/* Testing
        rm -f test.out
index 6cc332a16abe3ff2d157305e598c56800bc33293..fbeb280252da71ecdb26748245dd16e0e71c1208 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
old mode 100644 (file)
new mode 100755 (executable)
index eb6956b..47eecef
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2015-2020 RadosÅ‚aw Korzeniewski
 # License: BSD 2-Clause; see file LICENSE-FOSS
@@ -16,8 +16,8 @@
 #   $FileSetName - a FileSet prefix for restore job to execute
 #
 
-# now check if we are running under a proper shell
-if test "x$SHELL" != "x/bin/bash"
+ # now check if we are running under a proper shell
+if test "x/$(basename $0)" != "x/bash"
 then
         echo "Regression script must use BASH for this utilities!"
         exit 1
index b2352a0aaf0983051b2cade9c6b6ff2afbd7507f..eb85cc256ef5b1992d46957b6b691cfc8f202d31 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
 #
 # Copyright (C) 2000-2015 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
@@ -13,4 +13,4 @@ diff = t - float(s)
 h = int(diff / 3600)
 m = int((diff - h * 3600) / 60)
 sec = diff - h * 3600 - m * 60
-print '%02d:%02d:%02d %ds' % (h, m, sec, t-float(s))
+print('%02d:%02d:%02d %ds' % (h, m, sec, t-float(s)))
index ad4401c44190856c3035f0e6dd76be9400527ff0..a7a3d454330dd04705944246b696ff571ca2a723 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index e4d98c6fe69de4c6043a73e507820f97fa69e355..84a037df5986a5de6d9ed179e160f6670273c842 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index f8bc88276f8719b11aaeefa18f1bd2df3aa5f9a1..5f4290a19ee46ccbe76c2628f01771197a36b6f1 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index cc96016642e57d297426ba891be2461392933d55..14fd4499aafb987cb19c4c47cf9b0cfa52d7f8e7 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 0acdd341de439635d18e8c855637535ea39ee9ec..c3bbbbaf2a47000194857885751c2e9c04bfb5ab 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index b6bac63791f0fcca0aa91aa0504509bafe8f87cd..285731e0c3885aa519f1a1549711a6251fb969f0 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 909860e68ff04972b5711623ba26b7ec23b332c2..34d473d5bbca78ec363ee39351208164c0966a3d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index c8f75f4fc915005d51068df7ca0a2a4e3af1bc5b..1c52d418d6828c8320108475def27a6464722eda 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index dcf73884742c5f7aab97603e436076a21902b594..6f812a18b61d77c39cd7ca06f07b410f50e5e0a7 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2021 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 6da70d40b14c68488225eb62a5883a43bd723f12..59dd6d40244d4f7c2230fa4ff62aa4ea51a3721f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index e66263782aca5f8fca4d04e168c6d0cdfcb36469..a3f7bc69db32ddd5f5d7aee90d0bfebceb14b0fd 100755 (executable)
@@ -110,17 +110,23 @@ else
    bstat=1
 fi
 
+echo ' testing a'
 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED1"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
 a=$?
+echo ' testing b'
 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED2"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
 b=$?
+echo ' testing c'
 grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
 c=$?
+echo ' testing d'
 grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
 d=$?
+echo ' testing e'
 grep 'touching' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
 e=$?
-grep '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
+echo ' testing f'
+grep '\*\*\* Backup Error \*\*\*' ${cwd}/tmp/RUN_FD_FAILED.log >/dev/null
 f=$?
 if [ $a = 0 -a $b = 0 -a $c = 0 -a $d = 0 -a $e = 0 -a $f = 0 ]
 then
@@ -138,7 +144,7 @@ grep 'shell command: run ClientBeforeJob "/bin/false RUN_FD_FAILED3"' ${cwd}/tmp
 c=$?
 grep 'shell command: run AfterJob "/bin/echo RunAfterFailedJob"' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
 d=$?
-grep  '*** Backup Error ***' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
+grep  '\*\*\* Backup Error \*\*\*' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
 e=$?
 grep 'RUN_FD_FAILED4' ${cwd}/tmp/RUN_FD_FAILED2.log >/dev/null
 f=$?
index 0f3a62d013abb821671253eda3fbc3bf72ad6da6..d656d0420c88e8c758c6557b61838bf03fa66cab 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 0607d90bab6d1af034ee14663bc89594084e8c0f..85cac0d8cc789eb94f80ead468506b85d7819e4d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 49b01cafa84d2c628e747746cdd69534990700cb..35dc6a1dddf8429b101489e4da1f7eb6578b773b 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 61b82e94f5ad68a2d274f6e3f004ff46cc446b0a..e96b9d67b971d098cb187704dddc5aad3812be40 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 4b41b9e01f4617752cae4612607d8eb70eb73967..9739153692640684526a939e201ce13313637020 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 6a4bf954cd48a83def29620d4c1e4b5f809676bc..a50c15abd084d9fef51fee6a7cfc03c8bf3942df 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 0236e30be9881a4e1d0cecd97dcc322b0057e28d..bd1be2654a3db8ecc67baa8ffe62170c1e8eba8f 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2020 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index 906879bb7c581aca30f9f09971235721cde577f8..8c43723d27eb39e614c9c3df39ec675adec0d753 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Copyright (C) 2000-2021 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
index fdc78e7cc0ea4f57ae0c5a086ac80727bc6e1598..25ebec70e1d5f0a36bb161fa764f1db6b15a64f2 100755 (executable)
@@ -19,6 +19,16 @@ echo $src > $tmp/file-list
 sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1
 cp $tmp/1 $conf/bacula-dir.conf
 
+case $(uname) in
+  FreeBSD )
+    DU="du -A -B 1"
+    ;;
+  * )
+    DU="du -b"
+    ;;
+esac
+
+
 start_test
 
 cat >tmp/bconcmds <<END_OF_DATA
@@ -83,9 +93,9 @@ messages
 @#########################################################
 @# test that we cannot truncate a volume that is not purged
 @#########################################################
-@exec "du -s -b $tmp/TestVolume001"
+@exec "$DU -s $tmp/TestVolume001"
 truncate volume=TestVolume001  storage=File
-@exec "du -s -b $tmp/TestVolume001"
+@exec "$DU -s $tmp/TestVolume001"
 messages
 @$out $tmp/log6.out
 @#########################################################
@@ -117,7 +127,7 @@ fi
 print_debug "Check all media"
 
 for i in 1 2 3 4 5 ; do
-  size=`du -b TestVolume00$i|cut -f1`
+  size=`$DU TestVolume00$i|cut -f1`
   if test $size -lt 5000 ; then
      print_debug "ERROR 2: Volume TestVolum00$i is too small $size"
      ls -l TestVolume00$i
@@ -138,7 +148,7 @@ if test "$debug" -eq 1 ; then
 fi
 
 for i in  2 3 4 5 ; do
-  size=`du -b TestVolume00$i|cut -f1`
+  size=`$DU TestVolume00$i|cut -f1`
   if test $size -lt 5000 ; then
      print_debug "ERROR 3: Volume TestVolume00$i is too small $size"
      ls -l TestVolume00$i
@@ -146,7 +156,7 @@ for i in  2 3 4 5 ; do
   fi
 done
 for i in 1 ; do
-  size=`du -b TestVolume00${i} | cut -f1`
+  size=`$DU TestVolume00${i} | cut -f1`
   if test $size -gt 5000 ; then
      print_debug "ERROR 4: Volume TestVolume00$i is not truncated (too big) $size"
      ls -l TestVolume00$i
@@ -166,7 +176,7 @@ if test "$debug" -eq 1 ; then
 fi
 
 for i in 2 5 ; do
-  size=`du -b TestVolume00$i | cut -f1`
+  size=`$DU TestVolume00$i | cut -f1`
   if test $size -lt 5000 ; then
      print_debug "ERROR 5: Volume TestVolume00$i is too small $size"
      ls -l TestVolume00$i
@@ -174,7 +184,7 @@ for i in 2 5 ; do
   fi
 done
 for i in 1 3 4 ; do
-  size=`du -b TestVolume00$i | cut -f1`
+  size=`$DU TestVolume00$i | cut -f1`
   if test $size -gt 5000 ; then
      print_debug "ERROR 6: Volume TestVolume00$i is not truncated (too big) $size"
      ls -l TestVolume00$i
diff --git a/regress/tests/truncate-test.orig b/regress/tests/truncate-test.orig
new file mode 100755 (executable)
index 0000000..fdc78e7
--- /dev/null
@@ -0,0 +1,241 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Test truncate command (replaces old purge action=truncate ...)
+#
+#
+TestName="truncate-test"
+JobName=FIFOTest
+. scripts/functions
+
+cwd=`pwd`
+scripts/cleanup
+scripts/copy-test-confs
+
+echo $src > $tmp/file-list
+
+sed 's/Pool Type = Backup/Pool Type = Backup; ActionOnPurge = Truncate/' $conf/bacula-dir.conf > $tmp/1
+cp $tmp/1 $conf/bacula-dir.conf
+
+start_test
+
+cat >tmp/bconcmds <<END_OF_DATA
+@$out /dev/null
+messages
+@$out $tmp/log1.out
+label storage=File volume=TestVolume001
+@########################################################
+@# Run a first job on TestVolume001
+@########################################################
+run level=full job=$JobName yes
+wait
+messages
+@#@$out $tmp/log2.out
+@#restore where=${cwd}/tmp/bacula-restores select all storage=File done
+@#yes
+@#wait
+@#messages
+@#########################################################
+@# Run a second job on TestVolume002
+@#########################################################
+@$out $tmp/log3.out
+label storage=File volume=TestVolume002
+update volume=TestVolume001 volstatus=Used
+messages
+show pool
+@$out $tmp/log1.out
+run level=full job=$JobName yes
+wait
+messages
+@#########################################################
+@# Run a 3th job on TestVolume003
+@#########################################################
+@$out $tmp/log3.out
+update volume=TestVolume002 volstatus=Used
+label storage=File volume=TestVolume003
+messages
+show pool
+@$out $tmp/log1.out
+run level=full job=$JobName yes
+wait
+messages
+@#########################################################
+@# Run a 4th job
+@#########################################################
+@$out $tmp/log5.out
+update volume=TestVolume003 volstatus=Used
+label storage=File volume=TestVolume004
+messages
+@$out $tmp/log1.out
+run level=full job=$JobName yes
+wait
+messages
+list volume
+@$out $tmp/log1.out
+update volume=TestVolume004 volstatus=Used
+label storage=File volume=TestVolume005
+run level=full job=$JobName yes
+wait
+messages
+@$out $tmp/log7.out
+@#########################################################
+@# test that we cannot truncate a volume that is not purged
+@#########################################################
+@exec "du -s -b $tmp/TestVolume001"
+truncate volume=TestVolume001  storage=File
+@exec "du -s -b $tmp/TestVolume001"
+messages
+@$out $tmp/log6.out
+@#########################################################
+@# tests
+@#########################################################
+update volume=TestVolume002 actiononpurge=none
+purge volume=TestVolume001
+purge volume=TestVolume002
+purge volume=TestVolume003
+purge volume=TestVolume004
+list volume
+sql
+select VolumeName, VolStatus, ActionOnPurge FROM Media;
+
+setdebug level=100 director
+wait
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File
+
+cd $tmp
+if test "$debug" -eq 1 ; then
+  echo "Volume sizes before truncate ..."
+  ls -l TestVolume*
+fi
+
+print_debug "Check all media"
+
+for i in 1 2 3 4 5 ; do
+  size=`du -b TestVolume00$i|cut -f1`
+  if test $size -lt 5000 ; then
+     print_debug "ERROR 2: Volume TestVolum00$i is too small $size"
+     ls -l TestVolume00$i
+     estat=2
+  fi
+done
+
+cd $cwd
+
+echo "truncate volume=TestVolume001 storage=File" > $tmp/bconcmds
+run_bconsole
+
+cd $tmp
+
+if test "$debug" -eq 1 ; then
+  echo "Volume TestVolume001 should be truncated ..."
+  ls -l TestVolume*
+fi
+
+for i in  2 3 4 5 ; do
+  size=`du -b TestVolume00$i|cut -f1`
+  if test $size -lt 5000 ; then
+     print_debug "ERROR 3: Volume TestVolume00$i is too small $size"
+     ls -l TestVolume00$i
+     estat=3
+  fi
+done
+for i in 1 ; do
+  size=`du -b TestVolume00${i} | cut -f1`
+  if test $size -gt 5000 ; then
+     print_debug "ERROR 4: Volume TestVolume00$i is not truncated (too big) $size"
+     ls -l TestVolume00$i
+     estat=4
+  fi
+done
+
+cd $cwd
+
+echo "truncate volume storage=File" > $tmp/bconcmds
+run_bconsole
+
+cd $tmp
+if test "$debug" -eq 1 ; then
+  echo "Volumes 001, 003, and 004 should be truncated ..."
+  ls -l TestVolume*
+fi
+
+for i in 2 5 ; do
+  size=`du -b TestVolume00$i | cut -f1`
+  if test $size -lt 5000 ; then
+     print_debug "ERROR 5: Volume TestVolume00$i is too small $size"
+     ls -l TestVolume00$i
+     estat=5
+  fi
+done
+for i in 1 3 4 ; do
+  size=`du -b TestVolume00$i | cut -f1`
+  if test $size -gt 5000 ; then
+     print_debug "ERROR 6: Volume TestVolume00$i is not truncated (too big) $size"
+     ls -l TestVolume00$i
+     estat=6
+  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
+@#########################################################
+@# Display catalog settings for Pool and Media
+@#########################################################
+@$out $tmp/log4.out
+setdebug level=0 director
+sql
+select VolumeName, ActionOnPurge FROM Media;
+select Name, ActionOnPurge FROM Pool;
+
+wait
+quit
+END_OF_DATA
+
+run_bconsole
+
+stop_bacula
+
+touch $tmp/log2.out
+check_two_logs
+
+print_debug "Test if Pool record is ok"
+r=`awk '/Default/ { print $4 }' $tmp/log4.out`
+if [ "$r" != 1 ]; then
+    print_debug "ERROR 5: ActionOnPurge on Pool record should be 1 ($r)"
+    estat=5
+fi
+
+print_debug "Test TestVolume001 if Media record is ok"
+r=`awk '/TestVolume001/ { print $4 }' $tmp/log4.out`
+if [ "$r" != 1 ]; then
+    print_debug "ERROR 6: ActionOnPurge on Media record should be 1"
+    estat=6
+fi
+
+print_debug "Test TestVolume002 if Media record is ok"
+r=`awk '/TestVolume002/ { print $4 }' $tmp/log4.out`
+if [ "$r" != 0 ]; then
+    print_debug "ERROR 7: ActionOnPurge on Media record should be 0"
+    estat=7
+fi
+
+end_test