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# Copyright 2019 Joyent, Inc.
18#
19
20. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
21
22#
23# DESCRIPTION:
24#	Checking allocation_classes feature flag value after pool is created
25#	(should be enabled) and also after a special device added to existing
26#	pool (should be active).
27#
28
29verify_runnable "global"
30
31log_assert "Values of allocation_classes feature flag correct."
32log_onexit cleanup
33
34log_must disk_setup
35
36typeset ac_value
37
38for type in "" "mirror" "raidz"
39do
40	if [ "$type" = "mirror" ]; then
41		log_must zpool create $TESTPOOL $type $ZPOOL_DISK0 $ZPOOL_DISK1
42	else
43		log_must zpool create $TESTPOOL $type $ZPOOL_DISKS
44	fi
45	ac_value="$(zpool get all $TESTPOOL | \
46	    nawk '{if ($2 == "feature@allocation_classes") print $3}')"
47	if [ "$ac_value" = "enabled" ]; then
48		log_note "feature@allocation_classes is enabled"
49	else
50		log_fail "feature@allocation_classes not enabled, \
51		    status = $ac_value"
52	fi
53
54	if [ "$type" = "" ]; then
55		log_must zpool add $TESTPOOL special $CLASS_DISK0
56	else
57		log_must zpool add $TESTPOOL special mirror \
58		    $CLASS_DISK0 $CLASS_DISK1
59	fi
60	ac_value="$(zpool get all $TESTPOOL | \
61	    nawk '{if ($2 == "feature@allocation_classes") print $3}')"
62	if [ "$ac_value" = "active" ]; then
63		log_note "feature@allocation_classes is active"
64	else
65		log_fail "feature@allocation_classes not active, \
66		    status = $ac_value"
67	fi
68
69	log_must zpool destroy -f $TESTPOOL
70done
71
72log_pass "Values of allocation_classes feature flag correct."
73