Skip to content

Commit

Permalink
checkpoints-test: fix comparing bad numbers
Browse files Browse the repository at this point in the history
The test was comparing the number of files that the fd send to the
sd (this is the number displayed in the backup summary) to the number
of files that get restored (which is equal to the number of files that
the sd sends to the director).  This of course does not make sense and
can cause problems if the cancel does not happen fast enough.  Since
in that case the fd might continue sending files to the sd with the sd
never having the chance to send those to the director.

The fix is simple: we need to check the backup log and add up all
checkpoint batch inserts instead.  This should be equal to the number
of files that the sd send to the director.

For easier debugging I also added tracing to the test.
  • Loading branch information
sebsura authored and BareosBot committed Feb 21, 2024
1 parent 9ec4dcd commit d569a55
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ slowjob="slow-backup-bareos-fd"
cat <<END_OF_DATA >"$tmp/bconcmds"
@$out /dev/null
messages
setdebug level=100 trace=1 all
@$out $backup_log
run job=$slowjob fileset=bigfileset level=Full yes
quit
Expand Down Expand Up @@ -71,6 +72,7 @@ messages
restore jobid=${slowjobid} where=$restore_directory all done yes
wait
messages
setdebug trace=0 all
quit
END_OF_DATA

Expand All @@ -81,7 +83,12 @@ expect_grep "Termination: Backup Canceled" \
"$backup_log" \
"Job was not canceled!"

NumberOfBackedUpFiles=$(grep 'FD Files Written: ' "$backup_log" | sed -n -e 's/^.*Written: //p')
NumberOfBackedUpFiles=0
while read -a nums; do
for num in "${nums[@]}"; do
(( NumberOfBackedUpFiles += num ))
done
done <<< "$(grep "entries start" "$backup_log" | cut -d" " -f12)"

# Check that part of the files were written despite the cancel
if [ "$NumberOfBackedUpFiles" -le 0 ]; then
Expand Down

0 comments on commit d569a55

Please sign in to comment.