This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
always-incremental-test
executable file
·123 lines (96 loc) · 2.85 KB
/
always-incremental-test
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
#!/bin/sh
. scripts/functions
#
# Example regression test.
#
# Use this as a template for your own tests.
#
# Define the Name of the test as "TestName".
# Should be the same as the filename, therefore we use the filename as default.
TestName="`basename $0`"
#TestName="1-example-test"
# set other test specific variables
Client=bareos-fd
JobName=backup-bareos-fd
# Directory to backup.
# This example uses a subdirectory of the bareos source/build directory,
# that contains some file but isn't to large.
BackupDirectory="${cwd}/build/src/tests/"
# Remove old configuration, working and tmp files. Setup the database.
cleanup
# Config files will be copied to required location.
# Base configuration files come from the
# configs/BASE/ directory, see
# configs/BASE/README.txt for an overview of the provides resources.
# Store your additonal resources to
# configs/$TestName.
# It is also possible to overwrite resources from configs/BASE.
# If you define a full config file (instead of config files for individual resources),
# only these will be taken.
copy_configs
# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
echo "${BackupDirectory}" >${tmp}/file-list
# start the test
start_test
run_bareos
# create a new file and run multiple backups
for file in 1 2 3 4 5 6 7 ; do
echo file$file > ${BackupDirectory}/file$file
cat <<END_OF_DATA >${tmp}/bconcmds
messages
@$out ${tmp}/log1.out w
run job=$JobName yes
wait
messages
END_OF_DATA
run_bconsole
done
#stop_bareos
#check_for_zombie_jobs storage=File1 client=${Client}
cat <<END_OF_DATA >${tmp}/bconcmds
@#
@# try to consolidate
@#
@$out ${tmp}/log1.out w
list jobs
run job=Consolidate yes
wait
list jobs
messages
END_OF_DATA
run_bconsole
cat <<END_OF_DATA >${tmp}/bconcmds
@#
@# now do a restore
@#
@$out ${tmp}/log2.out w
restore client=${Client} where=${tmp}/bareos-restores select
unmark *
mark *
done
yes
wait
messages
quit
END_OF_DATA
run_bconsole
# stop bareos
stop_bareos
# check tmp/log1.out and tmp/log2.out for errors
check_two_logs
# check for differences between original files and restored files
check_restore_diff ${BackupDirectory}
# do some manual testing
if [ ! -d ${BackupDirectory} ]; then
set_error "Directory ${BackupDirectory} does not exists any more."
fi
# check if consolidation worked as expected
grep "purged JobIds 1,2,3,4,5 as they were consolidated into Job 9" tmp/log1.out || set_error "consolidation did not consolidate jobs that were expected"
# check if the expected jobids were chosen for restore
grep "You have selected the following JobIds: 9,6,7" tmp/log2.out || set_error "other jobs than expected were chosen for restore"
# check if all files were restored
for file in 1 2 3 4 5 6 7 ; do
grep $file ${tmp}/bareos-restores/${BackupDirectory}/file$file || set_error "file $file was not recovered"
done
# end tests and check for error codes
end_test