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# ident	"@(#)history_004_pos.ksh	1.2	07/01/09 SMI"
28#
29
30. $STF_SUITE/tests/history/history_common.kshlib
31
32#################################################################################
33#
34# __stc_assertion_start
35#
36# ID: history_004_pos
37#
38# DESCRIPTION:
39#	'zpool history' can copes with many simultaneous command.
40#
41# STRATEGY:
42#	1. Create test pool and test fs.
43#	2. Loop 100 times, set properties to test fs simultaneously.
44#	3. Wait for all the command execution complete.
45#	4. Make sure all the commands was logged by 'zpool history'.
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
59log_assert "'zpool history' can copes with many simultaneous command."
60
61typeset -i orig_count=$($ZPOOL history $TESTPOOL | $WC -l | $AWK '{print $1}')
62
63typeset -i i=0
64while ((i < 10)); do
65	$ZFS set compression=off $TESTPOOL/$TESTFS &
66	$ZFS set atime=off $TESTPOOL/$TESTFS &
67	$ZFS create $TESTPOOL/$TESTFS1 &
68	$ZFS create $TESTPOOL/$TESTFS2 &
69	$ZFS create $TESTPOOL/$TESTFS3 &
70
71	wait
72
73	$ZFS snapshot $TESTPOOL/$TESTFS1@snap &
74	$ZFS snapshot $TESTPOOL/$TESTFS2@snap &
75	$ZFS snapshot $TESTPOOL/$TESTFS3@snap &
76
77	wait
78
79	$ZFS clone $TESTPOOL/$TESTFS1@snap $TESTPOOL/clone1 &
80	$ZFS clone $TESTPOOL/$TESTFS2@snap $TESTPOOL/clone2 &
81	$ZFS clone $TESTPOOL/$TESTFS3@snap $TESTPOOL/clone3 &
82
83	wait
84
85	$ZFS promote $TESTPOOL/clone1 &
86	$ZFS promote $TESTPOOL/clone2 &
87	$ZFS promote $TESTPOOL/clone3 &
88
89	wait
90
91	$ZFS destroy $TESTPOOL/$TESTFS1 &
92	$ZFS destroy $TESTPOOL/$TESTFS2 &
93	$ZFS destroy $TESTPOOL/$TESTFS3 &
94
95	wait
96
97	$ZFS destroy -Rf $TESTPOOL/clone1 &
98	$ZFS destroy -Rf $TESTPOOL/clone2 &
99	$ZFS destroy -Rf $TESTPOOL/clone3 &
100
101	wait
102	((i += 1))
103done
104
105typeset -i count=$($ZPOOL history $TESTPOOL | $WC -l | $AWK '{print $1}')
106
107if ((count - orig_count != 200)); then
108	$ZPOOL history $spool
109	log_fail "Expected 200 more than $orig_count entries, but got $count"
110fi
111
112log_pass "zpool history copes with simultaneous commands passed."
113