/tests/zfs-tests/tests/functional/fault/decompress_fault.ksh

https://github.com/adilger/zfs · Korn Shell · 58 lines · 24 code · 8 blank · 26 comment · 1 complexity · 9a6403440ee0965961d99a76227633d2 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) 2018 by Datto Inc.
  14. # All rights reserved.
  15. #
  16. . $STF_SUITE/include/libtest.shlib
  17. . $STF_SUITE/tests/functional/fault/fault.cfg
  18. #
  19. # DESCRIPTION:
  20. # Test that injected decompression errors are handled correctly.
  21. #
  22. # STRATEGY:
  23. # 1. Create an compressed dataset with a test file
  24. # 2. Inject decompression errors on the file 20% of the time
  25. # 3. Read the file to confirm that errors are handled correctly
  26. # 4. Confirm that the decompression injection was added to the ZED logs
  27. #
  28. log_assert "Testing that injected decompression errors are handled correctly"
  29. function cleanup
  30. {
  31. log_must set_tunable64 COMPRESSED_ARC_ENABLED 1
  32. log_must zinject -c all
  33. default_cleanup_noexit
  34. }
  35. log_onexit cleanup
  36. default_mirror_setup_noexit $DISK1 $DISK2
  37. log_must set_tunable64 COMPRESSED_ARC_ENABLED 0
  38. log_must zfs create -o compression=on $TESTPOOL/fs
  39. mntpt=$(get_prop mountpoint $TESTPOOL/fs)
  40. write_compressible $mntpt 32m 1 1024k "testfile"
  41. log_must sync
  42. log_must zfs umount $TESTPOOL/fs
  43. log_must zfs mount $TESTPOOL/fs
  44. log_must zinject -a -t data -e decompress -f 20 $mntpt/testfile.0
  45. log_mustnot eval "cat $mntpt/testfile.0 > /dev/null"
  46. if ! is_freebsd; then
  47. # Events are not supported on FreeBSD
  48. log_must eval "zpool events $TESTPOOL | grep -q 'data'"
  49. fi
  50. log_pass "Injected decompression errors are handled correctly"