]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/aligned-bug-1919-test
authorKern Sibbald <kern@sibbald.com>
Wed, 2 Sep 2020 12:59:53 +0000 (14:59 +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: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Jul 21 10:28:13 2020 +0200

    regress: Add copyright to regress scripts

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Fri Dec 9 15:28:26 2016 +0100

    regress: Reorganize the DartTestFile

Author: Kern Sibbald <kern@sibbald.com>
Date:   Thu Nov 10 18:19:13 2016 +0100

    regress: tweak tests output

Author: Kern Sibbald <kern@sibbald.com>
Date:   Tue Aug 23 11:30:55 2016 +0200

    regress: Tweak aligned tests not compatible with cloud

Author: Kern Sibbald <kern@sibbald.com>
Date:   Sat Jul 2 11:08:38 2016 +0200

    regress: add new/modified aligned volumes tests

regress/tests/aligned-bug-1919-test [new file with mode: 0755]

diff --git a/regress/tests/aligned-bug-1919-test b/regress/tests/aligned-bug-1919-test
new file mode 100755 (executable)
index 0000000..73afa78
--- /dev/null
@@ -0,0 +1,141 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Test aligned data volumes with ZFS deduplication
+# This test expects that you have created a ZFS pool named
+#  tank, and that you have also created tank/volumes
+#
+TestName="aligned-bug-1919-test"
+JobName=NightlySave
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-test-confs
+cp scripts/aligned-bacula-sd.conf bin/bacula-sd.conf
+
+if test x$FORCE_CLOUD = xyes ; then
+   echo "\n=== Test $TestName skipped not compatible with Cloud  ==="
+   exit 0
+fi
+
+
+# install the aligned volume plugin
+make -C build/src/plugins/sd install-aligned-plugin >/dev/null
+
+echo "${cwd}/build" >${cwd}/tmp/file-list
+
+which zfs >/dev/null 2>&1
+if [ $? -eq 0 ] ; then
+  zfs=1
+else
+  zfs=0
+fi
+
+# If we are running with zfs, setup a pool,
+#  otherwise just use defaults
+if [ $zfs -eq 1 ]; then
+  cp bin/bacula-sd.conf tmp/1
+  sed "s%Archive Device = .*$%Archive Device = /tank/volumes%g" tmp/1 >bin/bacula-sd.conf
+
+  # Delete any previous zfs pool
+  sudo zfs destroy -fR tank/volumes
+  sudo zfs destroy -fR tank
+  sudo zfs destroy -r tank
+  sudo zpool destroy -f tank
+  sudo rm -rf /tank/volumes
+  sudo rm -rf /tank
+  #
+  # Create zfs pool
+  sudo zpool create tank sdb sdc
+  sudo zfs create tank/volumes
+  #sudo zfs recordsize=64k tank # default is 128K
+  sudo zfs set atime=off tank
+  sudo zfs set compress=on tank
+  sudo zfs set dedup=on tank
+  sudo zdb -dd tank
+  sudo chown -R kern:kern /tank
+fi
+
+start_test
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+label storage=File volume=Vol1
+label storage=File volume=Vol2
+label storage=File volume=Vol3
+END_OF_DATA
+
+# do label
+run_bacula
+
+if [ $zfs -eq 1 ] ; then
+  sudo zdb -DD tank
+  sudo zdb -b tank
+  sudo zpool list tank
+fi
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+run job=$JobName level=Full yes
+wait
+list volumes
+messages
+END_OF_DATA
+
+for i in 1; do
+  #echo "Running job $i"
+  run_bconsole
+  if [ $zfs -eq 1 ] ; then
+    sudo zdb -DD tank
+    sudo zdb -b tank
+    sudo zpool list tank
+    ls -l /tank/volumes/Vol*  >${cwd}/tmp/log5.out
+    du -h /tank/volumes/Vol1.add >>${cwd}/tmp/log5.out
+  else
+    ls -l tmp/Vol* >${cwd}/tmp/log5.out
+    du -h tmp/Vol1.add >>${cwd}/tmp/log5.out
+  fi
+done
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@# 
+@# now do a restore
+@#
+@$out ${cwd}/tmp/log2.out
+@# setdebug level=0 fd
+restore where=${cwd}/tmp/bacula-restores storage=File
+5
+mark *
+done
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+if [ $zfs -eq 1 ] ; then
+  sudo zdb -DD tank
+  sudo zdb -b tank
+  sudo zpool list tank
+  ls -l /tank/volumes/Vol*  >>${cwd}/tmp/log5.out
+  du -h /tank/volumes/Vol1.add >>${cwd}/tmp/log5.out
+else
+  ls -l tmp/Vol* >>${cwd}/tmp/log5.out
+  du -h tmp/Vol1.add >>${cwd}/tmp/log5.out
+fi
+
+sleep 2
+check_for_zombie_jobs storage=File 
+stop_bacula
+
+check_two_logs
+check_restore_diff
+end_test