/tests/zfs-tests/tests/functional/cli_root/zpool_trim/zpool_trim_offline_export_import_online.ksh

https://github.com/adilger/zfs · Korn Shell · 62 lines · 23 code · 10 blank · 29 comment · 4 complexity · ec53c4dd42cb14dbe5161347d7d44f8d MD5 · raw file

  1. #!/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # This file and its contents are supplied under the terms of the
  6. # Common Development and Distribution License ("CDDL"), version 1.0.
  7. # You may only use this file in accordance with the terms of version
  8. # 1.0 of the CDDL.
  9. #
  10. # A full copy of the text of the CDDL should have accompanied this
  11. # source. A copy of the CDDL is also available via the Internet at
  12. # http://www.illumos.org/license/CDDL.
  13. #
  14. # CDDL HEADER END
  15. #
  16. #
  17. # Copyright (c) 2019 by Tim Chase. All rights reserved.
  18. # Copyright (c) 2019 Lawrence Livermore National Security, LLC.
  19. #
  20. . $STF_SUITE/include/libtest.shlib
  21. . $STF_SUITE/tests/functional/cli_root/zpool_trim/zpool_trim.kshlib
  22. #
  23. # DESCRIPTION:
  24. # Miscellaneous complex sequences of operations function as expected.
  25. #
  26. # STRATEGY:
  27. # 1. Create a pool with a two-way mirror.
  28. # 2. Start trimming, offline, export, import, online and verify that
  29. # trimming state is preserved / trimming behaves as expected
  30. # at each step.
  31. #
  32. DISK1="$(echo $DISKS | cut -d' ' -f1)"
  33. DISK2="$(echo $DISKS | cut -d' ' -f2)"
  34. log_must zpool create -f $TESTPOOL mirror $DISK1 $DISK2
  35. log_must zpool trim -r 128M $TESTPOOL $DISK1
  36. log_must zpool offline $TESTPOOL $DISK1
  37. progress="$(trim_progress $TESTPOOL $DISK1)"
  38. [[ -z "$progress" ]] && log_fail "Trimming did not start"
  39. log_mustnot eval "trim_prog_line $TESTPOOL $DISK1 | grep suspended"
  40. log_must zpool export $TESTPOOL
  41. log_must zpool import $TESTPOOL
  42. new_progress="$(trim_progress $TESTPOOL $DISK1)"
  43. [[ -z "$new_progress" ]] && log_fail "Trimming did not start after import"
  44. [[ "$new_progress" -ge "$progress" ]] || \
  45. log_fail "Trimming lost progress after import"
  46. log_mustnot eval "trim_prog_line $TESTPOOL $DISK1 | grep suspended"
  47. log_must zpool online $TESTPOOL $DISK1
  48. new_progress="$(trim_progress $TESTPOOL $DISK1)"
  49. [[ "$new_progress" -ge "$progress" ]] || \
  50. log_fail "Trimming lost progress after online"
  51. log_pass "Trimming behaves as expected at each step of:" \
  52. "trim + offline + export + import + online"