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