summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLOLi <[email protected]>2018-05-08 06:11:59 +0200
committerBrian Behlendorf <[email protected]>2018-05-07 21:11:58 -0700
commit4ceb8dd6fdfdde3b6ac55cf52132858973fce9d0 (patch)
treeb0403036d7c98772746e44961df3b5880918c4e1 /tests
parentc02c1becce96969ea20a2e142dd451cc37d2a9a0 (diff)
Fix 'zpool create -t <tempname>'
Creating a pool with a temporary name fails when we also specify custom dataset properties: this is because we mistakenly call zfs_set_prop_nvlist() on the "real" pool name which, as expected, cannot be found because the SPA is present in the namespace with the temporary name. Fix this by specifying the correct pool name when setting the dataset properties. Reviewed-by: Prakash Surya <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #7502 Closes #7509
Diffstat (limited to 'tests')
-rw-r--r--tests/runfiles/linux.run2
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am3
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh68
3 files changed, 71 insertions, 2 deletions
diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run
index 1d0b2ef91..eecac8f6e 100644
--- a/tests/runfiles/linux.run
+++ b/tests/runfiles/linux.run
@@ -317,7 +317,7 @@ tests = ['zpool_create_001_pos', 'zpool_create_002_pos',
'zpool_create_features_001_pos', 'zpool_create_features_002_pos',
'zpool_create_features_003_pos', 'zpool_create_features_004_neg',
'zpool_create_features_005_pos',
- 'create-o_ashift']
+ 'create-o_ashift', 'zpool_create_tempname']
tags = ['functional', 'cli_root', 'zpool_create']
[tests/functional/cli_root/zpool_destroy]
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am
index 89b36fa99..3c595935a 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/Makefile.am
@@ -32,7 +32,8 @@ dist_pkgdata_SCRIPTS = \
zpool_create_features_003_pos.ksh \
zpool_create_features_004_neg.ksh \
zpool_create_features_005_pos.ksh \
- create-o_ashift.ksh
+ create-o_ashift.ksh \
+ zpool_create_tempname.ksh
dist_pkgdata_DATA = \
zpool_create.cfg \
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh
new file mode 100755
index 000000000..1e6fcea03
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname.ksh
@@ -0,0 +1,68 @@
+#!/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 2018, loli10K <[email protected]>. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+#
+# DESCRIPTION:
+# 'zpool create -t <tempname>' can create a pool with the specified temporary
+# name. The pool should be present in the namespace as <tempname> until exported
+#
+# STRATEGY:
+# 1. Create a pool with '-t' option
+# 2. Verify the pool is created with the specified temporary name
+#
+
+verify_runnable "global"
+
+function cleanup
+{
+ destroy_pool $TESTPOOL
+ destroy_pool $TEMPPOOL
+
+}
+
+log_assert "'zpool create -t <tempname>' can create a pool with the specified" \
+ " temporary name."
+log_onexit cleanup
+
+TEMPPOOL="tempname.$$"
+typeset poolprops=('comment=text' 'ashift=12' 'listsnapshots=on' 'autoexpand=on'
+ 'autoreplace=on' 'delegation=off' 'failmode=continue')
+typeset fsprops=('canmount=off' 'mountpoint=none' 'utf8only=on'
+ 'casesensitivity=mixed' 'version=1' 'normalization=formKD')
+
+for poolprop in "${poolprops[@]}"; do
+ for fsprop in "${fsprops[@]}"; do
+ # 1. Create a pool with '-t' option
+ log_must zpool create $TESTPOOL -t $TEMPPOOL \
+ -O $fsprop -o $poolprop $DISKS
+ # 2. Verify the pool is created with the specified temporary name
+ log_must poolexists $TEMPPOOL
+ log_mustnot poolexists $TESTPOOL
+ propname="$(awk -F= '{print $1}' <<< $fsprop)"
+ propval="$(awk -F= '{print $2}' <<< $fsprop)"
+ log_must test "$(get_prop $propname $TEMPPOOL)" == "$propval"
+ propname="$(awk -F= '{print $1}' <<< $poolprop)"
+ propval="$(awk -F= '{print $2}' <<< $poolprop)"
+ log_must test "$(get_pool_prop $propname $TEMPPOOL)" == "$propval"
+ # Cleanup
+ destroy_pool $TEMPPOOL
+ done
+done
+
+log_pass "'zpool create -t <tempname>' successfully creates pools with" \
+ " temporary names"