history_003_pos.ksh revision 1d32ba663e202c24a5a1f2e5aef83fffb447cb7f
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# CDDL HEADER START
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# The contents of this file are subject to the terms of the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Common Development and Distribution License (the "License").
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# You may not use this file except in compliance with the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# See the License for the specific language governing permissions
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# and limitations under the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# CDDL HEADER END
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# zpool history will truncate on small pools, leaving pool creation intact
4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1cMatthew Ahrens# 1. Create a test pool on a file.
4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1cMatthew Ahrens# 2. Loop 300 times to set and remove compression to test dataset.
4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1cMatthew Ahrens# 3. Make sure 'zpool history' output is truncated
4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1cMatthew Ahrens# 4. Verify that the initial pool creation is preserved.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy datasetexists $spool && log_must zpool destroy $spool
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy [[ -f $TMPFILE ]] && log_must rm -f $TMPFILE
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_assert "zpool history limitation test."
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy(( $? != 0 )) && log_fail "get_prop mountpoint $TESTPOOL"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedytypeset -i orig_count=$(zpool history $spool | wc -l)
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedytypeset orig_md5=$(zpool history $spool | head -2 | md5sum | \
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedytypeset -i entry_count=$(wc -l $TMPFILE | awk '{print $1}')
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedytypeset final_md5=$(head -2 $TMPFILE | md5sum | awk '{print $1}')
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedygrep 'zpool create' $TMPFILE >/dev/null 2>&1 ||
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_fail "'zpool create' was not found in pool history"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedygrep 'zfs create' $TMPFILE >/dev/null 2>&1 &&
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_fail "'zfs create' was found in pool history"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedygrep 'zfs set compress' $TMPFILE >/dev/null 2>&1 ||
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_fail "'zfs set compress' was found in pool history"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Verify that the creation of the pool was preserved in the history.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_fail "zpool creation history was not preserved."
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_pass "zpool history limitation test passed."