]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_sync/zpool_sync_001_pos.ksh
5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
16 # Copyright (c) 2017 Datto Inc.
19 .
$STF_SUITE/include
/libtest.shlib
23 # Verify 'zpool sync' can sync txgs to the pool(s) main vdevs.
27 # 2. Use zdb to obtain current txg
28 # 3. Create a file in the pool if we're not using force sync
29 # 4. Use zpool sync to sync pool
30 # 5. Verify the new txg is now bigger than the saved one
33 verify_runnable
"global"
36 typeset
-i txg
=$
(zdb
-u $1 |
sed -n 's/^.*txg = \(.*\)$/\1/p')
40 set -A args
"sync $TESTPOOL" "sync -f $TESTPOOL" "sync" "sync -f"
42 log_assert
"Verify 'zpool sync' can sync a pool"
47 while [[ $i -lt ${#args[*]} ]]; do
48 orig_txg
=$
(get_txg
$TESTPOOL)
49 if ! [[ "${args[i]}" =~
"-f" ]]; then
50 log_must
touch /$TESTPOOL/$i
52 log_must zpool
${args[i]}
53 new_txg
=$
(get_txg
$TESTPOOL)
54 if [[ $orig_txg -ge $new_txg ]]; then
55 log_fail
"'zpool ${args[i]}' failed: txg $orig_txg >= $new_txg"
60 # sync_pool is implemented using 'zpool sync' so let's test it as well
62 # make sure we can use sync_pool with force sync explicitly not used
63 orig_txg
=$
(get_txg
$TESTPOOL)
64 log_must
touch /$TESTPOOL/$i
65 log_must sync_pool
$TESTPOOL false
66 new_txg
=$
(get_txg
$TESTPOOL)
67 if [[ $orig_txg -ge $new_txg ]]; then
68 log_fail
"'sync_pool $TESTPOOL false' failed: txg $orig_txg >= $new_txg"
71 # make sure we can use sync_pool with force sync explicitly enabled
72 orig_txg
=$
(get_txg
$TESTPOOL)
73 log_must sync_pool
$TESTPOOL true
74 new_txg
=$
(get_txg
$TESTPOOL)
75 if [[ $orig_txg -ge $new_txg ]]; then
76 log_fail
"'sync_pool $TESTPOOL true' failed: txg $orig_txg >= $new_txg"
79 # make sure we can use sync_pool with force sync implicitly not used
80 orig_txg
=$
(get_txg
$TESTPOOL)
81 log_must
touch /$TESTPOOL/$i
82 log_must sync_pool
$TESTPOOL
83 new_txg
=$
(get_txg
$TESTPOOL)
84 if [[ $orig_txg -ge $new_txg ]]; then
85 log_fail
"'sync_pool $TESTPOOL' failed: txg $orig_txg >= $new_txg"
88 log_pass
"'zpool sync' syncs pool as expected."