Mercurial > illumos > illumos-gate
comparison usr/src/test/zfs-tests/tests/functional/cli_root/zfs_upgrade/zfs_upgrade.kshlib @ 13899:0bcf78798346
3311 Want a test framework for arbitrary OS unit tests
3312 Add a testrunner package for OS unit tests
3313 Add a testrunner package to convert ZFS tests from STF
Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com>
Reviewed by: Will Guyette <will.guyette@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Henrik Mattson <henrik.mattson@delphix.com>
Reviewed by: Sonu Pillai <sonu.pillai@delphix.com>
Reviewed by: Christopher Siden <chris.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Richard Lowe <richlowe@richlowe.net>
author | John Wren Kennedy <john.kennedy@delphix.com> |
---|---|
date | Wed, 05 Dec 2012 22:04:50 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13898:7f822b09519b | 13899:0bcf78798346 |
---|---|
1 # | |
2 # CDDL HEADER START | |
3 # | |
4 # The contents of this file are subject to the terms of the | |
5 # Common Development and Distribution License (the "License"). | |
6 # You may not use this file except in compliance with the License. | |
7 # | |
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 # or http://www.opensolaris.org/os/licensing. | |
10 # See the License for the specific language governing permissions | |
11 # and limitations under the License. | |
12 # | |
13 # When distributing Covered Code, include this CDDL HEADER in each | |
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 # If applicable, add the following below this CDDL HEADER, with the | |
16 # fields enclosed by brackets "[]" replaced with your own identifying | |
17 # information: Portions Copyright [yyyy] [name of copyright owner] | |
18 # | |
19 # CDDL HEADER END | |
20 # | |
21 | |
22 # | |
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved. | |
24 # Use is subject to license terms. | |
25 # | |
26 | |
27 . $STF_SUITE/include/libtest.shlib | |
28 | |
29 # | |
30 # For zfs create. | |
31 # | |
32 set -A zpl_create_versions 3 4 5 | |
33 set -A spa_create_versions 9 15 24 | |
34 | |
35 # | |
36 # For zfs upgrade | |
37 # | |
38 set -A zpl_upgrade_versions 3 4 5 | |
39 set -A spa_upgrade_versions 9 15 24 | |
40 | |
41 function default_setup_datasets #rootfs | |
42 { | |
43 typeset rootfs=$1 | |
44 typeset pool=${rootfs%%/*} | |
45 typeset -i vp=$(get_pool_prop version $pool) | |
46 typeset -i version | |
47 typeset -i m | |
48 typeset -i spa_version | |
49 typeset -i zpl_version | |
50 | |
51 for version in $ZFS_ALL_VERSIONS ; do | |
52 typeset verfs | |
53 eval verfs=\$ZFS_VERSION_$version | |
54 typeset current_fs=$rootfs/$verfs | |
55 typeset current_snap=${current_fs}@snap | |
56 typeset current_clone=$rootfs/clone$verfs | |
57 | |
58 (( m=0 )) | |
59 (( spa_version=0 )) | |
60 while (( m < ${#zpl_create_versions[@]} )); do | |
61 (( zpl_version=${zpl_create_versions[m]} )) | |
62 if (( version == zpl_version )); then | |
63 (( spa_version=${spa_create_versions[m]} )) | |
64 break | |
65 fi | |
66 (( m+=1 )) | |
67 done | |
68 if (( spa_version != 0 )) && (( vp < spa_version )); then | |
69 log_mustnot $ZFS create -o version=${version} ${current_fs} | |
70 continue | |
71 fi | |
72 log_must $ZFS create -o version=${version} ${current_fs} | |
73 log_must $ZFS snapshot ${current_snap} | |
74 log_must $ZFS clone ${current_snap} ${current_clone} | |
75 | |
76 for subversion in $ZFS_ALL_VERSIONS ; do | |
77 typeset subverfs | |
78 eval subverfs=\$ZFS_VERSION_$subversion | |
79 | |
80 (( m=0 )) | |
81 (( spa_version=0 )) | |
82 while (( m < ${#zpl_create_versions[@]} )); do | |
83 (( zpl_version=${zpl_create_versions[m]} )) | |
84 if (( subversion == zpl_version )); then | |
85 (( spa_version=${spa_create_versions[m]} )) | |
86 break | |
87 fi | |
88 (( m+=1 )) | |
89 done | |
90 if (( spa_version != 0 )) && (( vp < spa_version )); then | |
91 log_mustnot $ZFS create -o \ | |
92 version=${subversion} ${current_fs}/$subverfs | |
93 else | |
94 log_must $ZFS create -o \ | |
95 version=${subversion} ${current_fs}/$subverfs | |
96 fi | |
97 done | |
98 done | |
99 } | |
100 | |
101 function default_cleanup_datasets #rootfs | |
102 { | |
103 typeset rootfs=$1 | |
104 | |
105 if datasetexists $rootfs ; then | |
106 log_must $ZFS destroy -Rf $rootfs | |
107 fi | |
108 | |
109 if datasetnonexists $rootfs ; then | |
110 log_must $ZFS create $rootfs | |
111 fi | |
112 } | |
113 | |
114 function default_check_zfs_upgrade #rootfs | |
115 { | |
116 typeset rootfs=$1 | |
117 typeset pool=${rootfs%%/*} | |
118 typeset -i vp=$(get_pool_prop version $pool) | |
119 typeset -i m | |
120 typeset -i spa_version | |
121 typeset -i zpl_version | |
122 typeset newv | |
123 typeset -i df_ret | |
124 | |
125 $DF -F zfs / > /dev/null 2>&1 | |
126 df_ret=$? | |
127 | |
128 for newv in "" $ZFS_VERSION; do | |
129 default_setup_datasets $rootfs | |
130 if [[ -n $newv ]]; then | |
131 opt="-V $newv" | |
132 else | |
133 newv=$ZFS_VERSION | |
134 fi | |
135 | |
136 (( m=0 )) | |
137 (( spa_version=0 )) | |
138 while (( m < ${#zpl_upgrade_versions[@]} )); do | |
139 (( zpl_version=${zpl_upgrade_versions[m]} )) | |
140 if (( newv == zpl_version )); then | |
141 (( spa_version=${spa_upgrade_versions[m]} )) | |
142 break | |
143 fi | |
144 (( m+=1 )) | |
145 done | |
146 | |
147 if (( df_ret != 0 )); then | |
148 if (( spa_version != 0 )) && (( vp < spa_version )); then | |
149 log_mustnot eval '$ZFS upgrade $opt -a > /dev/null 2>&1' | |
150 log_must eval '$ZPOOL upgrade $pool > /dev/null 2>&1' | |
151 vp=$(get_pool_prop version $pool) | |
152 fi | |
153 | |
154 log_must eval '$ZFS upgrade $opt -a > /dev/null 2>&1' | |
155 | |
156 for fs in $($ZFS list -rH -t filesystem -o name $rootfs) ; do | |
157 log_must check_fs_version $fs $newv | |
158 done | |
159 fi | |
160 | |
161 default_cleanup_datasets $rootfs | |
162 done | |
163 } | |
164 | |
165 function check_fs_version #filesystem version | |
166 { | |
167 typeset fs=$1 | |
168 typeset -i version=${2:-$ZFS_VERSION} | |
169 | |
170 if [[ -z $fs ]]; then | |
171 log_fail "No filesystem specified." | |
172 fi | |
173 | |
174 typeset -i curv=$(get_prop version $fs) | |
175 if (( curv != version )); then | |
176 return 1 | |
177 fi | |
178 return 0 | |
179 } |