1#!/usr/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 by Delphix. All rights reserved.
16#
17
18. $STF_SUITE/tests/functional/pool_checkpoint/pool_checkpoint.kshlib
19
20#
21# DESCRIPTION:
22#	Attempt to take a checkpoint while a removal is
23#	in progress. The attempt should fail.
24#
25# STRATEGY:
26#	1. Create pool with one disk
27#	2. Create a big file in the pool, so when the disk
28#	   is later removed, it will give us enough of a
29#	   time window to attempt the checkpoint while the
30#	   removal takes place
31#	3. Add a second disk where all the data will be moved
32#	   to when the first disk will be removed.
33#	4. Start removal of first disk
34#	5. Attempt to checkpoint (attempt should fail)
35#
36
37verify_runnable "global"
38
39function callback
40{
41	log_mustnot zpool checkpoint $TESTPOOL
42	return 0
43}
44
45#
46# Create pool
47#
48setup_test_pool
49log_onexit cleanup_test_pool
50populate_test_pool
51
52#
53# Create big empty file and do some writes at random
54# offsets to ensure that it takes up space. Note that
55# the implcitly created filesystem ($FS0) does not
56# have compression enabled.
57#
58log_must mkfile $BIGFILESIZE $FS0FILE
59log_must randwritecomp $FS0FILE 1000
60
61#
62# Add second disk
63#
64log_must zpool add $TESTPOOL $EXTRATESTDISK
65
66#
67# Remove disk and attempt to take checkpoint
68#
69log_must attempt_during_removal $TESTPOOL $TESTDISK callback
70log_must zpool status $TESTPOOL
71
72log_pass "Attempting to checkpoint during removal fails as expected."
73