tests.sh 4.1 KB

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