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 63C7D1F7AA for ; Fri, 26 Jul 2024 21:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1722030192; bh=jNnnrHVNmW/2MDEiql8SfSYIw0CjLx7R8sVENKQcnz8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=INpJYBoH+p3nI8dupo63KhlpUinLr1FFxpyy94pVeocKRZmcnJvJLPWUIvLyOhgvW zPT+xxBazx4RR5FFL6QS7XvHKGW7CAw4fvEOXAKRf/ra3EHTmqVax4uyq0cKvaJjRo laHSwhH5zbXtUwXMCi8S8wh8+4y9Cqmxrh+/YhFU= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH v2 3/4] t/v2writable: test ENOSPC from fast-import Date: Fri, 26 Jul 2024 21:31:10 +0000 Message-ID: <20240726214311.4092940-4-e@80x24.org> In-Reply-To: <20240726214311.4092940-1-e@80x24.org> References: <20240726214311.4092940-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 | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/t/v2writable.t b/t/v2writable.t index a062d1b3..0493f90e 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'; - like $@, qr/ disk is full/, 'set $@ for 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/, '$@ reports 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 fails after fixing ENOSPC'; + $im->done; + ok !$im->add($eml), '->add detects existing message'; + $im->done; + is -s $fh, 0, 'nothing new in fast-import stderr'; } done_testing;