From owner-svn-src-projects@freebsd.org Fri Sep 22 22:19:58 2017 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 32A3DE12144 for ; Fri, 22 Sep 2017 22:19:58 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 01F80811D7; Fri, 22 Sep 2017 22:19:57 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8MMJvFX081851; Fri, 22 Sep 2017 22:19:57 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8MMJvbn081850; Fri, 22 Sep 2017 22:19:57 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201709222219.v8MMJvbn081850@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 22 Sep 2017 22:19:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r323940 - projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy X-SVN-Commit-Revision: 323940 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Sep 2017 22:19:58 -0000 Author: asomers Date: Fri Sep 22 22:19:56 2017 New Revision: 323940 URL: https://svnweb.freebsd.org/changeset/base/323940 Log: Simplify zpool_destroy_004_pos.ksh Formerly, this test went through tortuous manchinations to determine if the zfs send and/or receive were interrupted by the zpool destroy. Due to the race conditions and peculiarities of KSH wait, these efforts were mostly bogus. The only true test of success is that the pool was destroyed. Sponsored by: Spectra Logic Corp Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_004_pos.ksh Modified: projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_004_pos.ksh ============================================================================== --- projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_004_pos.ksh Fri Sep 22 22:12:45 2017 (r323939) +++ projects/zfsd/head/tests/sys/cddl/zfs/tests/cli_root/zpool_destroy/zpool_destroy_004_pos.ksh Fri Sep 22 22:19:56 2017 (r323940) @@ -56,37 +56,6 @@ function create_sender_and_receiver create_pool "$TESTPOOL1" "$DISK1" } -function check_recv_status -{ - rcv_pid="$1" - rcv_status="$2" - destroyed="$3" - - if ((rcv_status != 0)) - then - log_note \ - "zfs receive interrupted by destruction of $destroyed as expected" - return 0 - fi - - log_note "zfs receive NOT interrupted by destruction of $destroyed" - case $destroyed - in - SAME_POOL|RECEIVER) - log_fail "expected zfs receive failure did not occur" - ;; - - SENDER) - log_note "zfs send completed before destruction of $destroyed" - ;; - - *) - log_fail "unknown parameter $destroyed" - ;; - esac - return 0 -} - function send_recv_destroy { sleeptime=$1 @@ -94,39 +63,45 @@ function send_recv_destroy to_destroy=$3 who_to_destroy="$4" - # The pid of this send/receive pipeline is that of zfs receive. - # We can not get the exit status of the zfs send. We can, however, - # infer the status of the send; see note below. + # The pid of this pipe line is that of zfs receive # ( $ZFS send -RP $TESTPOOL/$TESTFS@snap1 | $ZFS receive -Fu $recv/d1 ) & - recvpid=$! sndrcv_start=$(date '+%s') + rcvpid=$! + sndpid=$(pgrep -P $rcvpid) log_must sleep $sleeptime + log_note "post sleep: $(ps -p ${sndpid},${rcvpid} -o command)" + destroy_start=$(date '+%s') log_must $ZPOOL destroy -f $to_destroy destroy_end=$(date '+%s') dtime=$((destroy_end - destroy_start)) log_note "Destroy of $who_to_destroy took ${dtime} seconds." - # NOTE: - # If the we have destroyed the send pool then the send/receive may - # succeed. - # 1.) If the destruction of the send pool interrupts the zfs - # send then this error will be detected by the receiver; - # the entire operation will fail. + log_note "post destroy: $(ps -p ${sndpid},${rcvpid} -o command)" + + # Wait for send and recv to exit. # - # 2.) If the send completes before the destruction of the send - # pool then the receive will succeed. - # - wait $recvpid - rc=$? + wait $sndpid + snderr=$? + wait $rcvpid + rcverr=$? wait_end=$(date '+%s') - log_note "$recvpid rc = $rc for destruction of $who_to_destroy" - check_recv_status $recvpid $rc $who_to_destroy - wtime=$((wait_end - sndrcv_start)) log_note "send|receive took ${wtime} seconds to finish." + + # KSH: "wait pid" exit status of 127 means that process never existed + # or already completed; ksh's wait only returns the status of the + # child process if the child was running when the wait was issued. + # Therefore, we can not imply much about the interruption of the + # send | recv by zpool destroy -f + # + # The real test of success is simply that the pool was destroyed. + # + log_note \ + "Destruction of ${who_to_destroy}: send ${snderr}, recv ${rcverr}" + log_mustnot $ZPOOL list $to_destroy }