Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix and active tests that creates sparse files
replaces the gigaslam tool by scripts/create_sparse_file.sh, to be able to create sparse files at arbitrary sizes. Creating a sparse file of 100M (real size about 8K).
- Loading branch information
1 parent
b41ce92
commit 721c56e
Showing
6 changed files
with
145 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
filename=${1:-sparse.dat} | ||
size=${2:-100M} | ||
|
||
echo "start" > $filename | ||
dd if=/dev/zero of=$filename bs=1 count=0 seek=$size 2>/dev/null | ||
echo "end" >> $filename | ||
|
||
size="`du --block-size=1 --apparent-size ${filename} | cut -f 1`" | ||
realsize="`du --block-size=1 ${filename} | cut -f 1`" | ||
|
||
printf "$filename created.\n" | ||
printf "size=%s\n" "$size" | ||
printf "realsize=%s\n" "$realsize" | ||
|
||
if ! [ "$realsize" -lt "$size" ]; then | ||
printf "ERROR: realsize has to be smaller than size.\n" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,7 @@ set_error() | |
{ | ||
estat=9 | ||
echo "ERROR: $@" >> $tmp/err.log | ||
echo "ERROR: $@" | ||
} | ||
|
||
check_files_written() | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/sh | ||
# | ||
# Run a simple backup of the Bareos build directory using the Sparse option | ||
# then restore it. | ||
# | ||
TestName="gigaslam-sparse-test" | ||
JobName=SparseTest | ||
#JobName=SparseCompressedTest | ||
|
||
. scripts/functions | ||
|
||
scripts/cleanup | ||
scripts/copy-test-confs | ||
|
||
# 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/" | ||
|
||
# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list". | ||
echo "${BackupDirectory}" >${tmp}/file-list | ||
|
||
mkdir -p "${BackupDirectory}" | ||
|
||
SPARSEFILE="${BackupDirectory}/gigaslam.gif" | ||
|
||
# create a sparse file | ||
scripts/create_sparse_file.sh ${SPARSEFILE} 100M | ||
if [ $? != 0 ]; then | ||
set_error "create_sparse_file failed." | ||
rm -f ${SPARSEFILE} | ||
exit 1 | ||
fi | ||
|
||
if ! [ -e "${SPARSEFILE}" ]; then | ||
set_error "Failed to create sparse file." | ||
exit 1 | ||
fi | ||
|
||
start_test | ||
|
||
cat >${cwd}/tmp/bconcmds <<END_OF_DATA | ||
@$out /dev/null | ||
messages | ||
@$out ${cwd}/tmp/log1.out | ||
label storage=File volume=TestVolume001 | ||
run job=$JobName yes | ||
wait | ||
messages | ||
list volumes | ||
@# | ||
@# now do a restore | ||
@# | ||
@$out ${cwd}/tmp/log2.out | ||
restore where=${cwd}/tmp/bareos-restores select storage=File | ||
unmark * | ||
mark * | ||
done | ||
yes | ||
wait | ||
messages | ||
quit | ||
END_OF_DATA | ||
|
||
run_bareos | ||
check_for_zombie_jobs storage=File | ||
stop_bareos | ||
|
||
size_orig=`du ${SPARSEFILE} | cut -f 1` | ||
size=`du ${cwd}/tmp/bareos-restores/${SPARSEFILE} | cut -f 1` | ||
if [ -z "$size" ]; then | ||
set_error "Failed to determine size of restored sparse file." | ||
elif [ $size -gt 120 ]; then | ||
set_error "Restored sparse file ${SPARSEFILE} is too big (${size}K > 120K)" | ||
fi | ||
|
||
print_debug "size orig: $size_orig" | ||
print_debug "size restored: $size" | ||
|
||
check_two_logs | ||
check_restore_diff "${BackupDirectory}" | ||
|
||
rm -f ${SPARSEFILE} | ||
|
||
end_test |