#!/bin/sh
#
# Copyright (C) 2000-2025 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Test for verification if proper message is being logged depending on TLS usage for the daemons
# during virtual full jobs
#
TestName="daemons-connection-virt_full-log-test"
JobName=Vbackup
. scripts/functions

scripts/cleanup
scripts/copy-migration-confs
echo "${cwd}/build" >${cwd}/tmp/file-list

change_jobname NightlySave $JobName

start_test

cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@output /dev/null
messages
@$out ${cwd}/tmp/log1.out
label storage=File volume=FileVolume001 Pool=Default
label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
@exec "sh -c 'date > ${cwd}/build/date'"
run job=$JobName level=Full yes
wait
messages
list jobs
@exec "sh -c 'touch ${cwd}/build/src/dird/*.c'"
run job=$JobName level=Incremental yes
wait
messages
list jobs
@exec "sh -c 'touch ${cwd}/build/src/dird/*.o'"
run job=$JobName level=Differential yes
wait
messages
list jobs
@exec "sh -c 'date > ${cwd}/build/date'"
@exec "sh -c 'touch ${cwd}/build/src/dird/*.o'"
run job=$JobName level=Incremental yes
wait
messages
@$out ${cwd}/tmp/log2.out
run job=$JobName level=VirtualFull yes
wait
messages
quit
END_OF_DATA

run_bacula

stop_bacula

check_connection_tls_logs $tmp/log2.out 1 1 0 0 0
tmp_estat=$((tmp_estat+estat))

estat=$tmp_estat
end_test
