1f38cb554SJohn Wren Kennedy#!/bin/ksh -p 2f38cb554SJohn Wren Kennedy# 3f38cb554SJohn Wren Kennedy# CDDL HEADER START 4f38cb554SJohn Wren Kennedy# 5f38cb554SJohn Wren Kennedy# The contents of this file are subject to the terms of the 6f38cb554SJohn Wren Kennedy# Common Development and Distribution License (the "License"). 7f38cb554SJohn Wren Kennedy# You may not use this file except in compliance with the License. 8f38cb554SJohn Wren Kennedy# 9f38cb554SJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10f38cb554SJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing. 11f38cb554SJohn Wren Kennedy# See the License for the specific language governing permissions 12f38cb554SJohn Wren Kennedy# and limitations under the License. 13f38cb554SJohn Wren Kennedy# 14f38cb554SJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each 15f38cb554SJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16f38cb554SJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the 17f38cb554SJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying 18f38cb554SJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner] 19f38cb554SJohn Wren Kennedy# 20f38cb554SJohn Wren Kennedy# CDDL HEADER END 21f38cb554SJohn Wren Kennedy# 22f38cb554SJohn Wren Kennedy 23f38cb554SJohn Wren Kennedy# 24f38cb554SJohn Wren Kennedy# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25f38cb554SJohn Wren Kennedy# Use is subject to license terms. 26f38cb554SJohn Wren Kennedy# 27f38cb554SJohn Wren Kennedy 28f38cb554SJohn Wren Kennedy# 291d32ba66SJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved. 30*e3bf7d5aSKody Kantor# Copyright 2020 Joyent, Inc. 31f38cb554SJohn Wren Kennedy# 32f38cb554SJohn Wren Kennedy 33f38cb554SJohn Wren Kennedy. $STF_SUITE/include/libtest.shlib 34f38cb554SJohn Wren Kennedy 35f38cb554SJohn Wren Kennedy# 36f38cb554SJohn Wren Kennedy# DESCRIPTION: 37f38cb554SJohn Wren Kennedy# zpool history will truncate on small pools, leaving pool creation intact 38f38cb554SJohn Wren Kennedy# 39f38cb554SJohn Wren Kennedy# STRATEGY: 404b5c8e93SMatthew Ahrens# 1. Create a test pool on a file. 414b5c8e93SMatthew Ahrens# 2. Loop 300 times to set and remove compression to test dataset. 424b5c8e93SMatthew Ahrens# 3. Make sure 'zpool history' output is truncated 434b5c8e93SMatthew Ahrens# 4. Verify that the initial pool creation is preserved. 44f38cb554SJohn Wren Kennedy# 45f38cb554SJohn Wren Kennedy 46f38cb554SJohn Wren Kennedyverify_runnable "global" 47f38cb554SJohn Wren Kennedy 48f38cb554SJohn Wren Kennedyfunction cleanup 49f38cb554SJohn Wren Kennedy{ 501d32ba66SJohn Wren Kennedy datasetexists $spool && log_must zpool destroy $spool 511d32ba66SJohn Wren Kennedy [[ -f $VDEV0 ]] && log_must rm -f $VDEV0 521d32ba66SJohn Wren Kennedy [[ -f $TMPFILE ]] && log_must rm -f $TMPFILE 53f38cb554SJohn Wren Kennedy} 54f38cb554SJohn Wren Kennedy 55f38cb554SJohn Wren Kennedylog_assert "zpool history limitation test." 56f38cb554SJohn Wren Kennedylog_onexit cleanup 57f38cb554SJohn Wren Kennedy 58f38cb554SJohn Wren Kennedymntpnt=$(get_prop mountpoint $TESTPOOL) 59f38cb554SJohn Wren Kennedy(( $? != 0 )) && log_fail "get_prop mountpoint $TESTPOOL" 60f38cb554SJohn Wren Kennedy 614b5c8e93SMatthew AhrensVDEV0=$mntpnt/vdev0 621d32ba66SJohn Wren Kennedylog_must mkfile $MINVDEVSIZE $VDEV0 63f38cb554SJohn Wren Kennedy 64f38cb554SJohn Wren Kennedyspool=smallpool.$$; sfs=smallfs.$$ 651d32ba66SJohn Wren Kennedylog_must zpool create $spool $VDEV0 661d32ba66SJohn Wren Kennedylog_must zfs create $spool/$sfs 67f38cb554SJohn Wren Kennedy 681d32ba66SJohn Wren Kennedytypeset -i orig_count=$(zpool history $spool | wc -l) 69*e3bf7d5aSKody Kantortypeset orig_md5=$(zpool history $spool | head -2 | digest -a md5) 70f38cb554SJohn Wren Kennedy 71f38cb554SJohn Wren Kennedytypeset -i i=0 724b5c8e93SMatthew Ahrenswhile ((i < 300)); do 731d32ba66SJohn Wren Kennedy zfs set compression=off $spool/$sfs 741d32ba66SJohn Wren Kennedy zfs set compression=on $spool/$sfs 751d32ba66SJohn Wren Kennedy zfs set compression=off $spool/$sfs 761d32ba66SJohn Wren Kennedy zfs set compression=on $spool/$sfs 771d32ba66SJohn Wren Kennedy zfs set compression=off $spool/$sfs 78f38cb554SJohn Wren Kennedy 79f38cb554SJohn Wren Kennedy ((i += 1)) 80f38cb554SJohn Wren Kennedydone 81f38cb554SJohn Wren Kennedy 82f38cb554SJohn Wren KennedyTMPFILE=/tmp/spool.$$ 831d32ba66SJohn Wren Kennedyzpool history $spool >$TMPFILE 841d32ba66SJohn Wren Kennedytypeset -i entry_count=$(wc -l $TMPFILE | awk '{print $1}') 85*e3bf7d5aSKody Kantortypeset final_md5=$(head -2 $TMPFILE | digest -a md5) 86f38cb554SJohn Wren Kennedy 871d32ba66SJohn Wren Kennedygrep 'zpool create' $TMPFILE >/dev/null 2>&1 || 88f38cb554SJohn Wren Kennedy log_fail "'zpool create' was not found in pool history" 89f38cb554SJohn Wren Kennedy 901d32ba66SJohn Wren Kennedygrep 'zfs create' $TMPFILE >/dev/null 2>&1 && 91f38cb554SJohn Wren Kennedy log_fail "'zfs create' was found in pool history" 92f38cb554SJohn Wren Kennedy 931d32ba66SJohn Wren Kennedygrep 'zfs set compress' $TMPFILE >/dev/null 2>&1 || 94f38cb554SJohn Wren Kennedy log_fail "'zfs set compress' was found in pool history" 95f38cb554SJohn Wren Kennedy 96f38cb554SJohn Wren Kennedy# Verify that the creation of the pool was preserved in the history. 97f38cb554SJohn Wren Kennedyif [[ $orig_md5 != $final_md5 ]]; then 98f38cb554SJohn Wren Kennedy log_fail "zpool creation history was not preserved." 99f38cb554SJohn Wren Kennedyfi 100f38cb554SJohn Wren Kennedy 101f38cb554SJohn Wren Kennedylog_pass "zpool history limitation test passed." 102