1#!/usr/local/bin/ksh93 -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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/tests/history/history_common.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: history_001_pos 34# 35# DESCRIPTION: 36# Create a scenario to verify the following zpool subcommands are logged. 37# create, destroy, add, remove, offline, online, attach, detach, replace, 38# scrub, export, import, clear, upgrade. 39# 40# STRATEGY: 41# 1. Create three virtual disk files. 42# 2. Create a three-way mirror. 43# 3. Invoke every sub-commands to this mirror, except upgrade. 44# 4. Compare 'zpool history' log with expected log. 45# 5. Imported specified pool and upgrade it, verify 'upgrade' was logged. 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING_STATUS: COMPLETED (2006-07-05) 52# 53# __stc_assertion_end 54# 55################################################################################ 56 57verify_runnable "global" 58 59function cleanup 60{ 61 destroy_pool $MPOOL 62 destroy_pool $upgrade_pool 63 64 [[ -d $import_dir ]] && $RM -rf $import_dir 65 for file in $REAL_HISTORY $EXPECT_HISTORY \ 66 $VDEV1 $VDEV2 $VDEV3 $VDEV4 67 do 68 [[ -f $file ]] && $RM -f $file 69 done 70} 71 72log_assert "Verify zpool sub-commands which modify state are logged." 73log_onexit cleanup 74 75(( $? != 0)) && log_fail "get_prop($TESTPOOL mountpoint)" 76VDEV1=$TMPDIR/vdev1; VDEV2=$TMPDIR/vdev2; 77VDEV3=$TMPDIR/vdev3; VDEV4=$TMPDIR/vdev4; 78 79log_must create_vdevs $VDEV1 $VDEV2 $VDEV3 $VDEV4 80$CAT /dev/null > $EXPECT_HISTORY 81 82exec_record $ZPOOL create $MPOOL mirror $VDEV1 $VDEV2 83exec_record $ZPOOL add -f $MPOOL spare $VDEV3 84exec_record $ZPOOL remove $MPOOL $VDEV3 85exec_record $ZPOOL offline $MPOOL $VDEV1 86exec_record $ZPOOL online $MPOOL $VDEV1 87exec_record $ZPOOL attach $MPOOL $VDEV1 $VDEV4 88exec_record $ZPOOL detach $MPOOL $VDEV4 89exec_record $ZPOOL replace -f $MPOOL $VDEV1 $VDEV4 90exec_record $ZPOOL export $MPOOL 91exec_record $ZPOOL import -d $TMPDIR $MPOOL 92exec_record $ZPOOL destroy $MPOOL 93exec_record $ZPOOL import -D -f -d $TMPDIR $MPOOL 94exec_record $ZPOOL clear $MPOOL 95 96format_history $MPOOL $REAL_HISTORY 97log_must $DIFF $REAL_HISTORY $EXPECT_HISTORY 98 99import_dir=$TMPDIR/import_dir.${TESTCASE_ID} 100log_must $MKDIR $import_dir 101log_must $CP $STF_SUITE/tests/history/zfs-pool-v4.dat.Z $import_dir 102log_must $UNCOMPRESS $import_dir/zfs-pool-v4.dat.Z 103 104# Truncate $EXPECT_HISTORY file 105log_must eval "$CAT /dev/null > $EXPECT_HISTORY" 106 107upgrade_pool=$($ZPOOL import -d $import_dir | $GREP "pool:" | $AWK '{print $2}') 108exec_record $ZPOOL import -d $import_dir $upgrade_pool 109# Get existing history 110format_history $upgrade_pool $EXPECT_HISTORY 111exec_record $ZPOOL upgrade $upgrade_pool 112 113format_history $upgrade_pool $REAL_HISTORY 114log_must $DIFF $REAL_HISTORY $EXPECT_HISTORY 115 116log_pass "zpool sub-commands which modify state are logged passed. " 117