]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/bvfs-test
regress: Add test for bvfs-test with deleted files
[bacula/bacula] / regress / tests / bvfs-test
index 8671d8a1012a1e08a153943cf27029e32ef38872..aabd9a3645d8afb3403a86489f0d7934b5a51c3a 100755 (executable)
@@ -24,7 +24,7 @@ change_jobname CompressedTest $JobName
 start_test
 
 cat <<END_OF_DATA >${tmp}/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${tmp}/log1.out
 label storage=File volume=TestVolume001
@@ -45,7 +45,7 @@ echo "ficheriro1.txt" >${tmpsrc}/ficheriro1.txt
 cp -f ${tmpsrc}/dird.c ${tmpsrc}/ficheriro2.txt
 
 cat <<END_OF_DATA >${tmp}/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${tmp}/log1.out
 @# Force Incremental on the second Volume
@@ -63,7 +63,7 @@ touch ${tmpsrc}/ficheriro1.txt
 touch ${tmpsrc}/ficheriro2.txt
 
 cat <<END_OF_DATA >${tmp}/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${tmp}/log1.out
 run level=Incremental job=$JobName yes
@@ -81,7 +81,7 @@ sed "s%a%b%g" 1 >ficheriro2.txt
 rm -f 1
 cd ${cwd}
 cat <<END_OF_DATA >${tmp}/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${tmp}/log1.out
 run level=Differential job=$JobName yes
@@ -96,7 +96,7 @@ sleep 1
 touch ${tmpsrc}/ficheriro1.txt
 touch ${tmpsrc}/ficheriro2.txt
 cat <<END_OF_DATA >${tmp}/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${tmp}/log1.out
 run level=Incremental job=$JobName yes
@@ -111,7 +111,7 @@ sleep 1
 touch ${tmpsrc}/ficheriro1.txt
 touch ${tmpsrc}/ficheriro2.txt
 cat <<END_OF_DATA >${tmp}/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${tmp}/log1.out
 run level=Incremental job=$JobName yes
@@ -126,7 +126,7 @@ sleep 1
 touch ${tmpsrc}/ficheriro1.txt
 touch ${tmpsrc}/ficheriro2.txt
 cat <<END_OF_DATA >${tmp}/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${tmp}/log1.out
 run level=Incremental job=$JobName yes
@@ -137,50 +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 <<END_OF_DATA >${tmp}/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${tmp}/log1.out
-run level=Incremental job=$JobName yes
+run level=Incremental accurate=yes 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
-yes
+@$out ${tmp}/log3.out
+.bvfs_update
+.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 <<END_OF_DATA >${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 <<END_OF_DATA >>${tmp}/bconcmds
+restore file="?b21" where=$tmp/bacula-restores yes
 wait
-status storage=File
 messages
-@output
 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
+
+rm -rf $tmp/bacula-restores
+
+cat <<END_OF_DATA >${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 <<END_OF_DATA >>${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 <<END_OF_DATA >${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 <<END_OF_DATA >>${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