]> git.proxmox.com Git - mirror_zfs.git/blame - tests/zfs-tests/tests/functional/fault/decompress_fault.ksh
Update ZTS to work on FreeBSD
[mirror_zfs.git] / tests / zfs-tests / tests / functional / fault / decompress_fault.ksh
CommitLineData
c3bd3fb4
TC
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#
14# Copyright (c) 2018 by Datto Inc.
15# All rights reserved.
16#
17
18. $STF_SUITE/include/libtest.shlib
19. $STF_SUITE/tests/functional/fault/fault.cfg
20
21#
22# DESCRIPTION:
23# Test that injected decompression errors are handled correctly.
24#
25# STRATEGY:
26# 1. Create an compressed dataset with a test file
27# 2. Inject decompression errors on the file 20% of the time
28# 3. Read the file to confirm that errors are handled correctly
29# 4. Confirm that the decompression injection was added to the ZED logs
30#
31
32log_assert "Testing that injected decompression errors are handled correctly"
33
7839c4b5
MM
34if is_freebsd; then
35 COMPRESSION=compressed_arc_enabled
36else
37 COMPRESSION=zfs_compressed_arc_enabled
38fi
39
c3bd3fb4
TC
40function cleanup
41{
7839c4b5 42 log_must set_tunable64 $COMPRESSION 1
c3bd3fb4
TC
43 log_must zinject -c all
44 default_cleanup_noexit
45}
46
47log_onexit cleanup
48
49default_mirror_setup_noexit $DISK1 $DISK2
7839c4b5 50log_must set_tunable64 $COMPRESSION 0
c3bd3fb4
TC
51log_must zfs create -o compression=on $TESTPOOL/fs
52mntpt=$(get_prop mountpoint $TESTPOOL/fs)
7839c4b5 53write_compressible $mntpt 32m 1 1024k "testfile"
c3bd3fb4
TC
54log_must sync
55log_must zfs umount $TESTPOOL/fs
56log_must zfs mount $TESTPOOL/fs
57log_must zinject -a -t data -e decompress -f 20 $mntpt/testfile.0
58log_mustnot eval "cat $mntpt/testfile.0 > /dev/null"
7839c4b5
MM
59if ! is_freebsd; then
60 # Events are not supported on FreeBSD
61 log_must eval "zpool events $TESTPOOL | grep -q 'data'"
62fi
c3bd3fb4
TC
63
64log_pass "Injected decompression errors are handled correctly"