tests.sh 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. sleep 2
  80. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  81. # perform a simple check on the output (digcomp would be too much for this)
  82. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  83. if [ $status != 0 ]; then echo "I:failed"; fi
  84. n=`expr $n + 1`
  85. echo "I:Rechecking BIND 10 statistics after a pause ($n)"
  86. sleep 2
  87. echo 'Stats show
  88. ' | $RUN_BINDCTL \
  89. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  90. # The statistics counters can not be reset even after auth
  91. # restarts. Because stats preserves the query counts which the dying
  92. # auth sent. Then it cumulates them and new counts which the living
  93. # auth sends. This note assumes that the issue would have been
  94. # resolved : "#1941 stats lossage (multiple auth servers)".
  95. cnt_value1=`expr $cnt_value1 + 0`
  96. cnt_value2=`expr $cnt_value2 + 1`
  97. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  98. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  99. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  100. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  101. if [ $status != 0 ]; then echo "I:failed"; fi
  102. n=`expr $n + 1`
  103. echo "I:Changing the data source from sqlite3 to in-memory ($n)"
  104. DATASRC_SPEC='{"type": "MasterFiles", "cache-enable": true, "params": {"com":'
  105. DATASRC_SPEC="${DATASRC_SPEC} \"${TEST_TOP}/bindctl/nsx1/example-normalized.db\"}}"
  106. echo "config set data_sources/classes/IN[0] ${DATASRC_SPEC}
  107. config commit
  108. quit
  109. " | $RUN_BINDCTL \
  110. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  111. sleep 2
  112. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  113. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  114. if [ $status != 0 ]; then echo "I:failed"; fi
  115. n=`expr $n + 1`
  116. echo "I:Rechecking BIND 10 statistics after changing the datasource ($n)"
  117. sleep 2
  118. echo 'Stats show
  119. ' | $RUN_BINDCTL \
  120. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  121. # The statistics counters shouldn't be reset due to hot-swapping datasource.
  122. cnt_value1=`expr $cnt_value1 + 0`
  123. cnt_value2=`expr $cnt_value2 + 1`
  124. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  125. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  126. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  127. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  128. if [ $status != 0 ]; then echo "I:failed"; fi
  129. n=`expr $n + 1`
  130. echo "I:Starting more b10-auths and checking that ($n)"
  131. for i in 2 3
  132. do
  133. echo 'config add Boss/components b10-auth-'$i'
  134. config set Boss/components/b10-auth-'$i' { "special": "auth", "kind": "needed" }
  135. config commit
  136. quit
  137. ' | $RUN_BINDCTL \
  138. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  139. done
  140. sleep 2
  141. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  142. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  143. if [ $status != 0 ]; then echo "I:failed"; fi
  144. n=`expr $n + 1`
  145. echo "I:Rechecking BIND 10 statistics consistency after a pause ($n)"
  146. sleep 2
  147. cnt_value1=`expr $cnt_value1 + 0`
  148. cnt_value2=`expr $cnt_value2 + 1`
  149. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  150. # Rechecking some times
  151. for i in 1 2 3 4
  152. do
  153. echo 'Stats show
  154. ' | $RUN_BINDCTL \
  155. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  156. # The statistics counters should keep being consistent even while
  157. # multiple b10-auths are running.
  158. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  159. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  160. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  161. if [ $status != 0 ]; then echo "I:failed "; break ; fi
  162. done
  163. n=`expr $n + 1`
  164. echo "I:Stopping extra b10-auths and checking that ($n)"
  165. for i in 3 2
  166. do
  167. echo 'config remove Boss/components b10-auth-'$i'
  168. config commit
  169. quit
  170. ' | $RUN_BINDCTL \
  171. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  172. done
  173. sleep 2
  174. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  175. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  176. if [ $status != 0 ]; then echo "I:failed"; fi
  177. n=`expr $n + 1`
  178. # The statistics counters can not be rechecked here because the auth
  179. # instance seems to hang up after one of the multiple auth instances
  180. # was removed via bindctl. This reason seems to be the same reason as
  181. # #1703.
  182. echo "I:exit status: $status"
  183. exit $status