1#!/bin/sh
2#
3# Show the broken media bug. Test by Graham Keeling.
4#
5# For the moment this test will always fail, so do not add
6#   it to the standard test set.
7# The problem:
8# - You begin writing a giant job onto a Volume
9# - There are no other volumes available for writing (big mistake).
10# - You start a second job that needs a Volume to write on.
11# - The second job see that there are no JobMedia records associated with the
12#    Volume (not yet written), so it purges the Volume.
13# - A sort of chaos then follows.
14#
15
16TestName="broken-media-bug-test"
17. scripts/functions
18
19cwd=`pwd`
20scripts/cleanup
21/bin/cp -f scripts/broken-media-bug-bareos-dir.conf bin/bareos-dir.conf
22/bin/cp -f scripts/test-bareos-sd.conf bin/bareos-sd.conf
23/bin/cp -f scripts/test-bareos-fd.conf bin/bareos-fd.conf
24/bin/cp -f scripts/test-console.conf bin/bconsole.conf
25# Directory to backup.
26# This directory will be created by setup_data().
27BackupDirectory="${tmp}/data"
28
29# Use a tgz to setup data to be backuped.
30# Data will be placed at "${tmp}/data/".
31setup_data data/small.tgz
32
33# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
34echo "${BackupDirectory}" >${tmp}/file-list
35
36hugefile=${BackupDirectory}/hugefile
37hugefilesize=300
38
39
40
41
42start_test
43
44echo "Creating huge ${hugefilesize}M file..."
45dd if=/dev/urandom of="$hugefile" bs=1M count="$hugefilesize"
46echo "Done"
47
48cat >tmp/bconcmds <<END_OF_DATA
49@out /dev/null
50messages
51@$out tmp/log1.out
52setdebug level=150  storage=File
53setdebug level=150  Director
54label storage=File volume=TestVolume0001
55label storage=File volume=TestVolume0002
56run job=First yes
57messages
58quit
59END_OF_DATA
60
61run_bareos
62
63# Give the first job a bit of time to get going.
64sleep 5
65
66cat >tmp/bconcmds <<END_OF_DATA
67setdebug level=150  storage=File
68setdebug level=150  Director
69list volumes
70llist volume=TestVolume0001
71llist volume=TestVolume0002
72messages
73@$out tmp/log2.out
74run job=Second yes
75wait
76messages
77restore fileset=Set1 where=${cwd}/tmp/bareos-restores select all storage=File done
78yes
79wait
80messages
81quit
82END_OF_DATA
83
84run_bconsole
85check_for_zombie_jobs storage=File
86stop_bareos
87
88check_two_logs
89check_restore_diff
90end_test
91