Source

illumos-stc / usr / src / suites / storage / ndmp / zfs / tests / package / full / zfs_snap / tp_package_full_zfs_snap_001.ksh

Full commit
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#


#

# __stc_assertion_start
#
# ID: tp_package_full_zfs_snap_001
#
# DESCRIPTION:
# 	When ZFS_MODE=package, ndmpd successfully perform a full backup 
#	and restore for a directory which pointer to a snapshot. And
#	there snapshot pointer to a zfs dataset      
#
# STRATEGY:
#
#	Setup:
#		1. Create a zpool
#		2. Create zfs dataset
#		3. Copy data into the zfs 
#		4. Create a snapshot for the zfs 
#		5. Setup parameters in OSB client for backup and restore.
#		
#	Test:
#		1. Backup the dataset, check the status
#		2. Restore the dataset, check the status
#		3. Compare the restored data with original data, they 
#		   should be consistent.
#
#	Cleanup:
#		1. Destroy the zpool.	
#
#	STRATEGY_NOTES:
#
# TESTABILITY: explicit
#
# AUTHOR: zheng.he@sun.com
#
# REVIEWERS:
#
# ASSERTION_SOURCE:
#
# TEST_AUTOMATION_LEVEL: automated
#
# STATUS: IN_PROGRESS
#
# COMMENTS:
#
# __stc_assertion_end
#
function tp_package_full_zfs_snap_001
{
	cti_pass

	typeset tc_id tc_desc 
        tc_id="tp_package_full_zfs_snap_001"
        tc_desc="full backup restore \
                Path: zfs snapshot; Content: 1. normal files"

	print_test_case "${tc_id} - ${tc_desc}"
	typeset jobid state res
	
	zpool_destroy $ROOT_ZPOOL
	zpool_create  $ROOT_ZPOOL $BDEVS

	zfs_create "${ROOT_ZPOOL}/zfs"
	zfs_fill_data "/${ROOT_ZPOOL}/zfs"
	zfs_snapshot "${ROOT_ZPOOL}/zfs@first"

	osb_mkhost 
	osb_mkds "/${ROOT_ZPOOL}/zfs@first" "my_ds"

	osb_set_backup_type zfs
	osb_set_backup_env HIST n
	osb_add_backup_env ZFS_MODE package
	osb_set_restore_env DIRECT n

	jobid="$(osb_backup 0 'my_ds')" 
		
	if [[ $? -ne 0 ]] ; then
		zpool_destroy $ROOT_ZPOOL
		cti_fail "backup job fail"
		return;
	fi

	osb_restore_to ${jobid} /${ROOT_ZPOOL}/zfs-restore

	if [[ $? -ne 0 ]] ; then
		zpool_destroy $ROOT_ZPOOL
		cti_fail "restore job fail"
		return;
	fi

	zfs_mount ${ROOT_ZPOOL}/zfs-restore

	compare_fs /${ROOT_ZPOOL}/zfs /${ROOT_ZPOOL}/zfs-restore
	if [[ $? -ne 0 ]] ; then
		cti_fail "compare_fs fail"
	fi
	zpool_destroy $ROOT_ZPOOL
}