|
| 1 | +#!/bin/ksh -p |
| 2 | +# |
| 3 | +# CDDL HEADER START |
| 4 | +# |
| 5 | +# The contents of this file are subject to the terms of the |
| 6 | +# Common Development and Distribution License (the "License"). |
| 7 | +# You may not use this file except in compliance with the License. |
| 8 | +# |
| 9 | +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
| 10 | +# or http://www.opensolaris.org/os/licensing. |
| 11 | +# See the License for the specific language governing permissions |
| 12 | +# and limitations under the License. |
| 13 | +# |
| 14 | +# When distributing Covered Code, include this CDDL HEADER in each |
| 15 | +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
| 16 | +# If applicable, add the following below this CDDL HEADER, with the |
| 17 | +# fields enclosed by brackets "[]" replaced with your own identifying |
| 18 | +# information: Portions Copyright [yyyy] [name of copyright owner] |
| 19 | +# |
| 20 | +# CDDL HEADER END |
| 21 | +# |
| 22 | + |
| 23 | +# |
| 24 | +# Copyright (c) 2020 The FreeBSD Foundation [1] |
| 25 | +# |
| 26 | +# [1] Portions of this software were developed by Allan Jude |
| 27 | +# under sponsorship from the FreeBSD Foundation. |
| 28 | + |
| 29 | +. $STF_SUITE/include/libtest.shlib |
| 30 | + |
| 31 | +# |
| 32 | +# DESCRIPTION: |
| 33 | +# Setting the compression property to any of the zstd levels should activate |
| 34 | +# the zstd feature flag. Destroying the last dataset using the zstd feature flag |
| 35 | +# should revert the feature to the 'enabled' state. |
| 36 | +# |
| 37 | +# STRATEGY: |
| 38 | +# 1. Create pool, then create a file system within it. |
| 39 | +# 2. Check that the zstd feature flag is 'enabled'. |
| 40 | +# 3. Setting the compression property to zstd. |
| 41 | +# 4. Check that the zstd feature flag is now 'active'. |
| 42 | +# 5. Destroy the dataset |
| 43 | +# 6. Confirm that the feature flag reverts to the 'enabled' state. |
| 44 | +# |
| 45 | + |
| 46 | +verify_runnable "both" |
| 47 | + |
| 48 | +log_assert "Setting compression=zstd should activate the"\ |
| 49 | + "org.freebsd:zstd_compress feature flag, and destroying the last"\ |
| 50 | + "dataset using that property, should revert the feature flag to"\ |
| 51 | + "the enabled state." |
| 52 | + |
| 53 | +featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL)" |
| 54 | + |
| 55 | +[[ "$featureval" == "disabled" ]] && \ |
| 56 | + log_unsupported "ZSTD feature flag unsupposed" |
| 57 | + |
| 58 | +[[ "$featureval" == "active" ]] && \ |
| 59 | + log_unsupported "ZSTD feature already active before test" |
| 60 | + |
| 61 | +random_level=$((RANDOM%19 + 1)) |
| 62 | +log_note "Randomly selected ZSTD level: $random_level" |
| 63 | + |
| 64 | +log_must zfs create -o compress=zstd-$random_level $TESTPOOL/$TESTFS-zstd |
| 65 | + |
| 66 | +featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL)" |
| 67 | + |
| 68 | +log_note "After zfs set, feature flag value is: $featureval" |
| 69 | + |
| 70 | +[[ "$featureval" == "active" ]] || |
| 71 | + log_fail "ZSTD feature flag not activated" |
| 72 | + |
| 73 | +log_must zfs destroy $TESTPOOL/$TESTFS-zstd |
| 74 | + |
| 75 | +featureval="$(get_pool_prop feature@zstd_compress $TESTPOOL)" |
| 76 | + |
| 77 | +log_note "After zfs destroy, feature flag value is: $featureval" |
| 78 | + |
| 79 | +[[ "$featureval" == "enabled" ]] || |
| 80 | + log_fail "ZSTD feature flag not deactivated" |
| 81 | + |
| 82 | +log_pass "Setting compression=zstd activated the feature flag, and"\ |
| 83 | + "destroying the dataset deactivated it." |
0 commit comments