diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 14:53:52 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 14:53:52 +0000 |
commit | 3ed143456d4270196c89e8e7e57badd439b44df4 (patch) | |
tree | fb241ff60337a450c34bfa02210a10fe0ddc9073 /debian/tests/smoke-tests | |
parent | Adding upstream version 2.5.7. (diff) | |
download | isc-kea-debian.tar.xz isc-kea-debian.zip |
Adding debian version 2.4.1-3.debian/2.4.1-3debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests/smoke-tests')
-rw-r--r-- | debian/tests/smoke-tests | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/debian/tests/smoke-tests b/debian/tests/smoke-tests new file mode 100644 index 0000000..2de85c4 --- /dev/null +++ b/debian/tests/smoke-tests @@ -0,0 +1,63 @@ +#!/bin/bash + +set -exo pipefail + +# kea-ctrl-agent needs a password file, or else it won't start +# this also tests the debconf mechanism +debconf-set-selections << eof +kea-ctrl-agent kea-ctrl-agent/make_a_choice select configured_random_password +eof + +dpkg-reconfigure kea-ctrl-agent +kea_password_file="/etc/kea/kea-api-password" +[ -s "${kea_password_file}" ] || { + echo "ERROR, debconf-set-selections failed to set a password for kea-ctrl-agent" + exit 1 +} + +# Arbitrary wait to allow for the services to start. +# This is needed to avoid having racy/flaky tests. +sleep 5 + +# Check that the PID files are in the right location +for f in kea-dhcp4.kea-dhcp4.pid kea-dhcp6.kea-dhcp6.pid kea-ctrl-agent.kea-ctrl-agent.pid kea-dhcp-ddns.kea-dhcp-ddns.pid; do + test -f "/run/kea/$f" +done + +# Check that the sockets are in the right location +for socket in kea-ddns-ctrl-socket kea4-ctrl-socket kea6-ctrl-socket; do + test -S "/run/kea/$socket" +done + +# Check that lock files are in the right location +test -f /run/lock/kea/logger_lockfile + +check_kea_version() { + CHECKED_VERSION=$1 + if [[ ! ${CHECKED_VERSION} =~ [0-9]+(\.[0-9]+){2} ]]; then + echo "Version [ ${CHECKED_VERSION} ] does not match X.Y.Z format" + exit 1 + fi +} + +# Check dhcp4 server configuration file +kea-dhcp4 -t /etc/kea/kea-dhcp4.conf > /dev/null + +# Check dhcp6 server configuration file +kea-dhcp6 -t /etc/kea/kea-dhcp6.conf > /dev/null + +# Check if we need to provide authentication +auth_params="" +basic_auth_params="" +if [ -s /etc/kea/kea-api-password ]; then + auth_params="--auth-user kea-api --auth-password $(cat /etc/kea/kea-api-password)" + basic_auth_params="-u kea-api:$(cat /etc/kea/kea-api-password)" +fi + +# Check control agent API +TEST_KEA_VERSION=$(curl ${basic_auth_params} -s -X POST -H "Content-Type: application/json" -d '{ "command": "version-get", "service": [ "dhcp4" ] }' 127.0.0.1:8000 | jq -r '.[0].text') +check_kea_version "${TEST_KEA_VERSION}" + +# Check control agent API through kea-shell +TEST_KEA_VERSION=$(echo | kea-shell --service dhcp4 --host 127.0.0.1 --port 8000 ${auth_params} version-get | jq -r '.[0].text') +check_kea_version "${TEST_KEA_VERSION}" |