tests.sh 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 can not be reset even after auth
  80. # restarts. Because stats preserves the query counts which the dying
  81. # auth sent. Then it cumulates them and new counts which the living
  82. # auth sends.
  83. cnt_value1=`expr $cnt_value1 + 0`
  84. cnt_value2=`expr $cnt_value2 + 1`
  85. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  86. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  87. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  88. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  89. if [ $status != 0 ]; then echo "I:failed"; fi
  90. n=`expr $n + 1`
  91. echo "I:Changing the data source from sqlite3 to in-memory ($n)"
  92. DATASRC_SPEC='[{"type": "memory", "zones": [{"origin": "com","file":'
  93. DATASRC_SPEC="${DATASRC_SPEC} \"${TEST_TOP}/bindctl/nsx1/example-normalized.db\"}]}]"
  94. echo "config set Auth/datasources ${DATASRC_SPEC}
  95. config commit
  96. quit
  97. " | $RUN_BINDCTL \
  98. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  99. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  100. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  101. if [ $status != 0 ]; then echo "I:failed"; fi
  102. n=`expr $n + 1`
  103. echo "I:Rechecking BIND 10 statistics after changing the datasource ($n)"
  104. sleep 2
  105. echo 'Stats show
  106. ' | $RUN_BINDCTL \
  107. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  108. # The statistics counters shouldn't be reset due to hot-swapping datasource.
  109. cnt_value1=`expr $cnt_value1 + 0`
  110. cnt_value2=`expr $cnt_value2 + 1`
  111. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  112. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  113. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  114. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  115. if [ $status != 0 ]; then echo "I:failed"; fi
  116. n=`expr $n + 1`
  117. echo "I:Starting another b10-auth and checking that ($n)"
  118. echo 'config add Boss/components b10-auth-2
  119. config set Boss/components/b10-auth { "special": "auth", "kind": "needed" }
  120. config commit
  121. quit
  122. ' | $RUN_BINDCTL \
  123. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  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 after a pause ($n)"
  129. sleep 2
  130. echo 'Stats show
  131. ' | $RUN_BINDCTL \
  132. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  133. # The statistics counters should keep increasing even after another
  134. # b10-auth starts.
  135. cnt_value1=`expr $cnt_value1 + 0`
  136. cnt_value2=`expr $cnt_value2 + 1`
  137. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  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. n=`expr $n + 1`
  143. echo "I:Stopping the second b10-auth and checking that ($n)"
  144. echo 'config remove Boss/components b10-auth-2
  145. config commit
  146. quit
  147. ' | $RUN_BINDCTL \
  148. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  149. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  150. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  151. if [ $status != 0 ]; then echo "I:failed"; fi
  152. n=`expr $n + 1`
  153. echo "I:Rechecking BIND 10 statistics after a pause ($n)"
  154. sleep 2
  155. echo 'Stats show
  156. ' | $RUN_BINDCTL \
  157. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  158. cnt_value1=`expr $cnt_value1 + 0`
  159. cnt_value2=`expr $cnt_value2 + 1`
  160. cnt_value3=`expr $cnt_value1 + $cnt_value2`
  161. grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
  162. grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
  163. grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
  164. if [ $status != 0 ]; then echo "I:failed"; fi
  165. n=`expr $n + 1`
  166. echo "I:exit status: $status"
  167. exit $status