]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add basic functional tests for zcp user properties
authorDon Brady <don.brady@delphix.com>
Thu, 8 Feb 2018 16:27:00 +0000 (09:27 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 8 Feb 2018 23:29:32 +0000 (15:29 -0800)
Signed-off-by: Don Brady <don.brady@delphix.com>
tests/runfiles/linux.run
tests/zfs-tests/tests/functional/channel_program/synctask_core/Makefile.am
tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_user_props.ksh [new file with mode: 0755]

index a844d6b1bc2ed7122cb75164dfb37834d8465a9e..1bd3fd6053d406f74d0e775f4abc32fd54fd7e80 100644 (file)
@@ -78,10 +78,10 @@ tests = ['tst.destroy_fs', 'tst.destroy_snap', 'tst.get_count_and_limit',
     'tst.get_number_props', 'tst.get_string_props', 'tst.get_type',
     'tst.get_userquota', 'tst.get_written', 'tst.list_children',
     'tst.list_clones', 'tst.list_snapshots', 'tst.list_system_props',
-    'tst.parse_args_neg', 'tst.promote_conflict', 'tst.promote_multiple',
-    'tst.promote_simple', 'tst.rollback_mult', 'tst.rollback_one',
-    'tst.snapshot_destroy', 'tst.snapshot_neg', 'tst.snapshot_recursive',
-    'tst.snapshot_simple']
+    'tst.list_user_props', 'tst.parse_args_neg','tst.promote_conflict',
+    'tst.promote_multiple', 'tst.promote_simple', 'tst.rollback_mult',
+    'tst.rollback_one', 'tst.snapshot_destroy', 'tst.snapshot_neg',
+    'tst.snapshot_recursive', 'tst.snapshot_simple']
 tags = ['functional', 'channel_program', 'synctask_core']
 
 [tests/functional/chattr]
index 48b89b5782eb50bfcce21be04945a3f62605e2ec..93ec25a03b3c9199352fffd15688f47026677236 100644 (file)
@@ -23,6 +23,7 @@ dist_pkgdata_SCRIPTS = \
        tst.list_clones.ksh \
        tst.list_snapshots.ksh \
        tst.list_system_props.ksh \
+       tst.list_user_props.ksh \
        tst.parse_args_neg.ksh \
        tst.promote_conflict.ksh \
        tst.promote_conflict.zcp \
diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_user_props.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.list_user_props.ksh
new file mode 100755 (executable)
index 0000000..910dddc
--- /dev/null
@@ -0,0 +1,98 @@
+#!/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) 2017 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib
+
+#
+# DESCRIPTION:
+#       Listing zfs user properties should work correctly.
+#
+
+verify_runnable "global"
+
+TESTPROP="org.openzfs:test_property"
+TESTPROP1=$TESTPROP-1
+TESTPROP2=$TESTPROP-2
+TESTPROP3=$TESTPROP-3
+TESTPROP4=$TESTPROP-4
+
+TESTVAL="true"
+TESTVAL1="busy"
+TESTVAL2="9223372036854775808"
+TESTVAL3="801f2266-3715-41f4-9080-3d5e913b0f15"
+TESTVAL4="TOZwOfACvQtmDyiq68elB3a3g9YYyxBjSnLtN3ZyQYNOAKykzIE2khKKOBncJiDx"
+
+
+# 0 properties handled correctly
+log_must_program $TESTPOOL - <<-EOF
+       n = 0
+       for p in zfs.list.properties("$TESTPOOL/$TESTFS") do
+               n = n + 1
+       end
+       assert(n == 0)
+       return 0
+EOF
+
+# Add a single user property
+log_must zfs set $TESTPROP="$TESTVAL" $TESTPOOL/$TESTFS
+
+log_must_program $TESTPOOL - <<-EOF
+       n = 0
+       for p,v in zfs.list.properties("$TESTPOOL/$TESTFS") do
+               assert(p == "$TESTPROP")
+               assert(v == "$TESTVAL")
+               n = n + 1
+       end
+       assert(n == 1)
+       return 0
+EOF
+
+log_must zfs set $TESTPROP1="$TESTVAL1" $TESTPOOL/$TESTFS
+log_must zfs set $TESTPROP2="$TESTVAL2" $TESTPOOL/$TESTFS
+log_must zfs set $TESTPROP3="$TESTVAL3" $TESTPOOL/$TESTFS
+log_must zfs set $TESTPROP4="$TESTVAL4" $TESTPOOL/$TESTFS
+
+# All user properties have correct value and appear exactly once
+log_must_program $TESTPOOL - <<-EOF
+       a = {}
+       a["$TESTPROP"] = false
+       a["$TESTPROP1"] = false
+       a["$TESTPROP2"] = false
+       a["$TESTPROP3"] = false
+       a["$TESTPROP4"] = false
+       m = {}
+       m["$TESTPROP"] = "$TESTVAL"
+       m["$TESTPROP1"] = "$TESTVAL1"
+       m["$TESTPROP2"] = "$TESTVAL2"
+       m["$TESTPROP3"] = "$TESTVAL3"
+       m["$TESTPROP4"] = "$TESTVAL4"
+       n = 0
+       for p,v in zfs.list.properties("$TESTPOOL/$TESTFS") do
+               assert(not a[p])
+               a[p] = true
+               assert(v == m[p])
+               n = n + 1
+       end
+       assert(n == 5)
+       assert(a["$TESTPROP"] and
+           a["$TESTPROP1"] and
+           a["$TESTPROP2"] and
+           a["$TESTPROP3"] and
+           a["$TESTPROP4"])
+       return 0
+EOF
+
+log_pass "Listing zfs user properies should work correctly."