/
testrunner
executable file
·145 lines (121 loc) · 2.86 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
#!/bin/bash
set -e
set -u
TestName="$(basename "$(pwd)")"
export TestName
JobName=backup-bareos-fd
#shellcheck source=../environment.in
. ./environment
CTEST_SKIP_RETURN_CODE=77
# check if required sudo commands can be executed, otherwise skip test
for SUDO_CMD in mount umount rm; do
if ! "${SUDO}" -l "${SUDO_CMD}" >/dev/null 2>&1 ; then
echo "cannot execute $SUDO_CMD via sudo" && exit "${CTEST_SKIP_RETURN_CODE}"
fi
done
umount_glusterfs(){
# make sure umount is successful
tries=60
echo "umounting glusterfs..."
while "${SUDO}" mount | grep "${tmp}/data" >/dev/null 2>&1; do
[ $((tries-=1)) -eq 0 ] && {
echo "could not umount glustrfs ${tmp}/data"
exit 1
}
"${SUDO}" umount "${tmp}/data"
echo -n "."
sleep 1
done
}
trap umount_glusterfs EXIT
#shellcheck source=../scripts/functions
. "${rscripts}"/functions
umount_glusterfs
"${rscripts}"/cleanup
"${rscripts}"/setup
# Directory to backup.
# This directory will be created by setup_data "$@"().
BackupDirectory="${tmp}/data"
[ -d "${tmp}/data" ] || mkdir -p "${tmp}/data"
"${SUDO}" mount -t glusterfs ${gfapi_fd_host}:/testvol "${tmp}/data"
"${SUDO}" rm -Rvf "${tmp}/data/*"
# Use a tgz to setup data to be backed up.
# Data will be placed at "${tmp}/data/".
setup_data "$@"
# remove fifos and links
find "${tmp}/data" -type p -exec rm '{}' \;
find "${tmp}/data" -type l -exec rm '{}' \;
start_test
cat <<END_OF_DATA_BACKUP >"$tmp/bconcmds"
@$out /dev/null
messages
@$out $tmp/log1.out
setdebug level=100 storage=File
label volume=TestVolume001 storage=File pool=Full
run job=$JobName yes
status director
status client
status storage=File
wait
messages
status director
status client
status storage=File
messages
wait
status director
status client
status storage=File
messages
wait
status director
status client
status storage=File
messages
wait
status director
status client
status storage=File
messages
wait
status director
status client
status storage=File
messages
wait
quit
END_OF_DATA_BACKUP
run_bareos "$@"
check_for_zombie_jobs storage=File
stop_bareos
#[ -d "${tmp}/bareos-restores" ] && rm -Rvf "${tmp}/bareos-restores"
#mkdir -p "${tmp}"/bareos-restores/"${tmp}/data"
#now move the data away from gluster volume, restore and compare to moved data
#mv "${tmp}/data"/* "${tmp}"/bareos-restores"${tmp}/data"
cat <<END_OF_DATA_RESTORE >"$tmp/bconcmds"
@#
@# now do a restore
@#
@$out $tmp/log2.out
status storage=File
wait
setdebug client=bareos-fd level=1000 trace=1
restore client=bareos-fd fileset=SelfTest where=$tmp/bareos-restores/data select all done
yes
status client
messages
wait
status director
status client
status storage=File
messages
wait
quit
END_OF_DATA_RESTORE
run_bareos "$@"
check_for_zombie_jobs storage=File
check_two_logs
ln -s "${tmp}" "${tmp}/bareos-restores"
check_recursive_diff_of_dirs $tmp/data/weird-files $tmp/data/$tmp/bareos-restores/data/weird-files
umount_glusterfs
end_test