tests.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 remove Boss/components b10-auth
  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 add Boss/components b10-auth
  57. config set Boss/components/b10-auth { "special": "auth", "kind": "needed" }
  58. config commit
  59. quit
  60. ' | $RUN_BINDCTL \
  61. --csv-file-dir=$BINDCTL_CSV_DIR 2>&1 > /dev/null || status=1
  62. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  63. grep 192.0.2.1 dig.out.$n > /dev/null || status=1
  64. if [ $status != 0 ]; then echo "I:failed"; fi
  65. n=`expr $n + 1`
  66. echo "I:Rechecking BIND 10 statistics after a pause ($n)"
  67. sleep 2
  68. echo 'Stats show
  69. ' | $RUN_BINDCTL \
  70. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  71. # The statistics counters should have been reset while stop/start.
  72. grep $auth_queries_tcp".*\<0\>" bindctl.out.$n > /dev/null || status=1
  73. grep $auth_queries_udp".*\<1\>" bindctl.out.$n > /dev/null || status=1
  74. if [ $status != 0 ]; then echo "I:failed"; fi
  75. n=`expr $n + 1`
  76. echo "I:Changing the data source from sqlite3 to in-memory ($n)"
  77. DATASRC_SPEC='[{"type": "memory", "zones": [{"origin": "com","file":'
  78. DATASRC_SPEC="${DATASRC_SPEC} \"${TEST_TOP}/bindctl/nsx1/example-normalized.db\"}]}]"
  79. echo "config set Auth/datasources ${DATASRC_SPEC}
  80. config commit
  81. quit
  82. " | $RUN_BINDCTL \
  83. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  84. $DIG +norec @10.53.0.1 -p 53210 ns.example.com. A >dig.out.$n || status=1
  85. grep 192.0.2.2 dig.out.$n > /dev/null || status=1
  86. if [ $status != 0 ]; then echo "I:failed"; fi
  87. n=`expr $n + 1`
  88. echo "I:Rechecking BIND 10 statistics after changing the datasource ($n)"
  89. sleep 2
  90. echo 'Stats show
  91. ' | $RUN_BINDCTL \
  92. --csv-file-dir=$BINDCTL_CSV_DIR > bindctl.out.$n || status=1
  93. # The statistics counters shouldn't be reset due to hot-swapping datasource.
  94. grep $auth_queries_tcp".*\<0\>" bindctl.out.$n > /dev/null || status=1
  95. grep $auth_queries_udp".*\<2\>" bindctl.out.$n > /dev/null || status=1
  96. if [ $status != 0 ]; then echo "I:failed"; fi
  97. n=`expr $n + 1`
  98. echo "I:exit status: $status"
  99. exit $status