blob: b787100d4197601e4dd385c87191333d15bddd94 (
plain)
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
|
#!/usr/bin/env bash
set -e
gitroot=$(git rev-parse --show-toplevel)
cert_file=$gitroot/modules/http/test_tls/test.crt
key_file=$gitroot/modules/http/test_tls/test.key
tls_certificate_conf=$(cat <<EOF
{
"cert-file": "$cert_file",
"key-file": "$key_file"
}
EOF
)
function count_errors(){
echo "$(journalctl -u knot-resolver.service | grep -c error)"
}
function count_reloads(){
echo "$(journalctl -u knot-resolver.service | grep -c "TLS cert files reload triggered")"
}
# test reload without files configure
# {{
err_count=$(count_errors)
rel_count=$(count_reloads)
kresctl reload
if [ $(count_errors) -ne $err_count ] || [ $(count_reloads) -ne $rel_count ]; then
echo "TLS cert files reload triggered when should not be."
exit 1
fi
# }}
# configure TLS certificate files
kresctl config set -p /network/tls "$tls_certificate_conf"
if [ "$?" -ne "0" ]; then
echo "Could not set TLS certificate files."
exit 1
fi
# test reload on no config changes
# {{
rel_count=$(count_reloads)
kresctl config set -p /workers 2
if [ $(count_errors) -ne $err_count ] || [ $(count_reloads) -eq $rel_count ]; then
echo "TLS cert files reload not triggered whe should be."
exit 1
fi
# }}
# test reload on config changes
# {{
rel_count=$(count_reloads)
kresctl config set -p /workers 5
if [ $(count_errors) -ne $err_count ] || [ $(count_reloads) -ne $rel_count ]; then
echo "TLS cert files reload triggered when should not be."
exit 1
fi
# }}
# test reload again on no config changes
# {{
rel_count=$(count_reloads)
kresctl config set -p /workers 5
if [ $(count_errors) -ne $err_count ] || [ $(count_reloads) -eq $rel_count ]; then
echo "TLS cert files reload not triggered whe should be."
exit 1
fi
# }}
# reload to defaults
kresctl reload
if [ "$?" -ne "0" ]; then
echo "The resolver reload failed."
exit 1
fi
|