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_005_pos 34# 35# DESCRIPTION: 36# Executing 'zfs upgrade [-V version] -a' command succeeds, 37# it upgrade all filesystems 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 [-V version] -a', verify return 0, 42# 3. Verify all the filesystems be updated 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 [-V version] -a' command succeeds." 88 89$DF -t zfs / > /dev/null 2>&1 90if (( $? == 0 )) ; then 91 log_unsupported "This case should not run on ZFS root system" 92fi 93 94log_onexit cleanup 95 96rootfs=$TESTPOOL/$TESTFS 97 98typeset datasets 99 100typeset newv 101for newv in "" "current" $ZFS_VERSION; do 102 setup_datasets 103 if [[ -n $newv ]]; then 104 opt="-V $newv" 105 if [[ $newv == current ]]; then 106 newv=$ZFS_VERSION 107 fi 108 else 109 newv=$ZFS_VERSION 110 fi 111 112 log_must eval '$ZFS upgrade $opt -a > /dev/null 2>&1' 113 114 for fs in $($ZFS list -rH -t filesystem -o name $rootfs) ; do 115 log_must check_fs_version $fs $newv 116 done 117 cleanup 118done 119 120log_pass "Executing 'zfs upgrade [-V version] -a' command succeeds." 121