diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 41e285a03..144b228bc 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -140,7 +140,7 @@ tests = ['tst.destroy_fs', 'tst.destroy_snap', 'tst.get_count_and_limit', 'tst.promote_multiple', 'tst.promote_simple', 'tst.rollback_mult', 'tst.rollback_one', 'tst.set_props', 'tst.snapshot_destroy', 'tst.snapshot_neg', 'tst.snapshot_recursive', 'tst.snapshot_rename', 'tst.snapshot_simple', - 'tst.bookmark.create', 'tst.bookmark.copy', + 'tst.bookmark.create', 'tst.bookmark.copy', 'tst.clone', 'tst.terminate_by_signal' ] tags = ['functional', 'channel_program', 'synctask_core'] diff --git a/tests/runfiles/sanity.run b/tests/runfiles/sanity.run index 1dbdc4d4e..732f252b5 100644 --- a/tests/runfiles/sanity.run +++ b/tests/runfiles/sanity.run @@ -84,7 +84,7 @@ tests = ['tst.destroy_fs', 'tst.destroy_snap', 'tst.get_count_and_limit', 'tst.promote_multiple', 'tst.promote_simple', 'tst.rollback_mult', 'tst.rollback_one', 'tst.set_props', 'tst.snapshot_destroy', 'tst.snapshot_neg', 'tst.snapshot_recursive', 'tst.snapshot_simple', - 'tst.bookmark.create', 'tst.bookmark.copy'] + 'tst.bookmark.create', 'tst.bookmark.copy', 'tst.clone'] tags = ['functional', 'channel_program', 'synctask_core'] [tests/functional/cli_root/zdb] diff --git a/tests/zfs-tests/tests/Makefile.am b/tests/zfs-tests/tests/Makefile.am index 25247b9fe..02b595be1 100644 --- a/tests/zfs-tests/tests/Makefile.am +++ b/tests/zfs-tests/tests/Makefile.am @@ -124,6 +124,7 @@ nobase_dist_datadir_zfs_tests_tests_DATA += \ functional/channel_program/lua_core/tst.timeout.zcp \ functional/channel_program/synctask_core/tst.bookmark.copy.zcp \ functional/channel_program/synctask_core/tst.bookmark.create.zcp \ + functional/channel_program/synctask_core/tst.clone.zcp \ functional/channel_program/synctask_core/tst.get_index_props.out \ functional/channel_program/synctask_core/tst.get_index_props.zcp \ functional/channel_program/synctask_core/tst.get_number_props.out \ @@ -569,6 +570,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \ functional/channel_program/synctask_core/setup.ksh \ functional/channel_program/synctask_core/tst.bookmark.copy.ksh \ functional/channel_program/synctask_core/tst.bookmark.create.ksh \ + functional/channel_program/synctask_core/tst.clone.ksh \ functional/channel_program/synctask_core/tst.destroy_fs.ksh \ functional/channel_program/synctask_core/tst.destroy_snap.ksh \ functional/channel_program/synctask_core/tst.get_count_and_limit.ksh \ diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.clone.ksh b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.clone.ksh new file mode 100755 index 000000000..d05a8253a --- /dev/null +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.clone.ksh @@ -0,0 +1,55 @@ +#!/bin/ksh -p +# SPDX-License-Identifier: CDDL-1.0 +# +# 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) 2016, 2017 by Delphix. All rights reserved. +# Copyright (c) 2025, Rob Norris +# + +. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib + +# +# DESCRIPTION: Make sure basic cloning functionality works in channel programs +# + +verify_runnable "global" + +base=$TESTPOOL/$TESTFS/base + +function cleanup +{ + destroy_dataset $base "-R" +} + +log_onexit cleanup + +log_must zfs create $base + +# test filesystem cloning +log_must zfs create $base/fs +log_must zfs snapshot $base/fs@snap + +log_must_program_sync $TESTPOOL \ + $ZCP_ROOT/synctask_core/tst.clone.zcp $base/fs@snap $base/newfs + +# test zvol cloning +log_must zfs create -s -V 100G $base/vol +log_must zfs snapshot $base/vol@snap + +log_must_program_sync $TESTPOOL \ + $ZCP_ROOT/synctask_core/tst.clone.zcp $base/vol@snap $base/newvol + +# make sure the dev node was created +block_device_wait $ZVOL_DEVDIR/$base/newvol + +log_pass "Cloning works" diff --git a/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.clone.zcp b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.clone.zcp new file mode 100644 index 000000000..f6f63b09c --- /dev/null +++ b/tests/zfs-tests/tests/functional/channel_program/synctask_core/tst.clone.zcp @@ -0,0 +1,28 @@ +-- SPDX-License-Identifier: CDDL-1.0 +-- +-- 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) 2016, 2017 by Delphix. All rights reserved. +-- Copyright (c) 2025, Rob Norris +-- + +-- This program should be invoked as "zfs program " + +args = ... +argv = args["argv"] +assert(zfs.sync.clone(argv[1], argv[2]) == 0) +clones = {} +for c in zfs.list.clones(argv[1]) do + table.insert(clones, c) +end +assert(#clones == 1) +assert(clones[1] == argv[2])