/tests/zfs-tests/tests/functional/cli_root/zpool_reopen/zpool_reopen_005_pos.ksh

https://github.com/adilger/zfs · Korn Shell · 86 lines · 28 code · 15 blank · 43 comment · 1 complexity · 2510b8c979add395424d992240f92745 MD5 · raw file

  1. #!/bin/ksh -p
  2. #
  3. # This file and its contents are supplied under the terms of the
  4. # Common Development and Distribution License ("CDDL"), version 1.0.
  5. # You may only use this file in accordance with the terms of version
  6. # 1.0 of the CDDL.
  7. #
  8. # A full copy of the text of the CDDL should have accompanied this
  9. # source. A copy of the CDDL is also available via the Internet at
  10. # http://www.illumos.org/license/CDDL.
  11. #
  12. #
  13. # Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
  14. #
  15. . $STF_SUITE/tests/functional/cli_root/zpool_reopen/zpool_reopen.shlib
  16. #
  17. # DESCRIPTION:
  18. # Test zpool reopen -n while resilver is running.
  19. # Checks if the resilver is restarted.
  20. #
  21. # STRATEGY:
  22. # 1. Create a pool
  23. # 2. Remove a disk.
  24. # 3. Write test file to pool.
  25. # 4. "Plug back" disk.
  26. # 5. Reopen a pool and wait until resilvering is started.
  27. # 6. Reopen a pool again with -n flag.
  28. # 7. Wait until resilvering is finished and check if it was restarted.
  29. #
  30. # NOTES:
  31. # A 25ms delay is added to make sure that the resilver is running while
  32. # the reopen is invoked.
  33. #
  34. verify_runnable "global"
  35. function cleanup
  36. {
  37. log_must zinject -c all
  38. insert_disk $REMOVED_DISK $scsi_host
  39. poolexists $TESTPOOL && destroy_pool $TESTPOOL
  40. }
  41. log_assert "Testing zpool reopen with pool name as argument"
  42. log_onexit cleanup
  43. set_removed_disk
  44. scsi_host=$(get_scsi_host $REMOVED_DISK)
  45. # 1. Create a pool
  46. default_mirror_setup_noexit $REMOVED_DISK_ID $DISK2
  47. # 2. Remove a disk.
  48. remove_disk $REMOVED_DISK
  49. log_must zpool reopen $TESTPOOL
  50. log_must check_state $TESTPOOL "$REMOVED_DISK_ID" "unavail"
  51. # 3. Write test file to pool.
  52. log_must generate_random_file /$TESTPOOL/data $LARGE_FILE_SIZE
  53. # 4. "Plug back" disk.
  54. insert_disk $REMOVED_DISK $scsi_host
  55. # 5. Reopen a pool and wait until resilvering is started.
  56. log_must zpool reopen $TESTPOOL
  57. log_must check_state $TESTPOOL "$REMOVED_DISK_ID" "online"
  58. # add delay to I/O requests for the reopened disk
  59. log_must zinject -d $REMOVED_DISK_ID -D25:1 $TESTPOOL
  60. # wait until resilver starts
  61. log_must wait_for_resilver_start $TESTPOOL $MAXTIMEOUT
  62. # 6. Reopen a pool again with -n flag.
  63. log_must zpool reopen -n $TESTPOOL
  64. # 7. Wait until resilvering is finished and check if it was restarted.
  65. log_must wait_for_resilver_end $TESTPOOL $MAXTIMEOUT
  66. # remove delay from disk
  67. log_must zinject -c all
  68. log_mustnot is_scan_restarted $TESTPOOL
  69. # clean up
  70. log_must zpool destroy $TESTPOOL
  71. log_pass "Zpool reopen test successful"