xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/history/history_004_pos.ksh (revision 458f44a49dc56cd17a39815122214e7a1b4793e3)
1#!/bin/ksh -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
28#
29# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30#
31
32. $STF_SUITE/include/libtest.shlib
33
34#
35# DESCRIPTION:
36#	'zpool history' can cope with simultaneous commands.
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
45verify_runnable "global"
46
47log_assert "'zpool history' can cope with simultaneous commands."
48
49typeset -i orig_count=$(zpool history $spool | wc -l | awk '{print $1}')
50
51typeset -i i=0
52while ((i < 10)); do
53	zfs set compression=off $TESTPOOL/$TESTFS &
54	zfs set atime=off $TESTPOOL/$TESTFS &
55	zfs create $TESTPOOL/$TESTFS1 &
56	zfs create $TESTPOOL/$TESTFS2 &
57	zfs create $TESTPOOL/$TESTFS3 &
58
59	wait
60
61	zfs snapshot $TESTPOOL/$TESTFS1@snap &
62	zfs snapshot $TESTPOOL/$TESTFS2@snap &
63	zfs snapshot $TESTPOOL/$TESTFS3@snap &
64
65	wait
66
67	zfs clone $TESTPOOL/$TESTFS1@snap $TESTPOOL/clone1 &
68	zfs clone $TESTPOOL/$TESTFS2@snap $TESTPOOL/clone2 &
69	zfs clone $TESTPOOL/$TESTFS3@snap $TESTPOOL/clone3 &
70
71	wait
72
73	zfs promote $TESTPOOL/clone1 &
74	zfs promote $TESTPOOL/clone2 &
75	zfs promote $TESTPOOL/clone3 &
76
77	wait
78
79	zfs destroy $TESTPOOL/$TESTFS1 &
80	zfs destroy $TESTPOOL/$TESTFS2 &
81	zfs destroy $TESTPOOL/$TESTFS3 &
82
83	wait
84
85	zfs destroy -Rf $TESTPOOL/clone1 &
86	zfs destroy -Rf $TESTPOOL/clone2 &
87	zfs destroy -Rf $TESTPOOL/clone3 &
88
89	wait
90	((i += 1))
91done
92
93typeset -i entry_count=$(zpool history $spool | wc -l | awk '{print $1}')
94
95if ((entry_count - orig_count != 200)); then
96	log_fail "The entries count error: entry_count=$entry_count " \
97		 "orig_count = $orig_count"
98fi
99
100log_pass "'zpool history' can cope with simultaneous commands."
101