1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or https://opensource.org/licenses/CDDL-1.0. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright (c) 2016, loli10K. All rights reserved. 25# Copyright (c) 2021, Pablo Correa Gómez. All rights reserved. 26# 27 28. $STF_SUITE/tests/functional/cli_root/cli_common.kshlib 29. $STF_SUITE/tests/functional/cli_root/zfs_send/zfs_send.cfg 30 31# 32# DESCRIPTION: 33# Verify 'zfs send' will avoid sending replication send 34# streams when we're missing snapshots in the dataset 35# hierarchy, unless -s|--skip-missing provided 36# 37# STRATEGY: 38# 1. Create a parent and child fs and then only snapshot the parent 39# 2. Verify sending with replication will fail 40# 3. Verify sending with skip-missing will print a warning but succeed 41# 42 43verify_runnable "both" 44 45function cleanup 46{ 47 snapexists $SNAP && destroy_dataset $SNAP -f 48 49 datasetexists $PARENT && destroy_dataset $PARENT -rf 50 51 [[ -e $WARNF ]] && log_must rm -f $WARNF 52} 53 54log_assert "Verify 'zfs send -Rs' works as expected." 55log_onexit cleanup 56 57PARENT=$TESTPOOL/parent 58CHILD=$PARENT/child 59SNAP=$PARENT@snap 60WARNF=$TEST_BASE_DIR/warn.2 61 62log_note "Verify 'zfs send -R' fails to generate replication stream"\ 63 " for datasets created before" 64 65log_must zfs create $PARENT 66log_must zfs create $CHILD 67log_must zfs snapshot $SNAP 68log_mustnot eval "zfs send -R $SNAP > /dev/null" 69 70log_note "Verify 'zfs send -Rs' warns about missing snapshots, "\ 71 "but still succeeds" 72 73log_must eval "zfs send -Rs $SNAP 2> $WARNF > /dev/null" 74log_must eval "[[ -s $WARNF ]]" 75 76log_pass "Verify 'zfs send -Rs' works as expected." 77