tests.sh 7.1 KB

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