[autotest-client-tests] ubuntu_fan_smoke_test: Add DNS hinting for docker test

Stefan Bader stefan.bader at canonical.com
Fri Nov 17 13:53:27 UTC 2017


When running in an environment which only has systemd-resolvd as
DNS resolver, it is possible that docker cannot figure out the
IP address of the real DNS server to use. Adding --dns in that
case to avoid issues.

Signed-off-by: Stefan Bader <stefan.bader at canonical.com>
---
 ubuntu_fan_smoke_test/smoke_test_old.sh | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/ubuntu_fan_smoke_test/smoke_test_old.sh b/ubuntu_fan_smoke_test/smoke_test_old.sh
index 9622575..eb0d2dc 100755
--- a/ubuntu_fan_smoke_test/smoke_test_old.sh
+++ b/ubuntu_fan_smoke_test/smoke_test_old.sh
@@ -128,7 +128,7 @@ fanatic_enable_docker_test()
 
 fanatic_docker_test()
 {
-	echo -n "fanatic docker test: "
+	echo -n "fanatic docker test"
 	enable_fan
 
 	info=$(ip address | ./extract-fan-info)
@@ -136,7 +136,22 @@ fanatic_docker_test()
 	fan_addr=$(echo $info | cut -d: -f2)
 	enable_docker
 	service docker restart
-	docker run $image sh -c "apt-get update && apt-get install iputils-ping -y && ping -c 10 $fan_addr" > $TMP
+
+	# Docker needs DNS hinting if systemd-resolvd is in charge
+	dns_opt=""
+	dns1=$(awk '$1=="nameserver"{print $2; exit}' /etc/resolv.conf)
+	if [ "$dns1" = "127.0.0.53" ]; then
+		dns_opt="--dns=$(systemd-resolve --status |
+			awk '/DNS Servers:/{
+				sub(/.*DNS Servers: */, "")
+				sub(/,.*/, "")
+				print
+				exit}')"
+		echo -n "($dns_opt): "
+	else
+		echo -n ": "
+	fi
+	docker run $dns_opt $image sh -c "apt-get update && apt-get install iputils-ping -y && ping -c 10 $fan_addr" > $TMP
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		echo "FAILED: (docker run returned $ret)"
-- 
2.7.4





More information about the kernel-team mailing list