git » dnss » commit ee1975e

tests: Add systemd socket activation tests

author Alberto Bertogli
2018-07-21 11:41:25 UTC
committer Alberto Bertogli
2018-07-21 11:41:25 UTC
parent ad1caccba4d1ca5e287eb9e2f4b774414a7439f6

tests: Add systemd socket activation tests

tests/external.sh +24 -1

diff --git a/tests/external.sh b/tests/external.sh
index 0de84db..9d503ae 100755
--- a/tests/external.sh
+++ b/tests/external.sh
@@ -40,7 +40,7 @@ function dnss() {
 			-test.coverprofile=$COVER_DIR/it-`date +%s.%N`.out"
 	fi
 
-	./dnss $COVER_ARGS \
+	$SYSTEMD_ACTIVATE ./dnss $COVER_ARGS \
 		-v 3 -monitoring_listen_addr :1900 \
 		"$@" > .dnss.log 2>&1 &
 	PID=$!
@@ -187,4 +187,27 @@ get http://localhost:1900/debug/dnsserver/cache/flush
 
 kill $PID
 
+
+# systemd socket activation tests must check one protocol at a time, due to
+# systemd-socket-activate not being able to listen on both.
+echo "## Socket activation via systemd: TCP"
+SYSTEMD_ACTIVATE="systemd-socket-activate -l 1053"
+dnss -enable_dns_to_https -dns_listen_addr "systemd"
+
+wait_until_ready tcp 1053
+kdig @127.0.0.1:1053 +tcp  example.com a > .dig.log
+grep -E -q '^example.com.*A'  .dig.log
+
+kill $PID
+
+echo "## Socket activation via systemd: UDP"
+SYSTEMD_ACTIVATE="systemd-socket-activate -d -l 1053"
+dnss -enable_dns_to_https -dns_listen_addr "systemd"
+
+kdig @127.0.0.1:1053 +notcp  example.com a > .dig.log
+grep -E -q '^example.com.*A'  .dig.log
+
+kill $PID
+
+
 echo SUCCESS