tests.sh 7.1 KB

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