1#!/usr/local/bin/ksh93 -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 http://www.opensolaris.org/os/licensing. 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 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26. $STF_SUITE/include/libtest.kshlib 27. $STF_SUITE/tests/cli_root/zfs_upgrade/zfs_upgrade.kshlib 28 29################################################################################ 30# 31# __stc_assertion_start 32# 33# ID: zfs_upgrade_004_pos 34# 35# DESCRIPTION: 36# Executing 'zfs upgrade -r [-V version] filesystem' command succeeds, 37# it upgrade filesystem recursively to specific or current version. 38# 39# STRATEGY: 40# 1. Prepare a set of datasets which contain old-version and current version. 41# 2. Execute 'zfs upgrade -r [-V version] filesystem', verify return 0, 42# 3. Verify the filesystem be updated recursively as expected. 43# 44# TESTABILITY: explicit 45# 46# TEST_AUTOMATION_LEVEL: automated 47# 48# CODING_STATUS: COMPLETED (2007-06-25) 49# 50# __stc_assertion_end 51# 52################################################################################ 53 54verify_runnable "both" 55 56function cleanup 57{ 58 if datasetexists $rootfs ; then 59 log_must $ZFS destroy -Rf $rootfs 60 fi 61 log_must $ZFS create $rootfs 62} 63 64function setup_datasets 65{ 66 datasets="" 67 for version in $ZFS_ALL_VERSIONS ; do 68 typeset verfs 69 eval verfs=\$ZFS_VERSION_$version 70 typeset current_fs=$rootfs/$verfs 71 typeset current_snap=${current_fs}@snap 72 typeset current_clone=$rootfs/clone$verfs 73 log_must $ZFS create -o version=${version} ${current_fs} 74 log_must $ZFS snapshot ${current_snap} 75 log_must $ZFS clone ${current_snap} ${current_clone} 76 77 for subversion in $ZFS_ALL_VERSIONS ; do 78 typeset subverfs 79 eval subverfs=\$ZFS_VERSION_$subversion 80 log_must $ZFS create -o version=${subversion} \ 81 ${current_fs}/$subverfs 82 done 83 datasets="$datasets ${current_fs}" 84 done 85} 86 87log_assert "Executing 'zfs upgrade -r [-V version] filesystem' command succeeds." 88log_onexit cleanup 89 90rootfs=$TESTPOOL/$TESTFS 91 92typeset datasets 93 94typeset newv 95for newv in "" "current" $ZFS_VERSION; do 96 setup_datasets 97 for topfs in $datasets ; do 98 if [[ -n $newv ]]; then 99 opt="-V $newv" 100 if [[ $newv == current ]]; then 101 newv=$ZFS_VERSION 102 fi 103 else 104 newv=$ZFS_VERSION 105 fi 106 107 log_must eval '$ZFS upgrade -r $opt $topfs > /dev/null 2>&1' 108 109 for fs in $($ZFS list -rH -t filesystem -o name $topfs) ; do 110 log_must check_fs_version $fs $newv 111 done 112 done 113 cleanup 114done 115 116log_pass "Executing 'zfs upgrade -r [-V version] filesystem' command succeeds." 117