summaryrefslogtreecommitdiffstats
path: root/debian/tests/smoke-tests
blob: 9aa95926507bdd45a09364106d3f2fc3165e4551 (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
#!/bin/bash

set -exo pipefail

# 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 control agent API
TEST_KEA_VERSION=$(curl -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 version-get | jq -r '.[0].text')
check_kea_version "${TEST_KEA_VERSION}"