1#!/usr/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 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# 27# 28. $STF_SUITE/include/libtest.shlib 29. $STF_SUITE/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib 30 31# 32# DESCRIPTION: 33# Executing 'zfs upgrade [-V version] filesystem' command succeeds, 34# it could upgrade a filesystem to specific version or current version. 35# 36# STRATEGY: 37# 1. Prepare a set of datasets which contain old-version and current version. 38# 2. Execute 'zfs upgrade [-V version] filesystem', verify return 0, 39# 3. Verify the filesystem be updated as expected. 40# 41 42verify_runnable "both" 43 44function cleanup 45{ 46 if datasetexists $rootfs ; then 47 log_must $ZFS destroy -Rf $rootfs 48 fi 49 log_must $ZFS create $rootfs 50} 51 52function setup_datasets 53{ 54 datasets="" 55 for version in $ZFS_ALL_VERSIONS ; do 56 typeset verfs 57 eval verfs=\$ZFS_VERSION_$version 58 typeset current_fs=$rootfs/$verfs 59 typeset current_snap=${current_fs}@snap 60 typeset current_clone=$rootfs/clone$verfs 61 log_must $ZFS create -o version=${version} ${current_fs} 62 log_must $ZFS snapshot ${current_snap} 63 log_must $ZFS clone ${current_snap} ${current_clone} 64 datasets="$datasets ${current_fs} ${current_clone}" 65 done 66} 67 68log_assert "Executing 'zfs upgrade [-V version] filesystem' command succeeds." 69log_onexit cleanup 70 71rootfs=$TESTPOOL/$TESTFS 72typeset datasets 73 74typeset newv 75for newv in "" "current" $ZFS_ALL_VERSIONS; do 76 setup_datasets 77 for fs in $datasets ; do 78 typeset -i oldv=$(get_prop version $fs) 79 80 if [[ -n $newv ]]; then 81 opt="-V $newv" 82 if [[ $newv == current ]]; then 83 newv=$ZFS_VERSION 84 fi 85 else 86 newv=$ZFS_VERSION 87 fi 88 89 if (( newv >= oldv )); then 90 log_must eval '$ZFS upgrade $opt $fs > /dev/null 2>&1' 91 log_must check_fs_version $fs $newv 92 else 93 log_mustnot eval '$ZFS upgrade $opt $fs > /dev/null 2>&1' 94 log_must check_fs_version $fs $oldv 95 fi 96 done 97 cleanup 98done 99 100log_pass "Executing 'zfs upgrade [-V version] filesystem' command succeeds." 101