aboutsummaryrefslogtreecommitdiff
path: root/tests/zfs-tests/tests/functional/cli_root/zpool_wait/zpool_wait_initialize_basic.ksh
blob: 924ae5f0d86d4bdcc675bfd8b6986216679363e0 (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
#!/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 devices to complete initializing
#
# STRATEGY:
# 1. Create a pool.
# 2. Modify a tunable to make sure initializing is slow enough to observe.
# 3. Start initializing the vdev in the pool.
# 4. Start 'zpool wait'.
# 5. Monitor the waiting process to make sure it returns neither too soon nor
#    too late.
#

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

        [[ -d "$TESTDIR" ]] && log_must rm -r "$TESTDIR"

        [[ "$default_chunk_sz" ]] && \
            log_must set_tunable64 INITIALIZE_CHUNK_SIZE $default_chunk_sz
}

typeset -r FILE_VDEV="$TESTDIR/file_vdev"
typeset pid default_chunk_sz

log_onexit cleanup

default_chunk_sz=$(get_tunable INITIALIZE_CHUNK_SIZE)
log_must set_tunable64 INITIALIZE_CHUNK_SIZE 2048

log_must mkdir "$TESTDIR"
log_must mkfile 256M "$FILE_VDEV"
log_must zpool create -f $TESTPOOL "$FILE_VDEV"

log_must zpool initialize $TESTPOOL "$FILE_VDEV"

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

check_while_waiting $pid "is_vdev_initializing $TESTPOOL"

log_pass "'zpool wait -t initialize' works."