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_004_pos
34#
35# DESCRIPTION:
36#	'zpool history' can copes with many simultaneous command.
37#
38# STRATEGY:
39#	1. Create test pool and test fs.
40#	2. Loop 100 times, set properties to test fs simultaneously.
41#	3. Wait for all the command execution complete.
42#	4. Make sure all the commands was logged by 'zpool history'.
43#
44# TESTABILITY: explicit
45#
46# TEST_AUTOMATION_LEVEL: automated
47#
48# CODING_STATUS: COMPLETED (2006-07-05)
49#
50# __stc_assertion_end
51#
52################################################################################
53
54verify_runnable "global"
55
56log_assert "'zpool history' can copes with many simultaneous command."
57
58typeset -i orig_count=$($ZPOOL history $TESTPOOL | $WC -l | $AWK '{print $1}')
59
60typeset -i i=0
61while ((i < 10)); do
62	$ZFS set compression=off $TESTPOOL/$TESTFS &
63	$ZFS set atime=off $TESTPOOL/$TESTFS &
64	$ZFS create $TESTPOOL/$TESTFS1 &
65	$ZFS create $TESTPOOL/$TESTFS2 &
66	$ZFS create $TESTPOOL/$TESTFS3 &
67
68	wait
69
70	$ZFS snapshot $TESTPOOL/$TESTFS1@snap &
71	$ZFS snapshot $TESTPOOL/$TESTFS2@snap &
72	$ZFS snapshot $TESTPOOL/$TESTFS3@snap &
73
74	wait
75
76	$ZFS clone $TESTPOOL/$TESTFS1@snap $TESTPOOL/clone1 &
77	$ZFS clone $TESTPOOL/$TESTFS2@snap $TESTPOOL/clone2 &
78	$ZFS clone $TESTPOOL/$TESTFS3@snap $TESTPOOL/clone3 &
79
80	wait
81
82	$ZFS promote $TESTPOOL/clone1 &
83	$ZFS promote $TESTPOOL/clone2 &
84	$ZFS promote $TESTPOOL/clone3 &
85
86	wait
87
88	$ZFS destroy $TESTPOOL/$TESTFS1 &
89	$ZFS destroy $TESTPOOL/$TESTFS2 &
90	$ZFS destroy $TESTPOOL/$TESTFS3 &
91
92	wait
93
94	$ZFS destroy -Rf $TESTPOOL/clone1 &
95	$ZFS destroy -Rf $TESTPOOL/clone2 &
96	$ZFS destroy -Rf $TESTPOOL/clone3 &
97
98	wait
99	((i += 1))
100done
101
102typeset -i count=$($ZPOOL history $TESTPOOL | $WC -l | $AWK '{print $1}')
103
104if ((count - orig_count != 200)); then
105	$ZPOOL history $spool
106	log_fail "Expected 200 more than $orig_count entries, but got $count"
107fi
108
109log_pass "zpool history copes with simultaneous commands passed."
110