Skip to content

Commit

Permalink
systemtests: add the operator and mail destination to messages test
Browse files Browse the repository at this point in the history
- add the destinations to the messages resource
- reword the test string
  • Loading branch information
franku committed Feb 11, 2020
1 parent bba159d commit feb314c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion core/src/tests/messages.cc
Expand Up @@ -142,5 +142,5 @@ TEST(messages, send_message_to_all_configured_destinations)
JobControlRecord jcr;
jcr.db = reinterpret_cast<BareosDb*>(1);

DispatchMessage(&jcr, M_ERROR, 0, "This is an error message");
DispatchMessage(&jcr, M_ERROR, 0, "\n!!!This is a test error message!!!\n");
}
@@ -1,10 +1,14 @@
Messages {
Name = Standard
Description = "Reasonable message delivery -- send most everything to email address and to the console."
console = all
append = "@logdir@/bareos.log" = all, !skipped, !saved, !audit
catalog = all, !skipped, !saved, !audit
syslog = all
stdout = all
stderr = all
Console = all
Append = "@logdir@/append" = all
Catalog = all
Syslog = all
Stdout = all
Stderr = all
Mail Command = "/bin/bash -c \"cat - > @logdir@/mail\""
Mail = no-mail = all
Operator Command = "/bin/bash -c \"cat - > @logdir@/operator\""
Operator = no-operator = all
}
16 changes: 11 additions & 5 deletions systemtests/tests/messages-test/testrunner
@@ -1,8 +1,9 @@
#!/bin/sh
#
# Run a simple backup
# then restore it.
# This test runs the messages unittest
# to examine all message directions
#

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

Expand All @@ -17,14 +18,18 @@ syslog_file="${BAREOS_LOG_DIR}"/syslog
dblog_file="${BAREOS_LOG_DIR}"/dblog
stdout_file="${BAREOS_LOG_DIR}"/stdout
stderr_file="${BAREOS_LOG_DIR}"/stderr
extra_append_file="${BAREOS_LOG_DIR}"/bareos.log
extra_append_file="${BAREOS_LOG_DIR}"/append
mail_file="${BAREOS_LOG_DIR}"/mail
operator_file="${BAREOS_LOG_DIR}"/operator

rm -f "$console_messages_file"
rm -f "$syslog_file"
rm -f "$dblog_file"
rm -f "$stdout_file"
rm -f "$stderr_file"
rm -f "$extra_append_file"
rm -f "$mail_file"
rm -f "$operator_file"

function exit_error() {
[ "$1" == "" ] || echo "$1"
Expand All @@ -36,7 +41,7 @@ function exit_error() {
function check_output_file {
[ -f "$1" ] || exit_error "$1 does not exist"

if ! grep --quiet "This is an error message" "$1"; then
if ! grep --quiet "!!!This is a test error message!!!" "$1"; then
exit_error "\"$1\" does not contain the expected text"
fi
}
Expand All @@ -49,7 +54,8 @@ check_output_file "$console_messages_file"
check_output_file "$syslog_file"
check_output_file "$dblog_file"
check_output_file "$stdout_file"
check_output_file "$stderr_file"
check_output_file "$extra_append_file"
check_output_file "$mail_file"
check_output_file "$operator_file"

end_test

0 comments on commit feb314c

Please sign in to comment.