-
Notifications
You must be signed in to change notification settings - Fork 256
/
testrunner
executable file
·114 lines (90 loc) · 2.4 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
112
113
#!/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/another_client.conf"
bconsole_command_file="$tmp/bconsole_reload_command"
console_logfile="$tmp/console.log"
console_show_client_output_file="$tmp/list_of_clients.out"
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
}
start_director() {
"${scripts}/bareos-ctl-dir" start "$director_debug_level"
director_pid=$(pidof ${BAREOS_DIRECTOR_BINARY})
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_added_client_in_config() {
echo "show client" | bin/bconsole > "$console_show_client_output_file"
if ! grep -wq "bareos-fd-2" "$console_show_client_output_file"; then
exit_with_error 'Could not find client "bareos-fd-2" in console output'
fi
}
add_another_client() {
cat <<END_OF_DATA > "$temporary_config_file"
Client {
Name = bareos-fd-2
Description = "Another Client resource."
Address = localhost
Password = "@fd_password@" # password for FileDaemon
FD PORT = @fd_port@
}
END_OF_DATA
}
remove_console_logfiles() {
rm -f "$console_logfile"
rm -f "$console_show_client_output_file"
}
############################################
start_test
############################################
#be sure no director is started
stop_director
#cleanup possible leftover from last run
${scripts}/cleanup
remove_console_logfiles
${scripts}/setup
start_director
#reload modified config
add_another_client
test_reload_will_not_crash_director
find_added_client_in_config
stop_director
############################################
end_test
############################################