]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add "digdelv" test to simulate DiG network unreachable error
authorAram Sargsyan <aram@isc.org>
Mon, 20 Jun 2022 12:13:44 +0000 (12:13 +0000)
committerAram Sargsyan <aram@isc.org>
Fri, 22 Jul 2022 09:00:31 +0000 (09:00 +0000)
There are existing tests for simulating timeouts, read errors, and
refused connecion errors. Implement also "network unreachable"
simulation.

Use "fixed" string search mode `-F` for `grep` in more places where
it is appropriate to do so.

(cherry picked from commit 626fbf325e048158625d197cd9734da932f6011d)

bin/tests/system/digdelv/tests.sh

index 767e33f8e6674199efc8483df48e404fb03ca841..939560737f811c50f9e36237609288a039ba1ee0 100644 (file)
@@ -1005,7 +1005,7 @@ if [ -x "$DIG" ] ; then
   echo "unstable" | sendcmd 10.53.0.8
   ret=0
   dig_with_opts +timeout=1 +nofail @10.53.0.8 a.example > dig.out.test$n 2>&1 || ret=1
-  grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
+  grep -F "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))
 
@@ -1015,7 +1015,25 @@ if [ -x "$DIG" ] ; then
   echo "unstable" | sendcmd 10.53.0.8
   ret=0
   dig_with_opts +timeout=1 +nofail +tcp @10.53.0.8 a.example > dig.out.test$n 2>&1 || ret=1
-  grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
+  grep -F "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=$((status+ret))
+
+  n=$((n+1))
+  echo_i "check that dig tries the next server after a UDP socket network unreachable error ($n)"
+  ret=0
+  dig_with_opts @192.0.2.128 @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
+  test $(grep -F -e "connection refused" -e "timed out" -e "network unreachable" dig.out.test$n | wc -l) -eq 3 || ret=1
+  grep -F "status: NOERROR" dig.out.test$n > /dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=$((status+ret))
+
+  n=$((n+1))
+  echo_i "check that dig tries the next server after a TCP socket network unreachable error ($n)"
+  ret=0
+  dig_with_opts +tcp @192.0.2.128 @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
+  test $(grep -F -e "connection refused" -e "timed out" -e "network unreachable" dig.out.test$n | wc -l) -eq 3 || ret=1
+  grep -F "status: NOERROR" dig.out.test$n > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))
 
@@ -1023,7 +1041,7 @@ if [ -x "$DIG" ] ; then
   echo_i "check that dig tries the next server after a UDP socket read error ($n)"
   ret=0
   dig_with_opts @10.53.0.99 @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
-  grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
+  grep -F "status: NOERROR" dig.out.test$n > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))
 
@@ -1033,7 +1051,7 @@ if [ -x "$DIG" ] ; then
   echo "close" | sendcmd 10.53.0.8
   ret=0
   dig_with_opts +tcp @10.53.0.8 @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
-  grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
+  grep -F "status: NOERROR" dig.out.test$n > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))
 
@@ -1048,7 +1066,7 @@ if [ -x "$DIG" ] ; then
   ret=0
   dig_with_opts +tcp @10.53.0.99 @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
   test $(grep -F -e "connection refused" -e "timed out" -e "network unreachable" dig.out.test$n | wc -l) -eq 3 || ret=1
-  grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
+  grep -F "status: NOERROR" dig.out.test$n > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))
 
@@ -1058,7 +1076,7 @@ if [ -x "$DIG" ] ; then
   echo "silent" | sendcmd 10.53.0.8
   ret=0
   dig_with_opts +timeout=1 @10.53.0.8 @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
-  grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
+  grep -F "status: NOERROR" dig.out.test$n > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))
 
@@ -1068,7 +1086,7 @@ if [ -x "$DIG" ] ; then
   echo "silent" | sendcmd 10.53.0.8
   ret=0
   dig_with_opts +timeout=1 +tcp @10.53.0.8 @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
-  grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
+  grep -F "status: NOERROR" dig.out.test$n > /dev/null || ret=1
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))