tests.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 working by default ($n)"
  31. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  32. # perform a simple check on the output (digcomp would be too much for this)
  33. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  34. if [ $status != 0 ]; then echo "I:failed"; fi
  35. n=`expr $n + 1`
  36. echo "I:Checking BIND 10 statistics after a pause ($n)"
  37. # wait for 2sec to make sure b10-stats gets the latest statistics.
  38. # note that we set statistics-interval to 1.
  39. sleep 2
  40. echo 'Stats show
  41. ' | $RUN_BINDCTL \
  42. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  43. # the server should have received 1 UDP and 1 TCP queries (TCP query was
  44. # sent from the server startup script)
  45. cnt_value1=`expr $cnt_value1 + 1`
  46. cnt_value2=`expr $cnt_value2 + 1`
  47. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  48. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  49. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  50. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  51. if [ $status != 0 ]; then echo "I:failed"; fi
  52. n=`expr $n + 1`
  53. echo "I:Stopping b10-auth and checking that ($n)"
  54. echo 'config remove Boss/components b10-auth
  55. config commit
  56. quit
  57. ' | $RUN_BINDCTL \
  58. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  59. # dig should exit with a failure code.
  60. $DIG +tcp +norec @10.53.0.1 -p 53210 ns.example.com. A && status=1
  61. if [ $status != 0 ]; then echo "I:failed"; fi
  62. n=`expr $n + 1`
  63. echo "I:Restarting b10-auth and checking that ($n)"
  64. echo 'config add Boss/components b10-auth
  65. config set Boss/components/b10-auth { "special": "auth", "kind": "needed" }
  66. config commit
  67. quit
  68. ' | $RUN_BINDCTL \
  69. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  70. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  71. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  72. if [ $status != 0 ]; then echo "I:failed"; fi
  73. n=`expr $n + 1`
  74. echo "I:Rechecking BIND 10 statistics after a pause ($n)"
  75. sleep 2
  76. echo 'Stats show
  77. ' | $RUN_BINDCTL \
  78. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  79. # The statistics counters should have been reset while stop/start.
  80. cnt_value1=0
  81. cnt_value2=1
  82. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  83. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  84. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  85. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  86. if [ $status != 0 ]; then echo "I:failed"; fi
  87. n=`expr $n + 1`
  88. echo "I:Changing the data source from sqlite3 to in-memory ($n)"
  89. DATASRC_SPEC='[{"type": "memory", "zones": [{"origin": "com","file":'
  90. DATASRC_SPEC="${DATASRC_SPEC} \"${TEST_TOP}/bindctl/nsx1/example-normalized.db\"}]}]"
  91. echo "config set Auth/datasources ${DATASRC_SPEC}
  92. config commit
  93. quit
  94. " | $RUN_BINDCTL \
  95. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  96. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  97. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  98. if [ $status != 0 ]; then echo "I:failed"; fi
  99. n=`expr $n + 1`
  100. echo "I:Rechecking BIND 10 statistics after changing the datasource ($n)"
  101. sleep 2
  102. echo 'Stats show
  103. ' | $RUN_BINDCTL \
  104. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  105. # The statistics counters shouldn't be reset due to hot-swapping datasource.
  106. cnt_value1=`expr $cnt_value1 + 0`
  107. cnt_value2=`expr $cnt_value2 + 1`
  108. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  109. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  110. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  111. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  112. if [ $status != 0 ]; then echo "I:failed"; fi
  113. n=`expr $n + 1`
  114. echo "I:Starting more b10-auths and checking that ($n)"
  115. for i in 2 3
  116. do
  117. echo 'config add Boss/components b10-auth-'$i'
  118. config set Boss/components/b10-auth-'$i' { "special": "auth", "kind": "needed" }
  119. config commit
  120. quit
  121. ' | $RUN_BINDCTL \
  122. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  123. done
  124. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  125. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  126. if [ $status != 0 ]; then echo "I:failed"; fi
  127. n=`expr $n + 1`
  128. echo "I:Rechecking BIND 10 statistics consistency after a pause ($n)"
  129. sleep 2
  130. cnt_value1=`expr $cnt_value1 + 0`
  131. cnt_value2=`expr $cnt_value2 + 1`
  132. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  133. # Rechecking some times
  134. for i in 1 2 3 4
  135. do
  136. echo 'Stats show
  137. ' | $RUN_BINDCTL \
  138. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  139. # The statistics counters should keep being consistent even while
  140. # multiple b10-auths are running.
  141. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  142. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  143. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  144. if [ $status != 0 ]; then echo "I:failed "; break ; fi
  145. done
  146. n=`expr $n + 1`
  147. echo "I:Stopping extra b10-auths and checking that ($n)"
  148. for i in 3 2
  149. do
  150. echo 'config remove Boss/components b10-auth-'$i'
  151. config commit
  152. quit
  153. ' | $RUN_BINDCTL \
  154. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  155. done
  156. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  157. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  158. if [ $status != 0 ]; then echo "I:failed"; fi
  159. n=`expr $n + 1`
  160. # The statistics counters can not be rechecked here because the auth
  161. # instance seems to hang up after one of the multiple auth instances
  162. # was removed via bindctl. This reason seems to be the same reason as
  163. # #1703.
  164. echo "I:exit status: $status"
  165. exit $status