From nobody Tue Nov 03 12:17:31 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jJndR5Tr9z6y3LN for ; Tue, 03 Nov 2026 12:17:31 +0000 (UTC) (envelope-from git@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) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jJndR3sn8z4rsQ for ; Tue, 03 Nov 2026 12:17:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793708251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dUAGuL8ccSInYfdWSDHjDDMI7cnhe7M24MNfGS5UJXk=; b=pxVjBFPk9PtO8TC/OKKZHQSfm4YPTcUOr2XZcw85R9qqvQqSXcIUNu9JhF5BAFJkQkPch1 EVqVmXu/S3AgPmmjfw9KJ+aj+jtRTXlzjfnOofqNCdOiPjNpEkNZmQqwCHHHmmarbPRKTr vXFUJu0mcsvYiZVsIhPsEuS9elM/sBI3E0MU7FZVNVq5tBl8Kg+Yh7vFS0JzuTyBbUBZk5 JItlZBZn+79lnrFz316D3RE349s2uWj9r3on70rD3udb/ulbukE42HdVjajtJ/54q5go/e ysXsepaq9lIbXjwW1M4+ZL/AkE7GFNV5IGzPjJ6SLPSe6HoO9nh6f9Tg9boQ9g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793708251; b=xElC/1bmuoDe0bpKRLS8zqHtEXM283ry4joR8+Li17uk4Gc68wTZeHx6TFiL21L/CtznrU 4UMUbkEnxpqKtRT0FBpdSsYwnKfeEY4i1M/jeJ2OS+wBQFqNj+pPfMwwsS/PJyIfz2IY6Q Q5oIIX29JYhrbWt2M0gkr6q7ux5Mk8MabETxJi3ma1JvKsgQrMt6Mk+vDJIPqNtyStgdKD hIgEEvG91N4liZfD/O19Kn0mfSmByEyvNd4tKTi2vOMF3P/hfNiloCxhWZYL+9sxUgAtx1 t1neWg1lWgH6A0qYK13tNt016yID6ec6obEXkLo9VpYR2vc/ORff8OnbLTXSYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793708251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dUAGuL8ccSInYfdWSDHjDDMI7cnhe7M24MNfGS5UJXk=; b=K0zwKQs0gcQ5qdsQPmx8AmbvGdYd323WfY/W/U8EkvElW/0DPYFiIsh0a19Ps7kuP9/Mrn LK5kWh809bq4e3zeb8ZM6NLZa55382MXUdoweHNvNnFhKUvCY6nOeguzmjGJlyRo35KL/y 0ZsRGi4SmcPvTQJPLNP5ATibLa1hiJidxmfhGOGV4R1QPKpfDwjK/MXJx88aPFp9w6qshs LcadUQlalW6Ga8bPsKQpyjJ9RNAyPcYk+NJsSE3VzVqLpeAZdCNhmWosoy8bSnXbvPNrBK 6abiiZIxI2kOgmp1zSb4m0NtFfSxj1HCIEwwfvotkYkfcHrBp/J9iTWVt9Tlig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jJndR3RMhzG76 for ; Tue, 03 Nov 2026 12:17:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 30936 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 03 Nov 2026 12:17:31 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 2321b3df1f0d - main - hastd: Add full lifecycle test List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2321b3df1f0db4f839cb9dde7c0a9a0060d4bcfe Auto-Submitted: auto-generated Date: Tue, 03 Nov 2026 12:17:31 +0000 Message-Id: <6ae9d0db.30936.7d0d7c10@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=2321b3df1f0db4f839cb9dde7c0a9a0060d4bcfe commit 2321b3df1f0db4f839cb9dde7c0a9a0060d4bcfe Author: Dag-Erling Smørgrav AuthorDate: 2026-11-03 12:07:35 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-03 12:07:35 +0000 hastd: Add full lifecycle test Add a test case that creates and starts two nodes, has one assume the primary role and the other the secondary role, writes to the device, verifies that the data is synced to both nodes, then switches the roles, and finally shuts both nodes down and compares their backing stores. Differential Revision: https://reviews.freebsd.org/D59676 --- sbin/hastd/tests/hastd_test.sh | 134 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/sbin/hastd/tests/hastd_test.sh b/sbin/hastd/tests/hastd_test.sh index 065626f22bc6..572c7b4712c1 100644 --- a/sbin/hastd/tests/hastd_test.sh +++ b/sbin/hastd/tests/hastd_test.sh @@ -9,6 +9,7 @@ ctl_head() { atf_set descr "Test that hastd can start, stop, and "\ "communicate with hastctl" + atf_set require.progs "hastctl hastd" atf_set require.user "root" } ctl_body() @@ -21,7 +22,7 @@ EOF atf_check hastd -c $PWD/hast.conf atf_check -o ignore hastctl status -c $PWD/hast.conf atf_check -o ignore hastctl stop -c $PWD/hast.conf - rm -f hastd.pid + atf_check lockf -st10 hastd.pid true } ctl_cleanup() { @@ -30,7 +31,138 @@ ctl_cleanup() fi } +hast_status() +{ + hastctl status "$@" | tail -1 | cut -w -f 2,3 +} + +atf_test_case pair cleanup +pair_head() +{ + atf_set descr "Test typical lifecycle or a pair " + atf_set require.progs "hastctl hastd nc" + atf_set require.user "root" + atf_set timeout "60" +} +pair_body() +{ + local pair=p$$ + if nc -z 127.0.0.1 8451 || nc -z 127.0.0.1 8452; then + atf_skip "TCP ports 8451 and 8452 must be free" + fi + if [ -c /dev/hast/$pair ]; then + atf_skip "A hast device named '$pair' already exists" + fi + + # Shared configuration + cat >hast.conf <>one/hast.conf <one/status + atf_check grep -qw init one/status + + # Create and start node two + atf_check mkdir -p two + atf_check cp hast.conf two/hast.conf + cat >>two/hast.conf <two/status + atf_check grep -qw init two/status + + # Switch node one to primary + atf_check hastctl role -c one/hast.conf -n one primary $pair + :>one/status + while ! grep -q $'degraded\tprimary' one/status; do + sleep 1 + hast_status -c one/hast.conf -n one $pair >one/status + done + + # Switch node two to secondary + atf_check hastctl role -c two/hast.conf -n two secondary $pair + :>two/status + while ! grep -q $'complete\tsecondary' two/status; do + sleep 1 + hast_status -c two/hast.conf -n two $pair >two/status + done + + # Write some data to the device + atf_check test -c /dev/hast/$pair + echo "The Magic Words are Squeamish Ossifrage" >d1 + cat d1 d1 d1 d1 >d4 + cat d4 d4 d4 d4 >d16 + # d16 is now more than 512 bytes + atf_check dd if=d16 of=/dev/hast/$pair bs=512 count=1 status=none + + # Wait for the data to sync to both nodes + while ! grep -aq "Squeamish Ossifrage" one/file; do + sleep 1 + done + while ! grep -aq "Squeamish Ossifrage" two/file; do + sleep 1 + done + + # Now switch roles and check + atf_check hastctl role -c one/hast.conf -n one secondary $pair + atf_check hastctl role -c two/hast.conf -n two primary $pair + :>two/status + while ! grep -q $'complete\tprimary' two/status; do + sleep 1 + hast_status -c two/hast.conf -n two $pair >two/status + done + + # Finally, shut both nodes down + atf_check hastctl role -c one/hast.conf -n one init $pair + atf_check hastctl stop -c one/hast.conf -n one + atf_check lockf -st10 one/hastd.pid true + atf_check hastctl role -c two/hast.conf -n two init $pair + atf_check hastctl stop -c two/hast.conf -n two + atf_check lockf -st10 two/hastd.pid true + + # Just for kicks, compare the files; they should be identical + # (but only because we switched both nodes to init before + # stopping them, as the last known state of the node is stored + # in the hastd metadata at the beginning of the file) + atf_check cmp one/file two/file +} +pair_cleanup() +{ + if [ -s one/hastd.pid ]; then + kill -9 "$(cat one/hastd.pid)" || true + fi + if [ -s two/hastd.pid ]; then + kill -9 "$(cat two/hastd.pid)" || true + fi +} + atf_init_test_cases() { atf_add_test_case ctl + atf_add_test_case pair }