/
testrunner
executable file
·112 lines (88 loc) · 2.35 KB
/
testrunner
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/sh
#
#set -x
#trap read debug
TestName="$(basename "$(pwd)")"
export TestName
export estat
# shellcheck disable=SC1091
. ./environment
. ${scripts}/functions
temporary_config_file="$config_directory_dir_additional_test_config/uncommented_string.conf"
bconsole_command_file="$tmp/bconsole_reload_command"
console_logfile="$tmp/console.log"
director_debug_level=""
#director_debug_level="-d 200"
exit_with_error() {
echo "$1"
estat=1
end_test
exit 1
}
stop_director() {
"${scripts}/bareos-ctl-dir" stop
if [ -n "$(pidof bareos-dir)" ]; then
killall -SIGKILL "$(pidof bareos-dir)"
fi
if [ -n "$(pidof bareos-dir)" ]; then
exit_with_error "Bareos director could not be stopped"
fi
}
start_director() {
"${scripts}/bareos-ctl-dir" start "$director_debug_level"
director_pid=$(pidof bareos-dir)
if [ -z "$director_pid" ]; then
exit_with_error "Bareos director could not be started"
fi
}
create_console_command_file() {
if [ ! -f "$bconsole_command_file" ]; then
cat > "$bconsole_command_file" <<EOF
@$out "$console_logfile"
reload
messages
EOF
fi
}
test_reload_will_not_crash_director() {
create_console_command_file
"$bin"/bconsole -c "$conf"/bconsole.conf < "$bconsole_command_file" 2>&1 >> /dev/null
if [ $? != 0 ] ; then
exit_with_error "BConsole finished with errors"
fi
if ! ps $director_pid > /dev/null; then
exit_with_error "Bareos director should not stop after reload"
fi
}
find_error_string_in_console_log() {
err='This is an uncommented string that causes a config abort.'
if ! grep -q "$err" "$console_logfile"; then
exit_with_error "Could not find error string in console output"
fi
}
add_uncommented_string_to_config() {
cat <<END_OF_DATA > "$temporary_config_file"
This is an uncommented string that causes a config abort.
END_OF_DATA
}
remove_console_logfile() {
rm -f "$console_logfile"
}
############################################
start_test
############################################
#be sure no director is started
stop_director
#cleanup possible leftover from last run
${scripts}/cleanup
remove_console_logfile
${scripts}/setup
start_director
#reload modified config
add_uncommented_string_to_config
test_reload_will_not_crash_director
find_error_string_in_console_log
stop_director
############################################
end_test
############################################