tests.sh 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
  4. #
  5. # Permission to use, copy, modify, and/or distribute this software for any
  6. # purpose with or without fee is hereby granted, provided that the above
  7. # copyright notice and this permission notice appear in all copies.
  8. #
  9. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  10. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  14. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. # PERFORMANCE OF THIS SOFTWARE.
  16. SYSTEMTESTTOP=..
  17. . $SYSTEMTESTTOP/conf.sh
  18. #
  19. # Do bindctl tests.
  20. #
  21. status=0
  22. n=0
  23. # TODO: consider consistency with statistics definition in auth.spec
  24. cnt_name1="\<queries\.tcp\>"
  25. cnt_name2="\<queries\.udp\>"
  26. cnt_name3="\<opcode\.query\>"
  27. cnt_value1=0
  28. cnt_value2=0
  29. cnt_value3=0
  30. echo "I:Checking b10-auth is disabled by default ($n)"
  31. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A > /dev/null && status=1
  32. if [ $status != 0 ]; then echo "I:failed"; fi
  33. n=`expr $n + 1`
  34. echo "I:Starting b10-auth and checking that it works ($n)"
  35. echo 'config add Boss/components b10-auth
  36. config set Boss/components/b10-auth { "special": "auth", "kind": "needed" }
  37. config commit
  38. quit
  39. ' | $RUN_BINDCTL \
  40. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  41. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  42. # perform a simple check on the output (digcomp would be too much for this)
  43. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  44. if [ $status != 0 ]; then echo "I:failed"; fi
  45. n=`expr $n + 1`
  46. echo "I:Checking BIND 10 statistics after a pause ($n)"
  47. # wait for 2sec to make sure b10-stats gets the latest statistics.
  48. sleep 2
  49. echo 'Stats show
  50. ' | $RUN_BINDCTL \
  51. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  52. # the server should have received 1 UDP and 0 TCP queries (the server
  53. # startup script no longer sends any TCP queries)
  54. cnt_value1=`expr $cnt_value1 + 0`
  55. cnt_value2=`expr $cnt_value2 + 1`
  56. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  57. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  58. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  59. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  60. if [ $status != 0 ]; then echo "I:failed"; fi
  61. n=`expr $n + 1`
  62. echo "I:Stopping b10-auth and checking that ($n)"
  63. echo 'config remove Boss/components b10-auth
  64. config commit
  65. quit
  66. ' | $RUN_BINDCTL \
  67. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  68. # dig should exit with a failure code.
  69. $DIG +tcp +norec @10.53.0.1 -p 53210 ns.example.com. A > /dev/null && status=1
  70. if [ $status != 0 ]; then echo "I:failed"; fi
  71. n=`expr $n + 1`
  72. echo "I:Restarting b10-auth and checking that ($n)"
  73. echo 'config add Boss/components b10-auth
  74. config set Boss/components/b10-auth { "special": "auth", "kind": "needed" }
  75. config commit
  76. quit
  77. ' | $RUN_BINDCTL \
  78. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  79. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  80. # perform a simple check on the output (digcomp would be too much for this)
  81. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  82. if [ $status != 0 ]; then echo "I:failed"; fi
  83. n=`expr $n + 1`
  84. echo "I:Rechecking BIND 10 statistics after a pause ($n)"
  85. sleep 2
  86. echo 'Stats show
  87. ' | $RUN_BINDCTL \
  88. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  89. # The statistics counters can not be reset even after auth
  90. # restarts. Because stats preserves the query counts which the dying
  91. # auth sent. Then it cumulates them and new counts which the living
  92. # auth sends. This note assumes that the issue would have been
  93. # resolved : "#1941 stats lossage (multiple auth servers)".
  94. cnt_value1=`expr $cnt_value1 + 0`
  95. cnt_value2=`expr $cnt_value2 + 1`
  96. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  97. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  98. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  99. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  100. if [ $status != 0 ]; then echo "I:failed"; fi
  101. n=`expr $n + 1`
  102. echo "I:Changing the data source from sqlite3 to in-memory ($n)"
  103. DATASRC_SPEC='{"type": "MasterFiles", "cache-enable": true, "params": {"com":'
  104. DATASRC_SPEC="${DATASRC_SPEC} \"${TEST_TOP}/bindctl/nsx1/example-normalized.db\"}}"
  105. echo "config set data_sources/classes/IN[0] ${DATASRC_SPEC}
  106. config commit
  107. quit
  108. " | $RUN_BINDCTL \
  109. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  110. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  111. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  112. if [ $status != 0 ]; then echo "I:failed"; fi
  113. n=`expr $n + 1`
  114. echo "I:Rechecking BIND 10 statistics after changing the datasource ($n)"
  115. sleep 2
  116. echo 'Stats show
  117. ' | $RUN_BINDCTL \
  118. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  119. # The statistics counters shouldn't be reset due to hot-swapping datasource.
  120. cnt_value1=`expr $cnt_value1 + 0`
  121. cnt_value2=`expr $cnt_value2 + 1`
  122. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  123. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  124. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  125. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  126. if [ $status != 0 ]; then echo "I:failed"; fi
  127. n=`expr $n + 1`
  128. echo "I:Starting more b10-auths and checking that ($n)"
  129. for i in 2 3
  130. do
  131. echo 'config add Boss/components b10-auth-'$i'
  132. config set Boss/components/b10-auth-'$i' { "special": "auth", "kind": "needed" }
  133. config commit
  134. quit
  135. ' | $RUN_BINDCTL \
  136. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  137. done
  138. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  139. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  140. if [ $status != 0 ]; then echo "I:failed"; fi
  141. n=`expr $n + 1`
  142. echo "I:Rechecking BIND 10 statistics consistency after a pause ($n)"
  143. sleep 2
  144. cnt_value1=`expr $cnt_value1 + 0`
  145. cnt_value2=`expr $cnt_value2 + 1`
  146. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  147. # Rechecking some times
  148. for i in 1 2 3 4
  149. do
  150. echo 'Stats show
  151. ' | $RUN_BINDCTL \
  152. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  153. # The statistics counters should keep being consistent even while
  154. # multiple b10-auths are running.
  155. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  156. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  157. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  158. if [ $status != 0 ]; then echo "I:failed "; break ; fi
  159. done
  160. n=`expr $n + 1`
  161. echo "I:Stopping extra b10-auths and checking that ($n)"
  162. for i in 3 2
  163. do
  164. echo 'config remove Boss/components b10-auth-'$i'
  165. config commit
  166. quit
  167. ' | $RUN_BINDCTL \
  168. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  169. done
  170. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  171. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  172. if [ $status != 0 ]; then echo "I:failed"; fi
  173. n=`expr $n + 1`
  174. # The statistics counters can not be rechecked here because the auth
  175. # instance seems to hang up after one of the multiple auth instances
  176. # was removed via bindctl. This reason seems to be the same reason as
  177. # #1703.
  178. echo "I:exit status: $status"
  179. exit $status