-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/packaging/interactive: added files_reload.sh
- Loading branch information
1 parent
661ba5b
commit eebf16f
Showing
1 changed file
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
|