aboutsummaryrefslogtreecommitdiff
path: root/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait_multiple.ksh
blob: a8107b94eb3b9e746a57314638eb97caa4542210 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/ksh -p
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright (c) 2018 by Delphix. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zpool_wait/zpool_wait.kshlib

#
# DESCRIPTION:
# 'zpool wait' works when waiting for multiple activities.
#
# STRATEGY:
# 1. Create a pool with some data.
# 2. Alterate running two different activities (scrub and initialize),
#    making sure that they overlap such that one of the two is always
#    running.
# 3. Wait for both activities with a single invocation of zpool wait.
# 4. Check that zpool wait doesn't return until both activities have
#    stopped.
#

function cleanup
{
	kill_if_running $pid
	poolexists $TESTPOOL && destroy_pool $TESTPOOL

	[[ "$default_chunk_sz" ]] && log_must set_tunable64 \
	    INITIALIZE_CHUNK_SIZE $default_chunk_sz
	log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0
}

typeset pid default_chunk_sz

log_onexit cleanup

log_must zpool create -f $TESTPOOL $DISK1
log_must dd if=/dev/urandom of="/$TESTPOOL/testfile" bs=64k count=1k

default_chunk_sz=$(get_tunable INITIALIZE_CHUNK_SIZE)
log_must set_tunable64 INITIALIZE_CHUNK_SIZE 512
log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1

log_must zpool scrub $TESTPOOL

log_bkgrnd zpool wait -t scrub,initialize $TESTPOOL
pid=$!

log_must sleep 2

log_must zpool initialize $TESTPOOL $DISK1
log_must zpool scrub -s $TESTPOOL

log_must sleep 2

log_must zpool scrub $TESTPOOL
log_must zpool initialize -s $TESTPOOL $DISK1

log_must sleep 2

log_must zpool initialize $TESTPOOL $DISK1
log_must zpool scrub -s $TESTPOOL

log_must sleep 2

proc_must_exist $pid

# Cancel last activity, zpool wait should return
log_must zpool initialize -s $TESTPOOL $DISK1
bkgrnd_proc_succeeded $pid

log_pass "'zpool wait' works when waiting for multiple activities."