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.
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.
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]
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
28 # Copyright (c) 2016 by Delphix. All rights reserved.
31 .
$STF_SUITE/include
/libtest.shlib
32 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_upgrade
/zfs_upgrade.kshlib
36 # Executing 'zfs upgrade' command succeeds, it should report
37 # the current system version and list all old-version filesystems.
38 # If no old-version filesystems be founded, it prints out
39 # "All filesystems are formatted with the current version."
42 # 1. Prepare a set of datasets which contain old-version and current version.
43 # 2. Execute 'zfs upgrade', verify return 0, and it prints out
44 # the current system version and list all old-version filesystems.
45 # 3. Remove all old-version filesystems, then execute 'zfs upgrade' again,
46 # verify return 0, and get the expected message.
49 verify_runnable
"both"
53 if datasetexists
$rootfs ; then
54 log_must zfs destroy
-Rf $rootfs
56 log_must zfs create
$rootfs
58 for file in $output $oldoutput ; do
59 if [[ -f $file ]]; then
65 log_assert
"Executing 'zfs upgrade' command succeeds."
68 rootfs
=$TESTPOOL/$TESTFS
69 typeset output
=/tmp
/zfs-versions.$$
70 typeset oldoutput
=/tmp
/zfs-versions-old.$$
71 typeset expect_str1
="This system is currently running ZFS filesystem version"
72 typeset expect_str2
="All filesystems are formatted with the current version"
73 typeset expect_str3
="The following filesystems are out of date, and can be upgraded"
74 typeset
-i COUNT OLDCOUNT
76 zfs upgrade | nawk
'$1 ~ "^[0-9]+$" {print $2}'> $oldoutput
77 OLDCOUNT
=$
( wc -l $oldoutput |
awk '{print $1}' )
80 for version
in $ZFS_ALL_VERSIONS ; do
82 eval verfs
=\
$ZFS_VERSION_$version
83 typeset current_fs
=$rootfs/$verfs
84 typeset current_snap
=${current_fs}@snap
85 typeset current_clone
=$rootfs/clone
$verfs
86 log_must zfs create
-o version
=${version} ${current_fs}
87 log_must zfs snapshot
${current_snap}
88 log_must zfs clone
${current_snap} ${current_clone}
90 if (( version
!= $ZFS_VERSION )); then
91 old_datasets
="$old_datasets ${current_fs} ${current_clone}"
95 if is_global_zone
; then
96 log_must zfs create
-V 100m
$rootfs/$TESTVOL
99 log_must
eval 'zfs upgrade > $output 2>&1'
101 # we also check that the usage message contains at least a description
102 # of the current ZFS version.
103 log_must
eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
104 zfs upgrade | nawk
'$1 ~ "^[0-9]+$" {print $2}'> $output
105 COUNT
=$
( wc -l $output |
awk '{print $1}' )
108 for fs
in ${old_datasets}; do
109 log_must
grep "^$fs$" $output
113 if (( i
!= COUNT
- OLDCOUNT
)); then
115 log_fail
"More old-version filesystems print out than expect."
118 for fs
in $old_datasets ; do
119 if datasetexists
$fs ; then
120 log_must zfs destroy
-Rf $fs
124 log_must
eval 'zfs upgrade > $output 2>&1'
125 log_must
eval 'grep "${expect_str1} $ZFS_VERSION" $output > /dev/null 2>&1'
126 if (( OLDCOUNT
== 0 )); then
127 log_must
eval 'grep "${expect_str2}" $output > /dev/null 2>&1'
129 log_must
eval 'grep "${expect_str3}" $output > /dev/null 2>&1'
131 zfs upgrade | nawk
'$1 ~ "^[0-9]+$" {print $2}'> $output
132 COUNT
=$
( wc -l $output |
awk '{print $1}' )
134 if (( COUNT
!= OLDCOUNT
)); then
136 log_fail
"Unexpect old-version filesystems print out."
139 log_pass
"Executing 'zfs upgrade' command succeeds."