1#!/bin/ksh -p
2
3#
4# This file and its contents are supplied under the terms of the
5# Common Development and Distribution License ("CDDL"), version 1.0.
6# You may only use this file in accordance with the terms of version
7# 1.0 of the CDDL.
8#
9# A full copy of the text of the CDDL should have accompanied this
10# source.  A copy of the CDDL is also available via the Internet at
11# http://www.illumos.org/license/CDDL.
12#
13
14#
15# Copyright (c) 2017, Intel Corporation.
16# Copyright (c) 2018 by Delphix. All rights reserved.
17#
18
19. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
20
21#
22# DESCRIPTION:
23#	Checking allocation_classes feature flag value after pool is created
24#	(should be enabled) and also after a special device added to existing
25#	pool (should be active).
26#
27
28verify_runnable "global"
29
30log_assert "Values of allocation_classes feature flag correct."
31log_onexit cleanup
32
33log_must disk_setup
34
35typeset ac_value
36
37for type in "" "mirror" "raidz"
38do
39	if [ "$type" = "mirror" ]; then
40		log_must zpool create $TESTPOOL $type $ZPOOL_DISK0 $ZPOOL_DISK1
41	else
42		log_must zpool create $TESTPOOL $type $ZPOOL_DISKS
43	fi
44	ac_value="$(zpool get -H -o property,value all | \
45	    awk '/allocation_classes/ {print $2}')"
46	if [ "$ac_value" = "enabled" ]; then
47		log_note "feature@allocation_classes is enabled"
48	else
49		log_fail "feature@allocation_classes not enabled, \
50		    status = $ac_value"
51	fi
52
53	if [ "$type" = "" ]; then
54		log_must zpool add $TESTPOOL special $CLASS_DISK0
55	else
56		log_must zpool add $TESTPOOL special mirror \
57		    $CLASS_DISK0 $CLASS_DISK1
58	fi
59	ac_value="$(zpool get -H -o property,value all | \
60	    awk '/allocation_classes/ {print $2}')"
61	if [ "$ac_value" = "active" ]; then
62		log_note "feature@allocation_classes is active"
63	else
64		log_fail "feature@allocation_classes not active, \
65		    status = $ac_value"
66	fi
67
68	log_must zpool destroy -f $TESTPOOL
69done
70
71log_pass "Values of allocation_classes feature flag correct."
72