1*094e47e9SGeorge Wilson#!/bin/ksh -p
2*094e47e9SGeorge Wilson#
3*094e47e9SGeorge Wilson# CDDL HEADER START
4*094e47e9SGeorge Wilson#
5*094e47e9SGeorge Wilson# The contents of this file are subject to the terms of the
6*094e47e9SGeorge Wilson# Common Development and Distribution License (the "License").
7*094e47e9SGeorge Wilson# You may not use this file except in compliance with the License.
8*094e47e9SGeorge Wilson#
9*094e47e9SGeorge Wilson# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*094e47e9SGeorge Wilson# or http://www.opensolaris.org/os/licensing.
11*094e47e9SGeorge Wilson# See the License for the specific language governing permissions
12*094e47e9SGeorge Wilson# and limitations under the License.
13*094e47e9SGeorge Wilson#
14*094e47e9SGeorge Wilson# When distributing Covered Code, include this CDDL HEADER in each
15*094e47e9SGeorge Wilson# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*094e47e9SGeorge Wilson# If applicable, add the following below this CDDL HEADER, with the
17*094e47e9SGeorge Wilson# fields enclosed by brackets "[]" replaced with your own identifying
18*094e47e9SGeorge Wilson# information: Portions Copyright [yyyy] [name of copyright owner]
19*094e47e9SGeorge Wilson#
20*094e47e9SGeorge Wilson# CDDL HEADER END
21*094e47e9SGeorge Wilson#
22*094e47e9SGeorge Wilson
23*094e47e9SGeorge Wilson#
24*094e47e9SGeorge Wilson# Copyright (c) 2016 by Delphix. All rights reserved.
25*094e47e9SGeorge Wilson#
26*094e47e9SGeorge Wilson. $STF_SUITE/include/libtest.shlib
27*094e47e9SGeorge Wilson. $STF_SUITE/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib
28*094e47e9SGeorge Wilson
29*094e47e9SGeorge Wilson#
30*094e47e9SGeorge Wilson# DESCRIPTION:
31*094e47e9SGeorge Wilson# Initializing does not cause file corruption.
32*094e47e9SGeorge Wilson#
33*094e47e9SGeorge Wilson# STRATEGY:
34*094e47e9SGeorge Wilson# 1. Create a one-disk pool.
35*094e47e9SGeorge Wilson# 2. Write data to the pool.
36*094e47e9SGeorge Wilson# 3. Start initializing and verify that initializing is active.
37*094e47e9SGeorge Wilson# 4. Write more data to the pool.
38*094e47e9SGeorge Wilson# 5. Run zdb to validate checksums.
39*094e47e9SGeorge Wilson#
40*094e47e9SGeorge Wilson
41*094e47e9SGeorge WilsonDISK1=${DISKS%% *}
42*094e47e9SGeorge Wilson
43*094e47e9SGeorge Wilsonlog_must zpool create -f $TESTPOOL $DISK1
44*094e47e9SGeorge Wilsonlog_must /usr/bin/dd if=/dev/urandom of=/$TESTPOOL/file1 bs=1M count=30
45*094e47e9SGeorge Wilsonlog_must sync
46*094e47e9SGeorge Wilson
47*094e47e9SGeorge Wilsonlog_must zpool initialize $TESTPOOL
48*094e47e9SGeorge Wilson
49*094e47e9SGeorge Wilsonlog_must zdb -cc $TESTPOOL
50*094e47e9SGeorge Wilson
51*094e47e9SGeorge Wilson[[ -z "$(initialize_progress $TESTPOOL $DISK1)" ]] && \
52*094e47e9SGeorge Wilson    log_fail "Initializing did not start"
53*094e47e9SGeorge Wilson
54*094e47e9SGeorge Wilsonlog_must /usr/bin/dd if=/dev/urandom of=/$TESTPOOL/file2 bs=1M count=30
55*094e47e9SGeorge Wilsonlog_must sync
56*094e47e9SGeorge Wilson
57*094e47e9SGeorge Wilsonlog_must zdb -cc $TESTPOOL
58*094e47e9SGeorge Wilson
59*094e47e9SGeorge Wilsonlog_pass "Initializing does not corrupt existing or new data"
60