12fae26bdSAlan Somers#!/usr/local/bin/ksh93 -p
22fae26bdSAlan Somers#
32fae26bdSAlan Somers# CDDL HEADER START
42fae26bdSAlan Somers#
52fae26bdSAlan Somers# The contents of this file are subject to the terms of the
62fae26bdSAlan Somers# Common Development and Distribution License (the "License").
72fae26bdSAlan Somers# You may not use this file except in compliance with the License.
82fae26bdSAlan Somers#
92fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
102fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing.
112fae26bdSAlan Somers# See the License for the specific language governing permissions
122fae26bdSAlan Somers# and limitations under the License.
132fae26bdSAlan Somers#
142fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each
152fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
162fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the
172fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying
182fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner]
192fae26bdSAlan Somers#
202fae26bdSAlan Somers# CDDL HEADER END
212fae26bdSAlan Somers#
222fae26bdSAlan Somers
232fae26bdSAlan Somers#
242fae26bdSAlan Somers# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
252fae26bdSAlan Somers# Use is subject to license terms.
262fae26bdSAlan Somers
272fae26bdSAlan Somers. $STF_SUITE/tests/history/history_common.kshlib
282fae26bdSAlan Somers
292fae26bdSAlan Somers#################################################################################
302fae26bdSAlan Somers#
312fae26bdSAlan Somers# __stc_assertion_start
322fae26bdSAlan Somers#
332fae26bdSAlan Somers# ID: history_004_pos
342fae26bdSAlan Somers#
352fae26bdSAlan Somers# DESCRIPTION:
362fae26bdSAlan Somers#	'zpool history' can copes with many simultaneous command.
372fae26bdSAlan Somers#
382fae26bdSAlan Somers# STRATEGY:
392fae26bdSAlan Somers#	1. Create test pool and test fs.
402fae26bdSAlan Somers#	2. Loop 100 times, set properties to test fs simultaneously.
412fae26bdSAlan Somers#	3. Wait for all the command execution complete.
422fae26bdSAlan Somers#	4. Make sure all the commands was logged by 'zpool history'.
432fae26bdSAlan Somers#
442fae26bdSAlan Somers# TESTABILITY: explicit
452fae26bdSAlan Somers#
462fae26bdSAlan Somers# TEST_AUTOMATION_LEVEL: automated
472fae26bdSAlan Somers#
482fae26bdSAlan Somers# CODING_STATUS: COMPLETED (2006-07-05)
492fae26bdSAlan Somers#
502fae26bdSAlan Somers# __stc_assertion_end
512fae26bdSAlan Somers#
522fae26bdSAlan Somers################################################################################
532fae26bdSAlan Somers
542fae26bdSAlan Somersverify_runnable "global"
552fae26bdSAlan Somers
562fae26bdSAlan Somerslog_assert "'zpool history' can copes with many simultaneous command."
572fae26bdSAlan Somers
582fae26bdSAlan Somerstypeset -i orig_count=$($ZPOOL history $TESTPOOL | $WC -l | $AWK '{print $1}')
592fae26bdSAlan Somers
602fae26bdSAlan Somerstypeset -i i=0
612fae26bdSAlan Somerswhile ((i < 10)); do
622fae26bdSAlan Somers	$ZFS set compression=off $TESTPOOL/$TESTFS &
632fae26bdSAlan Somers	$ZFS set atime=off $TESTPOOL/$TESTFS &
642fae26bdSAlan Somers	$ZFS create $TESTPOOL/$TESTFS1 &
652fae26bdSAlan Somers	$ZFS create $TESTPOOL/$TESTFS2 &
662fae26bdSAlan Somers	$ZFS create $TESTPOOL/$TESTFS3 &
672fae26bdSAlan Somers
682fae26bdSAlan Somers	wait
692fae26bdSAlan Somers
702fae26bdSAlan Somers	$ZFS snapshot $TESTPOOL/$TESTFS1@snap &
712fae26bdSAlan Somers	$ZFS snapshot $TESTPOOL/$TESTFS2@snap &
722fae26bdSAlan Somers	$ZFS snapshot $TESTPOOL/$TESTFS3@snap &
732fae26bdSAlan Somers
742fae26bdSAlan Somers	wait
752fae26bdSAlan Somers
762fae26bdSAlan Somers	$ZFS clone $TESTPOOL/$TESTFS1@snap $TESTPOOL/clone1 &
772fae26bdSAlan Somers	$ZFS clone $TESTPOOL/$TESTFS2@snap $TESTPOOL/clone2 &
782fae26bdSAlan Somers	$ZFS clone $TESTPOOL/$TESTFS3@snap $TESTPOOL/clone3 &
792fae26bdSAlan Somers
802fae26bdSAlan Somers	wait
812fae26bdSAlan Somers
822fae26bdSAlan Somers	$ZFS promote $TESTPOOL/clone1 &
832fae26bdSAlan Somers	$ZFS promote $TESTPOOL/clone2 &
842fae26bdSAlan Somers	$ZFS promote $TESTPOOL/clone3 &
852fae26bdSAlan Somers
862fae26bdSAlan Somers	wait
872fae26bdSAlan Somers
882fae26bdSAlan Somers	$ZFS destroy $TESTPOOL/$TESTFS1 &
892fae26bdSAlan Somers	$ZFS destroy $TESTPOOL/$TESTFS2 &
902fae26bdSAlan Somers	$ZFS destroy $TESTPOOL/$TESTFS3 &
912fae26bdSAlan Somers
922fae26bdSAlan Somers	wait
932fae26bdSAlan Somers
942fae26bdSAlan Somers	$ZFS destroy -Rf $TESTPOOL/clone1 &
952fae26bdSAlan Somers	$ZFS destroy -Rf $TESTPOOL/clone2 &
962fae26bdSAlan Somers	$ZFS destroy -Rf $TESTPOOL/clone3 &
972fae26bdSAlan Somers
982fae26bdSAlan Somers	wait
992fae26bdSAlan Somers	((i += 1))
1002fae26bdSAlan Somersdone
1012fae26bdSAlan Somers
1022fae26bdSAlan Somerstypeset -i count=$($ZPOOL history $TESTPOOL | $WC -l | $AWK '{print $1}')
1032fae26bdSAlan Somers
1042fae26bdSAlan Somersif ((count - orig_count != 200)); then
1052fae26bdSAlan Somers	$ZPOOL history $spool
1062fae26bdSAlan Somers	log_fail "Expected 200 more than $orig_count entries, but got $count"
1072fae26bdSAlan Somersfi
1082fae26bdSAlan Somers
1092fae26bdSAlan Somerslog_pass "zpool history copes with simultaneous commands passed."
110