common_tests.sh.in 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2004, 2005, 2007, 2011 Internet Systems Consortium, Inc. ("ISC")
  4. # Copyright (C) 2000, 2001 Internet Software Consortium.
  5. #
  6. # Permission to use, copy, modify, and/or distribute this software for any
  7. # purpose with or without fee is hereby granted, provided that the above
  8. # copyright notice and this permission notice appear in all copies.
  9. #
  10. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  11. # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  12. # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  13. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  14. # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  15. # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. # PERFORMANCE OF THIS SOFTWARE.
  17. # \file
  18. # This script is used in a couple of IXFR tests.
  19. #
  20. # Preconditions:\n
  21. # The BIND 9 nameserver (ns1, 10.53.0.1, acting as the IXFR server) is loaded
  22. # with the N-4 version of the zone. It may hold prior versions as well.
  23. # Notifications are disabled.
  24. #
  25. # The BIND 10 nameserver (nsx2, 10.53.0.2, acting as the IXFR client) is loaded
  26. # with an earlier (unspecified) version of the zone.
  27. #
  28. # Actions:\n
  29. # This script updates the IXFR server with the N-2 and N-0 versions of the zone.
  30. # It then updates the BIND 10 configuration so that it looks for IXFRs from
  31. # the IXFR server and causes the server to send the client a NOTIFY. After
  32. # waiting for the client to update from the server, it compares SOA serials,
  33. # reporting an error if they are different.
  34. #
  35. # Caller Actions:\n
  36. # The caller can pre-load the BIND 10 IXFR client with whatever version of the
  37. # zone it requires. It can also load the BIND 9 IXFR server with zones earlier
  38. # than N-4.
  39. #
  40. # After this test has finished, it is up to the caller to check the logs
  41. # to see if they report the expected behavior.
  42. # Set up variables etc.
  43. . @abs_top_builddir@/tests/system/conf.sh
  44. . $IXFR_TOP/ixfr_init.sh
  45. SERVER_NAME=ns1
  46. SERVER_IP=10.53.0.1 # BIND 9
  47. CLIENT_NAME=nsx2
  48. CLIENT_IP=10.53.0.2 # BIND 10
  49. status=0
  50. # Store the SOA serial number of the BIND 10 client for later use.
  51. old_client_serial=`$DIG_SOA @$CLIENT_IP | $AWK '{print $3}'`
  52. echo "I:SOA serial of IXFR client $CLIENT_NAME is $old_client_serial"
  53. # Load the BIND 9 system (the IXFR server) with the "n - 2" and "n" version of
  54. # the zones. With ixfr-from-differences set to "yes", the nameserver should
  55. # generate the differences between them.
  56. echo "I:updating IXFR-server $SERVER_NAME for ixfr-in tests"
  57. update_server_zone $SERVER_NAME $SERVER_IP $IXFR_TOP/largezone_n-2.db
  58. if [ $? != 0 ];
  59. then
  60. status=1
  61. fi
  62. # Wait a bit - it seems that if two updates are loaded in quick succession,
  63. # the second sometimes gets lost.
  64. sleep 5
  65. update_server_zone $SERVER_NAME $SERVER_IP $IXFR_TOP/largezone_n-0.db
  66. if [ $? != 0 ];
  67. then
  68. status=1
  69. fi
  70. # TODO: Need to alter configuration of BIND 10 server such that it accepts
  71. # NOTIFYs from and sends IXFR requests to the BIND 9 master.
  72. # Get the IXFR server to notify the slave server of the new zone. Do this by
  73. # allowing notifies and then triggering a re-notification of the server.
  74. echo "I:notifying IXFR-client $CLIENT_NAME of presence of new version of zone"
  75. cp ns1/named_notify.conf ns1/named.conf
  76. do_rndc $SERVER_NAME $SERVER_IP reconfig
  77. if [ $? != 0 ];
  78. then
  79. status=1
  80. fi
  81. do_rndc $SERVER_NAME $SERVER_IP notify example
  82. if [ $? != 0 ];
  83. then
  84. status=1
  85. fi
  86. # Wait for the client to update itself.
  87. wait_for_update $CLIENT_NAME $CLIENT_IP $old_client_serial
  88. if [ $? != 0 ];
  89. then
  90. status=1
  91. fi
  92. # Has updated, get the latest serial of the client and server - they
  93. # should be the same.
  94. client_serial=`$DIG_SOA @$CLIENT_IP | $AWK '{print $3}'`
  95. server_serial=`$DIG_SOA @$SERVER_IP | $AWK '{print $3}'`
  96. if [ "$client_serial" != "$server_serial" ];
  97. then
  98. echo "R:FAIL client serial $client_serial not same as server serial $server_serial after update"
  99. status=1
  100. fi
  101. exit $status