12fae26bdSAlan Somers# CDDL HEADER START
22fae26bdSAlan Somers#
32fae26bdSAlan Somers# The contents of this file are subject to the terms of the
42fae26bdSAlan Somers# Common Development and Distribution License (the "License").
52fae26bdSAlan Somers# You may not use this file except in compliance with the License.
62fae26bdSAlan Somers#
72fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
82fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing.
92fae26bdSAlan Somers# See the License for the specific language governing permissions
102fae26bdSAlan Somers# and limitations under the License.
112fae26bdSAlan Somers#
122fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each
132fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
142fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the
152fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying
162fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner]
172fae26bdSAlan Somers#
182fae26bdSAlan Somers# CDDL HEADER END
192fae26bdSAlan Somers#
202fae26bdSAlan Somers
212fae26bdSAlan Somers#
222fae26bdSAlan Somers# Copyright 2012 Spectra Logic.  All rights reserved.
232fae26bdSAlan Somers# Use is subject to license terms.
242fae26bdSAlan Somers#
252fae26bdSAlan Somers
262fae26bdSAlan Somers
272fae26bdSAlan Somersatf_test_case cache_001_pos cleanup
282fae26bdSAlan Somerscache_001_pos_head()
292fae26bdSAlan Somers{
302fae26bdSAlan Somers	atf_set "descr" "Creating a pool with a cache device succeeds."
310b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
322fae26bdSAlan Somers	atf_set "timeout" 1200
332fae26bdSAlan Somers}
342fae26bdSAlan Somerscache_001_pos_body()
352fae26bdSAlan Somers{
362fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
372fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
382fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
392fae26bdSAlan Somers
402fae26bdSAlan Somers	verify_disk_count "$DISKS" 1
412fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
422fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_001_pos.ksh || atf_fail "Testcase failed"
432fae26bdSAlan Somers}
442fae26bdSAlan Somerscache_001_pos_cleanup()
452fae26bdSAlan Somers{
462fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
472fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
482fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
492fae26bdSAlan Somers
502fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
512fae26bdSAlan Somers}
522fae26bdSAlan Somers
532fae26bdSAlan Somers
542fae26bdSAlan Somersatf_test_case cache_002_pos cleanup
552fae26bdSAlan Somerscache_002_pos_head()
562fae26bdSAlan Somers{
572fae26bdSAlan Somers	atf_set "descr" "Adding a cache device to normal pool works."
580b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
592fae26bdSAlan Somers	atf_set "timeout" 1200
602fae26bdSAlan Somers}
612fae26bdSAlan Somerscache_002_pos_body()
622fae26bdSAlan Somers{
632fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
642fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
652fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
662fae26bdSAlan Somers
672fae26bdSAlan Somers	verify_disk_count "$DISKS" 1
682fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
692fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_002_pos.ksh || atf_fail "Testcase failed"
702fae26bdSAlan Somers}
712fae26bdSAlan Somerscache_002_pos_cleanup()
722fae26bdSAlan Somers{
732fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
742fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
752fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
762fae26bdSAlan Somers
772fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
782fae26bdSAlan Somers}
792fae26bdSAlan Somers
802fae26bdSAlan Somers
812fae26bdSAlan Somersatf_test_case cache_003_pos cleanup
822fae26bdSAlan Somerscache_003_pos_head()
832fae26bdSAlan Somers{
842fae26bdSAlan Somers	atf_set "descr" "Adding an extra cache device works."
850b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
862fae26bdSAlan Somers	atf_set "timeout" 1200
872fae26bdSAlan Somers}
882fae26bdSAlan Somerscache_003_pos_body()
892fae26bdSAlan Somers{
902fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
912fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
922fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
932fae26bdSAlan Somers
942fae26bdSAlan Somers	verify_disk_count "$DISKS" 2
952fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
962fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_003_pos.ksh || atf_fail "Testcase failed"
972fae26bdSAlan Somers}
982fae26bdSAlan Somerscache_003_pos_cleanup()
992fae26bdSAlan Somers{
1002fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
1012fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
1022fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
1032fae26bdSAlan Somers
1042fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
1052fae26bdSAlan Somers}
1062fae26bdSAlan Somers
1072fae26bdSAlan Somers
1082fae26bdSAlan Somersatf_test_case cache_004_neg cleanup
1092fae26bdSAlan Somerscache_004_neg_head()
1102fae26bdSAlan Somers{
1112fae26bdSAlan Somers	atf_set "descr" "Attaching a cache device fails."
1120b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
1132fae26bdSAlan Somers	atf_set "timeout" 1200
1142fae26bdSAlan Somers}
1152fae26bdSAlan Somerscache_004_neg_body()
1162fae26bdSAlan Somers{
1172fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
1182fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
1192fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
1202fae26bdSAlan Somers
1212fae26bdSAlan Somers	verify_disk_count "$DISKS" 2
1222fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
1232fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_004_neg.ksh || atf_fail "Testcase failed"
1242fae26bdSAlan Somers}
1252fae26bdSAlan Somerscache_004_neg_cleanup()
1262fae26bdSAlan Somers{
1272fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
1282fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
1292fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
1302fae26bdSAlan Somers
1312fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
1322fae26bdSAlan Somers}
1332fae26bdSAlan Somers
1342fae26bdSAlan Somers
1352fae26bdSAlan Somersatf_test_case cache_005_neg cleanup
1362fae26bdSAlan Somerscache_005_neg_head()
1372fae26bdSAlan Somers{
1382fae26bdSAlan Somers	atf_set "descr" "Replacing a cache device fails."
1390b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
1402fae26bdSAlan Somers	atf_set "timeout" 1200
1412fae26bdSAlan Somers}
1422fae26bdSAlan Somerscache_005_neg_body()
1432fae26bdSAlan Somers{
1442fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
1452fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
1462fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
1472fae26bdSAlan Somers
1482fae26bdSAlan Somers	verify_disk_count "$DISKS" 2
1492fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
1502fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_005_neg.ksh || atf_fail "Testcase failed"
1512fae26bdSAlan Somers}
1522fae26bdSAlan Somerscache_005_neg_cleanup()
1532fae26bdSAlan Somers{
1542fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
1552fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
1562fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
1572fae26bdSAlan Somers
1582fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
1592fae26bdSAlan Somers}
1602fae26bdSAlan Somers
1612fae26bdSAlan Somers
1622fae26bdSAlan Somersatf_test_case cache_006_pos cleanup
1632fae26bdSAlan Somerscache_006_pos_head()
1642fae26bdSAlan Somers{
1652fae26bdSAlan Somers	atf_set "descr" "Exporting and importing pool with cache devices passes."
1660b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
1672fae26bdSAlan Somers	atf_set "timeout" 1200
1682fae26bdSAlan Somers}
1692fae26bdSAlan Somerscache_006_pos_body()
1702fae26bdSAlan Somers{
1712fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
1722fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
1732fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
1742fae26bdSAlan Somers
1752fae26bdSAlan Somers	verify_disk_count "$DISKS" 2
1762fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
1772fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_006_pos.ksh || atf_fail "Testcase failed"
1782fae26bdSAlan Somers}
1792fae26bdSAlan Somerscache_006_pos_cleanup()
1802fae26bdSAlan Somers{
1812fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
1822fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
1832fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
1842fae26bdSAlan Somers
1852fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
1862fae26bdSAlan Somers}
1872fae26bdSAlan Somers
1882fae26bdSAlan Somers
1892fae26bdSAlan Somersatf_test_case cache_007_neg cleanup
1902fae26bdSAlan Somerscache_007_neg_head()
1912fae26bdSAlan Somers{
1922fae26bdSAlan Somers	atf_set "descr" "A mirror/raidz/raidz2 cache is not supported."
1930b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
1942fae26bdSAlan Somers	atf_set "timeout" 1200
1952fae26bdSAlan Somers}
1962fae26bdSAlan Somerscache_007_neg_body()
1972fae26bdSAlan Somers{
1982fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
1992fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
2002fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
2012fae26bdSAlan Somers
2022fae26bdSAlan Somers	verify_disk_count "$DISKS" 2
2032fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
2042fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_007_neg.ksh || atf_fail "Testcase failed"
2052fae26bdSAlan Somers}
2062fae26bdSAlan Somerscache_007_neg_cleanup()
2072fae26bdSAlan Somers{
2082fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
2092fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
2102fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
2112fae26bdSAlan Somers
2122fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
2132fae26bdSAlan Somers}
2142fae26bdSAlan Somers
2152fae26bdSAlan Somers
2162fae26bdSAlan Somersatf_test_case cache_008_neg cleanup
2172fae26bdSAlan Somerscache_008_neg_head()
2182fae26bdSAlan Somers{
2192fae26bdSAlan Somers	atf_set "descr" "A raidz/raidz2 cache can not be added to existed pool."
2200b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
2212fae26bdSAlan Somers	atf_set "timeout" 1200
2222fae26bdSAlan Somers}
2232fae26bdSAlan Somerscache_008_neg_body()
2242fae26bdSAlan Somers{
2252fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
2262fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
2272fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
2282fae26bdSAlan Somers
2292fae26bdSAlan Somers	verify_disk_count "$DISKS" 2
2302fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
2312fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_008_neg.ksh || atf_fail "Testcase failed"
2322fae26bdSAlan Somers}
2332fae26bdSAlan Somerscache_008_neg_cleanup()
2342fae26bdSAlan Somers{
2352fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
2362fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
2372fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
2382fae26bdSAlan Somers
2392fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
2402fae26bdSAlan Somers}
2412fae26bdSAlan Somers
2422fae26bdSAlan Somers
2432fae26bdSAlan Somersatf_test_case cache_009_pos cleanup
2442fae26bdSAlan Somerscache_009_pos_head()
2452fae26bdSAlan Somers{
2462fae26bdSAlan Somers	atf_set "descr" "Offline and online a cache device succeed."
2470b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
2482fae26bdSAlan Somers	atf_set "timeout" 1200
2492fae26bdSAlan Somers}
2502fae26bdSAlan Somerscache_009_pos_body()
2512fae26bdSAlan Somers{
2522fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
2532fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
2542fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
2552fae26bdSAlan Somers
2562fae26bdSAlan Somers	verify_disk_count "$DISKS" 2
2572fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
2582fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_009_pos.ksh || atf_fail "Testcase failed"
2592fae26bdSAlan Somers}
2602fae26bdSAlan Somerscache_009_pos_cleanup()
2612fae26bdSAlan Somers{
2622fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
2632fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
2642fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
2652fae26bdSAlan Somers
2662fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
2672fae26bdSAlan Somers}
2682fae26bdSAlan Somers
2692fae26bdSAlan Somers
2702fae26bdSAlan Somersatf_test_case cache_010_neg cleanup
2712fae26bdSAlan Somerscache_010_neg_head()
2722fae26bdSAlan Somers{
2732fae26bdSAlan Somers	atf_set "descr" "Cache device can only be disk or slice."
2740b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zfs zpool"
2752fae26bdSAlan Somers	atf_set "timeout" 1200
2762fae26bdSAlan Somers}
2772fae26bdSAlan Somerscache_010_neg_body()
2782fae26bdSAlan Somers{
2792fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
2802fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
2812fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
2822fae26bdSAlan Somers
283ea823622SWarner Losh	[ -c /dev/mdctl ] || atf_skip "no /dev/mdctl to create md devices"
2842fae26bdSAlan Somers	verify_disk_count "$DISKS" 1
2852fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
2862fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_010_neg.ksh || atf_fail "Testcase failed"
2872fae26bdSAlan Somers}
2882fae26bdSAlan Somerscache_010_neg_cleanup()
2892fae26bdSAlan Somers{
2902fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
2912fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
2922fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
2932fae26bdSAlan Somers
2942fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
2952fae26bdSAlan Somers}
2962fae26bdSAlan Somers
2972fae26bdSAlan Somers
2982fae26bdSAlan Somersatf_test_case cache_011_pos cleanup
2992fae26bdSAlan Somerscache_011_pos_head()
3002fae26bdSAlan Somers{
3012fae26bdSAlan Somers	atf_set "descr" "Remove cache device from pool with spare device should succeed"
3020b86424cSAlex Richardson	atf_set "require.progs" "ksh93 zpool"
3032fae26bdSAlan Somers	atf_set "timeout" 1200
3042fae26bdSAlan Somers}
3052fae26bdSAlan Somerscache_011_pos_body()
3062fae26bdSAlan Somers{
3072fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
3082fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
3092fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
3102fae26bdSAlan Somers
3112fae26bdSAlan Somers	verify_disk_count "$DISKS" 2
3122fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/setup.ksh || atf_fail "Setup failed"
3132fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cache_011_pos.ksh || atf_fail "Testcase failed"
3142fae26bdSAlan Somers}
3152fae26bdSAlan Somerscache_011_pos_cleanup()
3162fae26bdSAlan Somers{
3172fae26bdSAlan Somers	. $(atf_get_srcdir)/../../include/default.cfg
3182fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.kshlib
3192fae26bdSAlan Somers	. $(atf_get_srcdir)/cache.cfg
3202fae26bdSAlan Somers
3212fae26bdSAlan Somers	ksh93 $(atf_get_srcdir)/cleanup.ksh || atf_fail "Cleanup failed"
3222fae26bdSAlan Somers}
3232fae26bdSAlan Somers
3242fae26bdSAlan Somers
3252fae26bdSAlan Somersatf_init_test_cases()
3262fae26bdSAlan Somers{
3272fae26bdSAlan Somers
3282fae26bdSAlan Somers	atf_add_test_case cache_001_pos
3292fae26bdSAlan Somers	atf_add_test_case cache_002_pos
3302fae26bdSAlan Somers	atf_add_test_case cache_003_pos
3312fae26bdSAlan Somers	atf_add_test_case cache_004_neg
3322fae26bdSAlan Somers	atf_add_test_case cache_005_neg
3332fae26bdSAlan Somers	atf_add_test_case cache_006_pos
3342fae26bdSAlan Somers	atf_add_test_case cache_007_neg
3352fae26bdSAlan Somers	atf_add_test_case cache_008_neg
3362fae26bdSAlan Somers	atf_add_test_case cache_009_pos
3372fae26bdSAlan Somers	atf_add_test_case cache_010_neg
3382fae26bdSAlan Somers	atf_add_test_case cache_011_pos
3392fae26bdSAlan Somers}
340