]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/pool_checkpoint/checkpoint_invalid.ksh
OpenZFS 9166 - zfs storage pool checkpoint
[mirror_zfs.git] / tests / zfs-tests / tests / functional / pool_checkpoint / checkpoint_invalid.ksh
1 #!/bin/ksh -p
2
3 #
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
8 #
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
12 #
13
14 #
15 # Copyright (c) 2017 by Delphix. All rights reserved.
16 #
17
18 . $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib
19
20 #
21 # DESCRIPTION:
22 # Try each 'zpool checkpoint' and relevant 'zpool import' with
23 # invalid inputs to ensure it returns an error. That includes:
24 # * A non-existent pool name or no pool name at all is supplied
25 # * Pool supplied for discarding or rewinding but the pool
26 # does not have a checkpoint
27 # * A dataset or a file/directory are supplied instead of a pool
28 #
29 # STRATEGY:
30 # 1. Create an array of parameters for the different scenarios
31 # 2. For each parameter, execute the scenarios sub-command
32 # 3. Verify that an error was returned
33 #
34
35 verify_runnable "global"
36
37 setup_test_pool
38 log_onexit cleanup_test_pool
39 populate_test_pool
40
41 #
42 # Argument groups below. Note that all_args also includes
43 # an empty string as "run command with no argument".
44 #
45 set -A all_args "" "-d" "--discard"
46
47 #
48 # Target groups below. Note that invalid_targets includes
49 # an empty string as "do not supply a pool name".
50 #
51 set -A invalid_targets "" "iDontExist" "$FS0" "$FS0FILE"
52 non_checkpointed="$TESTPOOL"
53
54 #
55 # Scenario 1
56 # Trying all checkpoint args with all invalid targets
57 #
58 typeset -i i=0
59 while (( i < ${#invalid_targets[*]} )); do
60 typeset -i j=0
61 while (( j < ${#all_args[*]} )); do
62 log_mustnot zpool checkpoint ${all_args[j]} \
63 ${invalid_targets[i]}
64 ((j = j + 1))
65 done
66 ((i = i + 1))
67 done
68
69 #
70 # Scenario 2
71 # If the pool does not have a checkpoint, -d nor import rewind
72 # should work with it.
73 #
74 log_mustnot zpool checkpoint -d $non_checkpointed
75 log_must zpool export $non_checkpointed
76 log_mustnot zpool import --rewind-to-checkpoint $non_checkpointed
77 log_must zpool import $non_checkpointed
78
79 log_pass "Badly formed checkpoint related commands with " \
80 "invalid inputs fail as expected."