dns-stress01-rmt.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. # Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
  3. # Copyright (c) International Business Machines Corp., 2005
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; either version 2 of
  8. # the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it would be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write the Free Software Foundation,
  17. # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. #
  19. # Author: Mitsuru Chinen <mitch@jp.ibm.com>
  20. TCID=dns-stress01-rmt
  21. TST_TOTAL=1
  22. . dns-stress-lib.sh
  23. # Check the arguments
  24. if [ $# -ne 7 ]; then
  25. tst_brkm TBROK "Usage: $0 ip_ver srv_ipaddr port domain \
  26. min_id max_id connect_quantity"
  27. fi
  28. ip_ver="$1"
  29. srv_ipaddr="$2"
  30. port="$3"
  31. domain="$4"
  32. min_id="$5"
  33. max_id="$6"
  34. connect_quantity="$7"
  35. # Specify the record of dns accoring to the version of IP
  36. case $ip_ver in
  37. 4)
  38. record="A" ;;
  39. 6)
  40. record="AAAA" ;;
  41. *)
  42. tst_brkm TBROK "$ver_opt is unknown IP version" ;;
  43. esac
  44. # Check the connectivity first
  45. dig @$srv_ipaddr -p $port node${min_id}.${domain} $record > ans.log 2>&1 || \
  46. tst_brkm TBROK "Failed to connect $srv_ipaddr"
  47. dns_check_answer ans.log
  48. # Loop for a large number of name lookup queries
  49. num=0
  50. id=$min_id
  51. while [ $num -lt $connect_quantity ]; do
  52. dig @$srv_ipaddr -p $port node${id}.${domain} $record \
  53. > /dev/null || break
  54. id=$(($id + 1))
  55. [ $id -gt $max_id ] && id=$min_id
  56. num=$(($num + 1))
  57. done
  58. # Check the connectivity again
  59. dig @$srv_ipaddr -p $port node${id}.${domain} $record > ans.log 2>&1 || \
  60. tst_brkm TBROK "Failed to connect $srv_ipaddr"
  61. dns_check_answer ans.log
  62. dns_check_send_requests
  63. tst_exit