diff --git a/README b/README index 3845fa9..b262eb1 100644 --- a/README +++ b/README @@ -60,7 +60,7 @@ Running the disk based tests: You can run all the disk based tests by doing: - ./do_file + ./do_disk The disk based tests are totally separate from any production system, provided you have configured the database appropriately diff --git a/tests/1-example-test b/tests/1-example-test index fa177e4..3f8cbfc 100755 --- a/tests/1-example-test +++ b/tests/1-example-test @@ -64,8 +64,9 @@ messages quit END_OF_DATA -# Start the bareos daemon +# Start the bareos daemons # and run the bconsole commands from ${tmp}/bconcmds +# Further bconsole commands can be executed by "run_bconsole". run_bareos # verify that all are terminated diff --git a/tests/truncate-command-test b/tests/truncate-command-test new file mode 100755 index 0000000..9dcded3 --- /dev/null +++ b/tests/truncate-command-test @@ -0,0 +1,106 @@ +#!/bin/sh + +. scripts/functions + +# +# Test the truncate command +# + +get_filesize() +{ + stat --printf="%s" "$1" +} + +# 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`" + +# set other test specific variables +Client=bareos-fd +JobName=backup-bareos-fd + +# a truncated volume has not the size 0, but is at least smaller than this (default block size) +MinVolumeSize=65536 +VolumeName=TestVolume001 + +# 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 + +# ${tmp}/bconcmds lists the bconsole commands executed by "run_bareos" +# create a volume and put data on it. +cat <${tmp}/bconcmds +messages +@$out ${tmp}/log1.out w +label storage=File1 volume=${VolumeName} pool=Default +run job=$JobName storage=File1 yes +wait +messages +END_OF_DATA + +# Start the bareos daemons +# and run the bconsole commands from ${tmp}/bconcmds +run_bareos + +# get size of backup job +#sed -r -n -e 's/ *SD Bytes Written: *([0-9,]*) .*/\1/p' tmp/log1.out | sed s/,// +VolumeSizeWithJob=`get_filesize ${tmp}/${VolumeName}` + +# do some manual testing +if [ ${VolumeSizeWithJob} -lt ${MinVolumeSize} ]; then + set_error "Volume size: ${VolumeSizeWithJob} < ${MinVolumeSize}. Something went wrong with the backup." +fi + + +cat <${tmp}/bconcmds2 +@$out ${tmp}/log2.out w +purge volume=${VolumeName} +truncate volstatus=Purged volume=${VolumeName} yes +messages +END_OF_DATA + +run_bconsole ${tmp}/bconcmds2 + +# verify that all are terminated +check_for_zombie_jobs storage=File1 client=${Client} + +# stop bareos +stop_bareos + +# check tmp/log1.out and tmp/log2.out for errors +check_two_logs + +VolumeSizeAfterTruncate=`get_filesize ${tmp}/${VolumeName}` + +# do some manual testing +if [ ${VolumeSizeAfterTruncate} -gt ${MinVolumeSize} ]; then + set_error "Volume size: ${VolumeSizeAfterTruncate} > ${MinVolumeSize}. Something went wrong with the truncate command." +fi + +printf "Volume path: %s\n" ${tmp}/${VolumeName} +printf "Size before truncate: %d\n" ${VolumeSizeWithJob} +printf "Size after truncate: %d\n" ${VolumeSizeAfterTruncate} + +# end tests and check for error codes +end_test