/
testrunner
executable file
·148 lines (126 loc) · 2.83 KB
/
testrunner
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
set -e
set -o pipefail
set -u
#
# Run a simple backup
# then restore it.
#
TestName="$(basename "$(pwd)")"
export TestName
JobName=backup-bareos-fd
#shellcheck source=../../environment.in
. ./environment
#shellcheck source=../../scripts/functions
. "${rscripts}"/functions
"${rscripts}"/cleanup
"${rscripts}"/setup
# Fill ${BackupDirectory} with data.
setup_data
# clean out logfile
rm -f log/bareos.log
start_test
start_bareos
cat <<END_OF_DATA >"$tmp/bconcmds"
@$out /dev/null
messages
@$out $tmp/log1.out
setdebug level=100 storage=File
label volume=TestVolume001 storage=File pool=Full
label volume=TestVolume002 storage=File pool=Incremental
label volume=TestVolume003 storage=File pool=VirtualFull
run job=$JobName level=Full yes
wait
messages
list jobs
@exec "sh -c 'touch ${tmp}/data/*.c'"
run job=$JobName level=Incremental yes
wait
messages
list jobs
run job=$JobName level=VirtualFull yes
wait
messages
list jobs
@# make sure we really restore the virtualfull
purge volume=TestVolume001
purge volume=TestVolume002
status director
status client
status storage=File
quit
END_OF_DATA
run_bconsole "$tmp/bconcmds"
cat <<END_OF_DATA >"$tmp/bconcmds2"
@#
@# now do a restore
@#
@$out $tmp/log2.out
wait
restore client=bareos-fd fileset=SelfTest where=$tmp/bareos-restores select all done
yes
wait
messages
quit
END_OF_DATA
run_bconsole "$tmp/bconcmds2"
check_for_zombie_jobs storage=File
check_restore_diff "${BackupDirectory}"
cat <<END_OF_DATA >"$tmp/bconcmds3"
@$out /dev/null
messages
@$out $tmp/log3.out
run job=$JobName level=Full yes
wait
messages
list jobs
@exec "sh -c 'touch ${tmp}/data/*.c'"
run job=$JobName level=Incremental yes
wait
run job=$JobName level=Incremental yes
wait
run job=$JobName level=Incremental yes
wait
messages
purge files jobid=5 yes
list jobs
@$out $tmp/log4.out
run job=$JobName jobid=7,8 level=VirtualFull yes
wait
messages
@$out $tmp/log5.out
run job=$JobName jobid=3,2,6 level=VirtualFull yes
wait
messages
@$out $tmp/log6.out
run job=$JobName jobid=3,5,6 level=VirtualFull yes
wait
messages
list jobs
quit
END_OF_DATA
run_bconsole "$tmp/bconcmds3"
check_for_zombie_jobs storage=File
check_two_logs
stop_bareos
if ! grep -q "Consolidating JobIds 1,2 containing 74 files" "$tmp/log1.out"; then
echo "Consolidation message was not emitted" >&2
cat "$tmp/log1.out"
estat=1
fi
if ! grep -q "Fatal error: Could not create bootstrap file" "$tmp/log4.out"; then
echo "Job with no files contained did not fail as expected" >&2
cat "$tmp/log4.out"
estat=1
fi
if ! grep -q "JobId 2 not found in catalog." "$tmp/log5.out"; then
echo "Consolidating missing jobids did not fail as expected" >&2
cat "$tmp/log5.out"
estat=1
fi
if ! grep -q "Termination:.*Backup Error" "$tmp/log6.out"; then
echo "Consolidating jobs with pruned files did not fail as expected" >&2
cat "$tmp/log6.out"
estat=1
fi
end_test