From 5492f6f17e9ee193bf9a42713ebee5d342657613 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 1 Nov 2012 21:42:04 +0100 Subject: [PATCH] regress: Add test for bvfs-test with deleted files --- regress/tests/bvfs-test | 164 +++++++++++++++++++++++++++++++++------- 1 file changed, 136 insertions(+), 28 deletions(-) diff --git a/regress/tests/bvfs-test b/regress/tests/bvfs-test index 49ed3d47f8..aabd9a3645 100755 --- a/regress/tests/bvfs-test +++ b/regress/tests/bvfs-test @@ -137,56 +137,164 @@ END_OF_DATA run_bconsole sleep 1 -touch ${tmpsrc}/ficheriro1.txt +cat /etc/hosts >> ${tmpsrc}/ficheriro1.txt +rm -f ${tmpsrc}/dird_conf.c touch ${tmpsrc}/ficheriro2.txt +ln ${tmpsrc}/ficheriro2.txt ${tmpsrc}/hardlink2 cat <${tmp}/bconcmds @$out /dev/null messages @$out ${tmp}/log1.out -run level=Incremental job=$JobName yes -wait -messages -@# -@# now do a restore -@# -@$out ${tmp}/log2.out -setdebug level=10 storage=File -restore where=${tmp}/bacula-restores storage=File file=<${tmp}/restore-list +run level=Incremental accurate=yes job=$JobName yes wait -status storage=File messages @$out ${tmp}/log3.out -setdebug level=10 director .bvfs_update -sql -SELECT HasCache FROM Job WHERE Type='B'; +.bvfs_lsdir path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8 +.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8 +@$out ${tmp}/log31.out +.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7 +quit +END_OF_DATA + +run_bconsole + +cat <${tmp}/bconcmds +@$out $tmp/log4.out +.bvfs_cleanup path=b21 +END_OF_DATA + + +# we look in the lsdir/lsfiles output to get filenameid and pathid for version and restore +awk '/ficheriro1.txt/ { + print ".bvfs_versions jobid=" $4 " fnid=" $2 " pathid=" $1 " client='$CLIENT'" + print ".bvfs_restore jobid=" $4 " fileid=" $3 " path=b21" +} ' $tmp/log3.out >> $tmp/bconcmds + +cat <>${tmp}/bconcmds +restore file="?b21" where=$tmp/bacula-restores yes +wait +messages +quit +END_OF_DATA + +run_bconsole + +diff $tmpsrc/ficheriro1.txt $tmp/bacula-restores/$tmpsrc/ficheriro1.txt &>> $tmp/d1 +if [ $? != 0 ]; then + print_debug "ERROR: ficheriro1.txt is different" + rstat=1 +fi -.bvfs_lsdir path=${tmpsrc}/ jobid=1,2,3,4,5,6,7,8 -.bvfs_lsfile path=${tmpsrc}/ jobid=1,2,3,4,5,6,7,8 +rm -rf $tmp/bacula-restores + +cat <${tmp}/bconcmds +@$out $tmp/log4.out +@# Try to restore a directory +.bvfs_cleanup path=b21 +END_OF_DATA + +awk '/ficheriro2.txt/ { + print ".bvfs_restore jobid=1,2,3,4,5,6,7,8 dirid=" $1 " path=b21" +} ' $tmp/log3.out >> $tmp/bconcmds + +cat <>${tmp}/bconcmds +@$out $tmp/log2.out +restore file="?b21" where=$tmp/bacula-restores yes +wait +messages quit END_OF_DATA run_bconsole + +$rscripts/diff.pl -s $tmpsrc/ -d $tmp/bacula-restores/$tmpsrc/ +if [ $? != 0 ]; then + print_debug "ERROR: Found error while restoring a directory" + rstat=1 +fi + +diff $tmpsrc/ficheriro2.txt $tmp/bacula-restores/$tmpsrc/ficheriro2.txt +if [ $? != 0 ]; then + print_debug "ERROR: ficheriro2.txt is different" + rstat=1 +fi + +rm -rf $tmp/bacula-restores + +cat <${tmp}/bconcmds +@$out $tmp/log4.out +@# Try to restore a hardlinks +.bvfs_cleanup path=b21 +END_OF_DATA + +jidx=`awk -F '\t' '/ficheriro2.txt|hardlinks2/ { lstat=$5 } + END { print ".bvfs_decode_lstat lstat=\"" lstat "\"" +} ' $tmp/log3.out | $bin/bconsole -c $conf/bconsole.conf | awk -F= '/LinkFI/ { print $2 } '` + +awk '/ficheriro2.txt/ { if (!id) { id=$3 } } /hardlink2/ { if (!id) { id=$3 } } + END { + print ".bvfs_restore jobid=1,2,3,4,5,6,7,8 hardlink=8,'$jidx' fileid=" id " path=b21" + } ' $tmp/log3.out >> $tmp/bconcmds + +cat <>${tmp}/bconcmds +@$out $tmp/log2.out +restore file="?b21" where=$tmp/bacula-restores yes +wait +messages +quit +END_OF_DATA + +run_bconsole + +test -f $tmp/bacula-restores/$tmpsrc/hardlink2 -a -f $tmp/bacula-restores/$tmpsrc/ficheriro2.txt +if [ $? != 0 ]; then + print_debug "ERROR: Need to get all files" + rstat=1 +fi + +# Compare Inode +ls -i $tmp/bacula-restores/$tmpsrc/hardlink2 | awk ' { print $1 } ' > $tmp/1 +ls -i $tmp/bacula-restores/$tmpsrc/ficheriro2.txt | awk ' { print $1 } ' > $tmp/2 +diff $tmp/1 $tmp/2 > /dev/null +if [ $? != 0 ]; then + print_debug "ERROR: Both files should have the same inode number" + rstat=1 +fi + check_for_zombie_jobs storage=File stop_bacula check_two_logs -# -# Delete .c files because we will only restored the txt files -# -rm -f ${tmpsrc}/*.c -check_restore_tmp_build_diff -${cwd}/build/src/tools/bvfs_test -T -p ${tmpsrc} -j 1,2,3,4,5,6,7,8 \ - -w "$working" -n "$db_name" -u "$db_user" -P "$db_password" +grep dird_conf.c $tmp/log3.out > /dev/null +if [ $? = 0 ]; then + print_debug "ERROR: Should not find dird_conf.c in bvfs_lsfiles output $tmp/log3.out" + estat=1 +fi -${cwd}/build/src/tools/bvfs_test -p ${cwd}/build/ -j 1,2,3,4,5,6,7,8 \ - -w "$working" -n "$db_name" -u "$db_user" -P "$db_password" +grep dird_conf.c $tmp/log31.out > /dev/null +if [ $? != 0 ]; then + print_debug "ERROR: Should find dird_conf.c in bvfs_lsfiles output $tmp/log31.out" + estat=1 +fi -${cwd}/build/src/tools/bvfs_test -p ${tmpsrc} -j 1,2,3,4,5,6,7,8 \ - -w "$working" -n "$db_name" -u "$db_user" -P "$db_password" \ - -f ficheriro1.txt -c ${HOST}-fd +# +# Delete .c files because we will only restored the txt files +# +#rm -f ${tmpsrc}/*.c +#check_restore_tmp_build_diff +# +#${cwd}/build/src/tools/bvfs_test -T -p ${tmpsrc} -j 1,2,3,4,5,6,7,8 \ +# -w "$working" -n "$db_name" -u "$db_user" -P "$db_password" +# +#${cwd}/build/src/tools/bvfs_test -p ${cwd}/build/ -j 1,2,3,4,5,6,7,8 \ +# -w "$working" -n "$db_name" -u "$db_user" -P "$db_password" +# +#${cwd}/build/src/tools/bvfs_test -p ${tmpsrc} -j 1,2,3,4,5,6,7,8 \ +# -w "$working" -n "$db_name" -u "$db_user" -P "$db_password" \ +# -f ficheriro1.txt -c ${HOST}-fd end_test -- 2.39.5