]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/jobmedia-bug3-test
authorEric Bollengier <eric@baculasystems.com>
Wed, 2 Sep 2020 13:27:38 +0000 (15:27 +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: Kern Sibbald <kern@sibbald.com>
Date:   Sat Feb 21 08:21:23 2015 +0100

    Tweak jobmedia-bug3-test

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Feb 17 17:47:12 2015 +0100

    regress: Scan volume and jobmedia in jobmedia-bug3-test script

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Feb 17 09:03:30 2015 +0100

    regress: Add information about jobmedia in jobmedia-bug3-test

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Mon Feb 16 13:19:17 2015 +0100

    regress: enhance jobmedia-bug3-test

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Mon Feb 16 09:19:32 2015 +0100

    regress: Add an other jobmedia test case

regress/tests/jobmedia-bug3-test [new file with mode: 0755]

diff --git a/regress/tests/jobmedia-bug3-test b/regress/tests/jobmedia-bug3-test
new file mode 100755 (executable)
index 0000000..b4160dd
--- /dev/null
@@ -0,0 +1,148 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# The script is writing simultaneously (20 jobs) on the same device
+# Normally each job will have to generate many JobMedia. Let see if
+# all JobMedia records are fine.
+#
+TestName=`basename $0`
+JobName=Virtual
+
+. scripts/functions
+${rscripts}/cleanup
+cp -f ${rscripts}/bacula-dir-2media-virtual.conf ${conf}/bacula-dir.conf
+cp -f ${rscripts}/bacula-sd-2media-virtual.conf ${conf}/bacula-sd.conf
+cp -f ${rscripts}/test-bacula-fd.conf ${conf}/bacula-fd.conf
+cp -f ${rscripts}/test-console.conf ${conf}/bconsole.conf
+
+echo "$cwd/tmp/data" >${cwd}/tmp/file-list
+
+# To reproduce this issue, we need only one job per device and per volume
+$bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum Concurrent Jobs", "20", "Device")'
+$bperl -e 'add_attribute("$conf/bacula-sd.conf", "Label Media", "Yes", "Device")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Label Format", "Vol-", "Pool")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Maximum Concurrent Jobs", "20", "Director")'
+$bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum File Size", "5M", "Device")'
+$bperl -e 'add_attribute("$conf/bacula-sd.conf", "Maximum Volume Size", "32M", "Device")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Autoprune", "no", "Client")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "Autoprune", "no", "Pool")'
+
+mkdir -p $tmp/data
+for i in 1 2 3 4
+do
+    dd if=/dev/urandom of=$tmp/data/$i.dat count=10000 bs=1024 2>/dev/null 1>/dev/null
+done
+
+start_test
+
+mkdir $tmp/disk
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+run job=$JobName level=Full storage=vDrive-1 yes
+@sleep 30
+.status dir running
+@sleep 30
+.status dir running
+@sleep 30
+.status dir running
+@sleep 30
+.status dir running
+@sleep 30
+.status dir running
+wait
+messages
+@$out $tmp/log2.out
+.status dir running
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=vDrive-1
+
+rm -f $tmp/bad-jobid.out
+$bperl -e 'check_jobmedia()'
+if [ -f $tmp/bad-jobid.out ]; then
+    echo "Trying to restore suspicious jobids"
+    while read jobid
+    do
+        cat <<END_OF_DATA >${tmp}/bconcmds
+@$out $tmp/log3.out
+@##############################
+@# Information for JobId $JobId
+@##############################
+llist jobid=$jobid
+list jobmedia jobid=$jobid
+llist jobmedia jobid=$jobid
+@$out $tmp/log3-$jobid.out
+@##############################
+@# Jobmedia list for job $jobid
+@##############################
+llist jobmedia jobid=$jobid
+list joblog jobid=$jobid
+@$out $tmp/log2.out
+@#############################
+restore where=$tmp/bacula-restore-$jobid
+3
+$jobid
+m *
+done
+yes
+wait
+END_OF_DATA
+        run_bconsole
+        $rscripts/diff.pl -s $cwd/tmp/data -d $tmp/bacula-restore-$jobid/$cwd/tmp/data
+
+        # get VolSessionId and VolSessionTime for the job
+        vsi=`awk -F: '/Volume Session Id:/ { print $2 }' $tmp/log3-$jobid.out`
+        vst=`awk -F: '/Volume Session Time:/ { print $2 }' $tmp/log3-$jobid.out`
+
+        cd $tmp/disk
+        for i in Vol-*
+        do
+            echo "Volume=$i" >> $tmp/$jobid.bsr
+            echo "VolSessionId=$vsi" >> $tmp/$jobid.bsr
+            echo "VolSessionTime=$vst" >> $tmp/$jobid.bsr
+        done
+        cd $cwd
+        $bin/bls -v -k -b $tmp/$jobid.bsr vDrive-0 > $tmp/bls-$jobid.out
+        $bperl -e "check_jobmedia_content('$tmp/log3-$jobid.out', '$tmp/bls-$jobid.out')"
+    done < $tmp/bad-jobid.out
+fi
+
+stop_bacula
+
+end_test