tests.sh 3.9 KB

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