tests.sh 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. # note that we set statistics-interval to 1.
  49. sleep 2
  50. echo 'Stats show
  51. ' | $RUN_BINDCTL \
  52. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  53. # the server should have received 1 UDP and 0 TCP queries (the server
  54. # startup script no longer sends any TCP queries)
  55. cnt_value1=`expr $cnt_value1 + 0`
  56. cnt_value2=`expr $cnt_value2 + 1`
  57. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  58. # Further changes of Boss(#2137) and Auth(#2138) depends on this
  59. # change(#2136). So statistics tests in this system test make no
  60. # sense. Following statistics tests are disabled until codes of both
  61. # #2137 and #2138 are merged.
  62. #grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  63. #grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  64. #grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  65. #if [ $status != 0 ]; then echo "I:failed"; fi
  66. echo "I:skipped"
  67. n=`expr $n + 1`
  68. echo "I:Stopping b10-auth and checking that ($n)"
  69. echo 'config remove Boss/components b10-auth
  70. config commit
  71. quit
  72. ' | $RUN_BINDCTL \
  73. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  74. # dig should exit with a failure code.
  75. $DIG +tcp +norec @10.53.0.1 -p 53210 ns.example.com. A > /dev/null && status=1
  76. if [ $status != 0 ]; then echo "I:failed"; fi
  77. n=`expr $n + 1`
  78. echo "I:Restarting b10-auth and checking that ($n)"
  79. echo 'config add Boss/components b10-auth
  80. config set Boss/components/b10-auth { "special": "auth", "kind": "needed" }
  81. config commit
  82. quit
  83. ' | $RUN_BINDCTL \
  84. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  85. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  86. # perform a simple check on the output (digcomp would be too much for this)
  87. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  88. if [ $status != 0 ]; then echo "I:failed"; fi
  89. n=`expr $n + 1`
  90. echo "I:Rechecking BIND 10 statistics after a pause ($n)"
  91. sleep 2
  92. echo 'Stats show
  93. ' | $RUN_BINDCTL \
  94. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  95. # The statistics counters can not be reset even after auth
  96. # restarts. Because stats preserves the query counts which the dying
  97. # auth sent. Then it cumulates them and new counts which the living
  98. # auth sends. This note assumes that the issue would have been
  99. # resolved : "#1941 stats lossage (multiple auth servers)".
  100. cnt_value1=`expr $cnt_value1 + 0`
  101. cnt_value2=`expr $cnt_value2 + 1`
  102. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  103. # Further changes of Boss(#2137) and Auth(#2138) depends on this
  104. # change(#2136). So statistics tests in this system test make no
  105. # sense. Following statistics tests are disabled until codes of both
  106. # #2137 and #2138 are merged.
  107. #grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  108. #grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  109. #grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  110. #if [ $status != 0 ]; then echo "I:failed"; fi
  111. echo "I:skipped"
  112. n=`expr $n + 1`
  113. echo "I:Changing the data source from sqlite3 to in-memory ($n)"
  114. DATASRC_SPEC='{"type": "MasterFiles", "cache-enable": true, "params": {"com":'
  115. DATASRC_SPEC="${DATASRC_SPEC} \"${TEST_TOP}/bindctl/nsx1/example-normalized.db\"}}"
  116. echo "config set data_sources/classes/IN[0] ${DATASRC_SPEC}
  117. config commit
  118. quit
  119. " | $RUN_BINDCTL \
  120. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  121. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  122. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  123. if [ $status != 0 ]; then echo "I:failed"; fi
  124. n=`expr $n + 1`
  125. echo "I:Rechecking BIND 10 statistics after changing the datasource ($n)"
  126. sleep 2
  127. echo 'Stats show
  128. ' | $RUN_BINDCTL \
  129. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  130. # The statistics counters shouldn't be reset due to hot-swapping datasource.
  131. cnt_value1=`expr $cnt_value1 + 0`
  132. cnt_value2=`expr $cnt_value2 + 1`
  133. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  134. # Further changes of Boss(#2137) and Auth(#2138) depends on this
  135. # change(#2136). So statistics tests in this system test make no
  136. # sense. Following statistics tests are disabled until codes of both
  137. # #2137 and #2138 are merged.
  138. #grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  139. #grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  140. #grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  141. #if [ $status != 0 ]; then echo "I:failed"; fi
  142. echo "I:skipped"
  143. n=`expr $n + 1`
  144. echo "I:Starting more b10-auths and checking that ($n)"
  145. for i in 2 3
  146. do
  147. echo 'config add Boss/components b10-auth-'$i'
  148. config set Boss/components/b10-auth-'$i' { "special": "auth", "kind": "needed" }
  149. config commit
  150. quit
  151. ' | $RUN_BINDCTL \
  152. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  153. done
  154. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  155. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  156. if [ $status != 0 ]; then echo "I:failed"; fi
  157. n=`expr $n + 1`
  158. echo "I:Rechecking BIND 10 statistics consistency after a pause ($n)"
  159. sleep 2
  160. cnt_value1=`expr $cnt_value1 + 0`
  161. cnt_value2=`expr $cnt_value2 + 1`
  162. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  163. # Rechecking some times
  164. for i in 1 2 3 4
  165. do
  166. echo 'Stats show
  167. ' | $RUN_BINDCTL \
  168. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  169. # The statistics counters should keep being consistent even while
  170. # multiple b10-auths are running.
  171. # Further changes of Boss(#2137) and Auth(#2138) depends on this
  172. # change(#2136). So statistics tests in this system test make no
  173. # sense. Following statistics tests are disabled until codes of both
  174. # #2137 and #2138 are merged.
  175. #grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  176. #grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  177. #grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  178. #if [ $status != 0 ]; then echo "I:failed "; break ; fi
  179. echo "I:skipped"
  180. done
  181. n=`expr $n + 1`
  182. echo "I:Stopping extra b10-auths and checking that ($n)"
  183. for i in 3 2
  184. do
  185. echo 'config remove Boss/components b10-auth-'$i'
  186. config commit
  187. quit
  188. ' | $RUN_BINDCTL \
  189. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  190. done
  191. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  192. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  193. if [ $status != 0 ]; then echo "I:failed"; fi
  194. n=`expr $n + 1`
  195. # The statistics counters can not be rechecked here because the auth
  196. # instance seems to hang up after one of the multiple auth instances
  197. # was removed via bindctl. This reason seems to be the same reason as
  198. # #1703.
  199. echo "I:exit status: $status"
  200. exit $status