tests.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. auth_queries_tcp="\<queries\.tcp\>"
  25. auth_queries_udp="\<queries\.udp\>"
  26. auth_opcode_queries="\<opcode\.query\>"
  27. echo "I:Checking b10-auth is working by default ($n)"
  28. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  29. # perform a simple check on the output (digcomp would be too much for this)
  30. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  31. if [ $status != 0 ]; then echo "I:failed"; fi
  32. n=`expr $n + 1`
  33. echo "I:Checking BIND 10 statistics after a pause ($n)"
  34. # wait for 2sec to make sure b10-stats gets the latest statistics.
  35. # note that we set statistics-interval to 1.
  36. sleep 2
  37. echo 'Stats show
  38. ' | $RUN_BINDCTL \
  39. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  40. # the server should have received 1 UDP and 1 TCP queries (TCP query was
  41. # sent from the server startup script)
  42. grep $auth_queries_tcp".*\<1\>" bindctl.out.$n > /dev/null || status=1
  43. grep $auth_queries_udp".*\<1\>" bindctl.out.$n > /dev/null || status=1
  44. grep $auth_opcode_queries".*\<2\>" bindctl.out.$n > /dev/null || status=1
  45. if [ $status != 0 ]; then echo "I:failed"; fi
  46. n=`expr $n + 1`
  47. echo "I:Stopping b10-auth and checking that ($n)"
  48. echo 'config remove Boss/components b10-auth
  49. config commit
  50. quit
  51. ' | $RUN_BINDCTL \
  52. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  53. # dig should exit with a failure code.
  54. $DIG +tcp +norec @10.53.0.1 -p 53210 ns.example.com. A && status=1
  55. if [ $status != 0 ]; then echo "I:failed"; fi
  56. n=`expr $n + 1`
  57. echo "I:Restarting b10-auth and checking that ($n)"
  58. echo 'config add Boss/components b10-auth
  59. config set Boss/components/b10-auth { "special": "auth", "kind": "needed" }
  60. config commit
  61. quit
  62. ' | $RUN_BINDCTL \
  63. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  64. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  65. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  66. if [ $status != 0 ]; then echo "I:failed"; fi
  67. n=`expr $n + 1`
  68. echo "I:Rechecking BIND 10 statistics after a pause ($n)"
  69. sleep 2
  70. echo 'Stats show
  71. ' | $RUN_BINDCTL \
  72. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  73. # The statistics counters should have been reset while stop/start.
  74. grep $auth_queries_tcp".*\<0\>" bindctl.out.$n > /dev/null || status=1
  75. grep $auth_queries_udp".*\<1\>" bindctl.out.$n > /dev/null || status=1
  76. grep $auth_opcode_queries".*\<1\>" bindctl.out.$n > /dev/null || status=1
  77. if [ $status != 0 ]; then echo "I:failed"; fi
  78. n=`expr $n + 1`
  79. echo "I:Changing the data source from sqlite3 to in-memory ($n)"
  80. DATASRC_SPEC='[{"type": "memory", "zones": [{"origin": "com","file":'
  81. DATASRC_SPEC="${DATASRC_SPEC} \"${TEST_TOP}/bindctl/nsx1/example-normalized.db\"}]}]"
  82. echo "config set Auth/datasources ${DATASRC_SPEC}
  83. config commit
  84. quit
  85. " | $RUN_BINDCTL \
  86. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  87. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  88. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  89. if [ $status != 0 ]; then echo "I:failed"; fi
  90. n=`expr $n + 1`
  91. echo "I:Rechecking BIND 10 statistics after changing the datasource ($n)"
  92. sleep 2
  93. echo 'Stats show
  94. ' | $RUN_BINDCTL \
  95. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  96. # The statistics counters shouldn't be reset due to hot-swapping datasource.
  97. grep $auth_queries_tcp".*\<0\>" bindctl.out.$n > /dev/null || status=1
  98. grep $auth_queries_udp".*\<2\>" bindctl.out.$n > /dev/null || status=1
  99. grep $auth_opcode_queries".*\<2\>" bindctl.out.$n > /dev/null || status=1
  100. if [ $status != 0 ]; then echo "I:failed"; fi
  101. n=`expr $n + 1`
  102. echo "I:exit status: $status"
  103. exit $status