From ffd0e4d4f3d2686316bb877dc5b8df377f4a064b Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Thu, 23 Jul 2026 09:25:05 +0200 Subject: [PATCH] Use recoverable target in STQ-04 fixture --- contrib/testing/queue-failure-safety-check.sh | 9 ++++++++- man/bongo-queuetool.1 | 9 +++++---- src/apps/queuetool/bongo-queuetool | 11 +++++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/contrib/testing/queue-failure-safety-check.sh b/contrib/testing/queue-failure-safety-check.sh index 6b3651a..9b3a8ce 100755 --- a/contrib/testing/queue-failure-safety-check.sh +++ b/contrib/testing/queue-failure-safety-check.sh @@ -28,10 +28,15 @@ queue_id= tmpfs_mounted=0 spool_mounted=0 blocked_mounted=0 +fill_open=0 restore() { status=$? + if [ "$fill_open" -eq 1 ]; then + exec 9>&- + fill_open=0 + fi $as_root /usr/bin/systemctl stop "$service" >/dev/null 2>&1 || true if [ "$blocked_mounted" -eq 1 ]; then $as_root /usr/bin/umount "$spool" >/dev/null 2>&1 || true @@ -82,7 +87,7 @@ printf '%s\r\n' \ >"$work/message.eml" chmod 0644 "$work/message.eml" -queue_id=$($as_bongo "$queue_tool" hold-local "$work/message.eml") +queue_id=$($as_bongo "$queue_tool" hold-local "$work/message.eml" 9) $as_bongo "$queue_tool" message "$queue_id" >"$work/before.eml" before_hash=$(sha256sum "$work/before.eml" | awk '{ print $1 }') @@ -91,6 +96,7 @@ reported_before=$4 block=$5 fill_blocks=$((reported_before / block + 1)) exec 9>"$tmpfs/.stq04-fill" +fill_open=1 rm "$tmpfs/.stq04-fill" /usr/bin/dd if=/dev/zero bs="$block" count="$fill_blocks" status=none >&9 $as_root /usr/bin/systemctl restart "$service" @@ -113,6 +119,7 @@ if ! grep -F 'Free disk space too low' "$work/full.err" >/dev/null; then fi $as_bongo "$queue_tool" message "$queue_id" >"$work/after-full.eml" exec 9>&- +fill_open=0 $as_root /usr/bin/systemctl stop "$service" $as_root /usr/bin/mount --bind "$blocked" "$spool" diff --git a/man/bongo-queuetool.1 b/man/bongo-queuetool.1 index 5425dc9..7622cab 100644 --- a/man/bongo-queuetool.1 +++ b/man/bongo-queuetool.1 @@ -46,10 +46,11 @@ Write the exact queued message bytes to standard output. Permanently remove one queue entry and its message data. .SH "QUEUE RECOVERY AND DIAGNOSTIC COMMANDS" .TP -.BI "hold-local " MESSAGE-FILE -Create a queue entry in the isolated diagnostic target 999 and print its -queue ID. The message remains held until it is explicitly delivered or -deleted. +.BI "hold-local " MESSAGE-FILE " [" TARGET ] +Create a queue entry and print its queue ID. The default isolated diagnostic +target is 999. An explicit target is intended for bounded recovery tests which +must exercise a normal Queue class; it must be between 0 and 999. The message +remains held until it is explicitly delivered or deleted. .TP .BI "deliver-local " "QUEUE-ID SENDER RECIPIENT " [ MAILBOX ] Copy an existing queued message directly to a local Store mailbox. The diff --git a/src/apps/queuetool/bongo-queuetool b/src/apps/queuetool/bongo-queuetool index 1c3b380..34c99e4 100755 --- a/src/apps/queuetool/bongo-queuetool +++ b/src/apps/queuetool/bongo-queuetool @@ -116,17 +116,20 @@ class HoldLocalCommand(Command): Command.__init__( self, "hold-local", summary="Create an isolated local-delivery queue fixture", - usage="%prog %cmd ") + usage="%prog %cmd []") def Run(self, options, args): - if len(args) != 1: - self.error("exactly one message file is required") + if len(args) < 1 or len(args) > 2: + self.error("a message file and optional queue target are required") + target = int(args[1]) if len(args) == 2 else 999 + if target < 0 or target > 999: + self.error("queue target must be between 0 and 999") with open(args[0], "rb") as message_file: message = message_file.read() queue = QueueClient(host=options.host, port=options.port) try: - queue.Create(999) + queue.Create(target) queue.StoreMessage(message) response = queue.Run() print(response.message.split(" ", 1)[0])