Skip to content

Commit

Permalink
manager/tests/packaging: More verbose systemd_service tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Oto Šťáva committed Jan 18, 2024
1 parent 303a2af commit 1713198
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
6 changes: 5 additions & 1 deletion manager/tests/packaging/interactive/etag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set -e

socket_opt="--unix-socket /var/run/knot-resolver/manager.sock"

echo " etag"
etag="$(curl --silent $socket_opt --fail http://localhost:5000/v1/config -o /dev/null -v 2>&1 | grep ETag | sed 's/< ETag: //;s/\s//')"
status=$(curl --silent $socket_opt --fail http://localhost:5000/v1/config --header "If-None-Match: $etag" -w "%{http_code}" -o /dev/null)
echo " etag OK"

echo " status"
status=$(curl --silent $socket_opt --fail http://localhost:5000/v1/config --header "If-None-Match: $etag" -w "%{http_code}" -o /dev/null)
test "$status" -eq 304
echo " status OK"
4 changes: 3 additions & 1 deletion manager/tests/packaging/interactive/metrics.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

curl --silent --fail --unix-socket /var/run/knot-resolver/manager.sock http://localhost/metrics > /dev/null
set -e

curl --silent --fail --unix-socket /var/run/knot-resolver/manager.sock http://localhost/metrics > /dev/null
20 changes: 17 additions & 3 deletions manager/tests/packaging/interactive/workers.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
#!/bin/bash

set -e
expected_workers="5"

kresctl config set -p /workers 5
kresctl config set -p /workers "$expected_workers"
if [ "$?" -ne "0" ]; then
echo "Could not configure $expected_workers workers"
exit 1
fi

test "$(ps -a -x | grep kresd | grep -v grep | wc -l)" -eq 5
ps_result="$(ps -a -x | grep kresd | grep -v grep)"
actual_processes="$(echo "$ps_result" | wc -l)"
if [ "$actual_processes" -ne "$expected_workers" ]; then
echo "Incorrect number of workers"
echo "Found workers:"
echo "$ps_result"
echo ""
echo "(actual) != (expected)"
echo "$actual_processes != $expected_workers"
exit 1
fi
14 changes: 13 additions & 1 deletion manager/tests/packaging/systemd_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,25 @@ if ! systemctl start knot-resolver.service; then
id knot-resolver
exit 1
else
set +e

# check that the resolvers are actually running
kdig @127.0.0.1 nic.cz
if [ "$?" -ne "0" ]; then
echo "Could not 'kdig' the resolvers - are they running?"
exit 1
fi

echo "Running interactive tests..."
exit_code="0"
for test in "$(dirname $0)"/interactive/*; do
echo "[test] $test"
$test
if [ "$?" -ne "0" ]; then
echo "[test] $test FAILED"
exit_code="1"
fi
echo "[test] $test OK"
done
exit "$exit_code"
fi

0 comments on commit 1713198

Please sign in to comment.