#!/bin/bash
set -e
set -o pipefail
set -u

TestName="$(basename "$(pwd)")"
export TestName

myname=$(basename "$0")

#shellcheck source=../environment.in
. ./environment

#shellcheck source=../scripts/functions
. "${rscripts}"/functions

start_test

# update first line in brands
"${SQLCMD}" -Q "UPDATE dbnormaltest.production.brands SET brand_name='Bareos' WHERE brand_id=1"

mkdir -p "${tmp}/data"
echo "$0" >"${tmp}/data/$myname"

cat <<END_OF_DATA >"$tmp/bconcmds"
@$out ${NULL_DEV}
messages
@$out $tmp/$myname.log
run job=backup-DBNormal level=Incremental yes
wait
messages
quit
END_OF_DATA

run_bconsole

check_for_zombie_jobs storage=File

if ! grep -q "IClientVirtualDeviceSet2::GetConfiguration successful: 0 (NOERROR)" "$tmp/$myname.log"; then
  echo "\"IClientVirtualDeviceSet2::GetConfiguration successful: 0 (NOERROR)\" not found in log"
  exit 2
fi

end_test
