From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8A2B21F785 for ; Tue, 23 Jul 2024 21:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1721770118; bh=1hkhNjWNF1aO39+f4xWzS50Y6ui6eLDT4KQdDhymGF0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SO6JXXjPP7oipb8jTeakq2Nm1rfoOGbiK4KWwirxyeQmzcbYinm+nEDDPI1AXbwD+ yzRtmEyrAwyqDMdb56X4FuAkPoPosZpR6u/G22wKS2CZSZXomWZ7My9P3f28qhC893 hzWAj+OTrCbU+AN+Xi9zkEXotgM4apcriz+V3DHU= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/4] t/v2writable: test ENOSPC from fast-import Date: Tue, 23 Jul 2024 21:28:36 +0000 Message-ID: <20240723212837.3931413-4-e@80x24.org> In-Reply-To: <20240723212837.3931413-1-e@80x24.org> References: <20240723212837.3931413-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This also ensures we can recover after the ENOSPC condition is resolved. --- t/v2writable.t | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/t/v2writable.t b/t/v2writable.t index a062d1b3..93385456 100644 --- a/t/v2writable.t +++ b/t/v2writable.t @@ -9,6 +9,7 @@ use PublicInbox::TestCommon; use PublicInbox::Spawn qw(popen_rd); use Config; use Cwd qw(abs_path); +use autodie qw(kill open read); require_git(2.6); require_mods(qw(DBD::SQLite Xapian)); local $ENV{HOME} = abs_path('t'); @@ -340,15 +341,46 @@ ok($@, 'V2Writable fails on non-existent dir'); SKIP: { my $strace = strace_inject; my $eml = eml_load 't/plack-qp.eml'; + my $gfi_err = "$inboxdir/gfi.err"; open my $fh, '>', my $trace = "$inboxdir/trace.out"; my $rd = popen_rd([ $strace, '-p', $$, '-o', $trace, '-e', 'inject=pwrite64:error=ENOSPC'], undef, { 2 => 1 }); $rd->poll_in(10) or die 'strace not ready'; - ok ! eval { $im->add($eml) }, 'v2w->add fails on ENOSPC'; + ok ! eval { + open my $olderr, '>&', \*STDERR; + open STDERR, '>>', $gfi_err; + $im->add($eml); + open STDERR, '>&', $olderr; + }, 'v2w->add fails on ENOSPC'; like $@, qr/ disk is full/, 'set $@ for ENOSPC'; $im->done; kill 'TERM', $rd->attached_pid; $rd->close; + + $im->add($eml) or xbail 'cannot add message to start fast-import'; + my $pid = $im->{im}->{io}->attached_pid or xbail 'no import pid'; + open $fh, '>', $trace; + + $rd = popen_rd([$strace, '-p', $pid, '-o', $trace, + '-e', 'inject=write:error=ENOSPC:when=1'], + undef, { 2 => 1 }); + $rd->poll_in(10) or die 'strace not ready'; + ok !eval { $im->done }, 'done fails with ENOSPC'; + ok $@, '$@ set on ENOSPC'; + kill 'TERM', $rd->attached_pid; + + open $fh, '<', $gfi_err; + read $fh, my $errbuf, -s $fh; + like $errbuf, qr/fatal:/, 'fatal git error noted'; + open $fh, '>', $gfi_err; + + $rd->close; + + $im->add($eml) or xbail '->add fail after fixing ENOSPC'; + $im->done; + ok !$im->add($eml), '->add detects existing message'; + $im->done; + is -s $fh, 0, 'nothing new fast-import stderr'; } done_testing;