From owner-svn-src-all@freebsd.org Tue Feb 12 23:35:48 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C0A8914D73C2; Tue, 12 Feb 2019 23:35:47 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 64A3E897C0; Tue, 12 Feb 2019 23:35:47 +0000 (UTC) (envelope-from ngie@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 554451F057; Tue, 12 Feb 2019 23:35:47 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x1CNZlAa065321; Tue, 12 Feb 2019 23:35:47 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1CNZlff065320; Tue, 12 Feb 2019 23:35:47 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201902122335.x1CNZlff065320@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Enji Cooper Date: Tue, 12 Feb 2019 23:35:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r344067 - head/sbin/bectl/tests X-SVN-Group: head X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: head/sbin/bectl/tests X-SVN-Commit-Revision: 344067 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 64A3E897C0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.96)[-0.962,0]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Feb 2019 23:35:48 -0000 Author: ngie Date: Tue Feb 12 23:35:46 2019 New Revision: 344067 URL: https://svnweb.freebsd.org/changeset/base/344067 Log: Fix up concurrent test zpool setup and teardown Set up zpools with a more unique name, stash the zpool name away in a file pointed to by `$ZPOOL_NAME_FILE` (which is relative to a per-testcase generated temporary directory), then remove the file based on `$ZPOOL_NAME_FILE` in the cleanup routines. This is a more concurrency-safe solution and will allow the testcases to be safely executed in parallel. Reviewed by: kevans, jtl Approved by: jtl (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19024 Modified: head/sbin/bectl/tests/bectl_test.sh Modified: head/sbin/bectl/tests/bectl_test.sh ============================================================================== --- head/sbin/bectl/tests/bectl_test.sh Tue Feb 12 23:33:16 2019 (r344066) +++ head/sbin/bectl/tests/bectl_test.sh Tue Feb 12 23:35:46 2019 (r344067) @@ -26,6 +26,17 @@ # # $FreeBSD$ +ZPOOL_NAME_FILE=zpool_name +get_zpool_name() +{ + cat $ZPOOL_NAME_FILE +} +make_zpool_name() +{ + mktemp -u bectl_test_XXXXXX > $ZPOOL_NAME_FILE + get_zpool_name +} + # Establishes a bectl_create zpool that can be used for some light testing; contains # a 'default' BE and not much else. bectl_create_setup() @@ -34,6 +45,9 @@ bectl_create_setup() disk=$2 mnt=$3 + # Sanity check to make sure `make_zpool_name` succeeded + atf_check test -n "$zpool" + kldload -n -q zfs || atf_skip "ZFS module not loaded on the current system" atf_check mkdir -p ${mnt} atf_check truncate -s 1G ${disk} @@ -48,6 +62,9 @@ bectl_create_deep_setup() disk=$2 mnt=$3 + # Sanity check to make sure `make_zpool_name` succeeded + atf_check test -n "$zpool" + bectl_create_setup ${zpool} ${disk} ${mnt} atf_check mkdir -p ${root} atf_check -o ignore bectl -r ${zpool}/ROOT mount default ${root} @@ -60,8 +77,9 @@ bectl_create_deep_setup() bectl_cleanup() { zpool=$1 - - if zpool get health ${zpool} >/dev/null 2>&1; then + if [ -z "$zpool" ]; then + echo "Skipping cleanup; zpool not set up" + elif zpool get health ${zpool} >/dev/null 2>&1; then zpool destroy -f ${zpool} fi } @@ -76,7 +94,7 @@ bectl_create_head() bectl_create_body() { cwd=$(realpath .) - zpool=bectl_test + zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt @@ -89,8 +107,7 @@ bectl_create_body() } bectl_create_cleanup() { - - bectl_cleanup bectl_test + bectl_cleanup $(get_zpool_name) } atf_test_case bectl_destroy cleanup @@ -103,7 +120,7 @@ bectl_destroy_head() bectl_destroy_body() { cwd=$(realpath .) - zpool=bectl_test + zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt @@ -116,7 +133,7 @@ bectl_destroy_body() bectl_destroy_cleanup() { - bectl_cleanup bectl_test + bectl_cleanup $(get_zpool_name) } atf_test_case bectl_export_import cleanup @@ -129,7 +146,7 @@ bectl_export_import_head() bectl_export_import_body() { cwd=$(realpath .) - zpool=bectl_test + zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt @@ -144,7 +161,7 @@ bectl_export_import_body() bectl_export_import_cleanup() { - bectl_cleanup bectl_test + bectl_cleanup $(get_zpool_name) } atf_test_case bectl_list cleanup @@ -157,7 +174,7 @@ bectl_list_head() bectl_list_body() { cwd=$(realpath .) - zpool=bectl_test + zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt @@ -179,7 +196,7 @@ bectl_list_body() bectl_list_cleanup() { - bectl_cleanup bectl_test + bectl_cleanup $(get_zpool_name) } atf_test_case bectl_mount cleanup @@ -192,7 +209,7 @@ bectl_mount_head() bectl_mount_body() { cwd=$(realpath .) - zpool=bectl_test + zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt root=${mount}/root @@ -213,7 +230,7 @@ bectl_mount_body() bectl_mount_cleanup() { - bectl_cleanup bectl_test + bectl_cleanup $(get_zpool_name) } atf_test_case bectl_rename cleanup @@ -226,7 +243,7 @@ bectl_rename_head() bectl_rename_body() { cwd=$(realpath .) - zpool=bectl_test + zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt @@ -239,7 +256,7 @@ bectl_rename_body() bectl_rename_cleanup() { - bectl_cleanup bectl_test + bectl_cleanup $(get_zpool_name) } atf_test_case bectl_jail cleanup @@ -252,7 +269,7 @@ bectl_jail_head() bectl_jail_body() { cwd=$(realpath .) - zpool=bectl_test + zpool=$(make_zpool_name) disk=${cwd}/disk.img mount=${cwd}/mnt root=${mount}/root @@ -327,7 +344,7 @@ bectl_jail_cleanup() jail -r ${jailid} done; - bectl_cleanup bectl_test + bectl_cleanup $(get_zpool_name) } atf_init_test_cases()