From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 2/1] fetch: fix and test v2 epoch detection
Date: Sun, 12 Sep 2021 10:53:34 +0000 [thread overview]
Message-ID: <20210912105334.GA16954@dcvr> (raw)
In-Reply-To: <20210912091239.20745-1-e@80x24.org>
It was also totally broken by the change to use manifest.js.gz
for v1 :x
Fixes: ffb7fbda6869db4b ("fetch: use manifest.js.gz for v1")
---
lib/PublicInbox/Fetch.pm | 2 +-
t/v2mirror.t | 31 ++++++++++++++++---------------
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/lib/PublicInbox/Fetch.pm b/lib/PublicInbox/Fetch.pm
index 2c6ae86a..4d501108 100644
--- a/lib/PublicInbox/Fetch.pm
+++ b/lib/PublicInbox/Fetch.pm
@@ -148,7 +148,7 @@ EOM
$cmd = [ @$torsocks, fetch_cmd($lei, $opt) ];
} else {
my $e_uri = $ibx_uri->clone;
- my ($epath) = ($d =~ m!/(git/[0-9]+\.git)\z!);
+ my ($epath) = ($d =~ m!(/git/[0-9]+\.git)\z!);
defined($epath) or
die "BUG: $d is not an epoch to clone\n";
$e_uri->path($ibx_uri->path.$epath);
diff --git a/t/v2mirror.t b/t/v2mirror.t
index 012e5bd2..b0075fcc 100644
--- a/t/v2mirror.t
+++ b/t/v2mirror.t
@@ -65,20 +65,16 @@ $v2w->done;
$ibx->cleanup;
my $sock = tcp_server();
-my $cmd = [ '-httpd', '-W0', "--stdout=$tmpdir/out", "--stderr=$tmpdir/err" ];
-my $td = start_script($cmd, undef, { 3 => $sock });
+my @cmd = ('-httpd', '-W0', "--stdout=$tmpdir/out", "--stderr=$tmpdir/err");
+my $td = start_script(\@cmd, undef, { 3 => $sock });
my ($host, $port) = tcp_host_port($sock);
$sock = undef;
-my @cmd;
-foreach my $i (0..$epoch_max) {
- my $sfx = $i == 0 ? '.git' : '';
- @cmd = (qw(git clone --mirror -q),
- "http://$host:$port/v2/$i$sfx",
- "$tmpdir/m/git/$i.git");
+@cmd = (qw(-clone -q), "http://$host:$port/v2/", "$tmpdir/m");
+run_script(\@cmd) or xbail '-clone';
- is(xsys(@cmd), 0, "cloned $i.git");
- ok(-d "$tmpdir/m/git/$i.git", "mirror $i OK");
+for my $i (0..$epoch_max) {
+ ok(-d "$tmpdir/m/git/$i.git", "epoch $i cloned");
}
@cmd = ("-init", '-j1', '-V2', 'm', "$tmpdir/m", 'http://example.com/m',
@@ -93,7 +89,6 @@ my $mibx = { inboxdir => "$tmpdir/m", address => 'alt@example.com' };
$mibx = PublicInbox::Inbox->new($mibx);
is_deeply([$mibx->mm->minmax], [$ibx->mm->minmax], 'index synched minmax');
-$v2w->{rotate_bytes} = $old_rotate_bytes;
for my $i (10..15) {
$mime->header_set('Message-ID', "<$i\@example.com>");
$mime->header_set('Subject', "subject = $i");
@@ -102,12 +97,17 @@ for my $i (10..15) {
$v2w->done;
$ibx->cleanup;
+my @new_epochs;
my $fetch_each_epoch = sub {
- foreach my $i (0..$epoch_max) {
- my $dir = "$tmpdir/m/git/$i.git";
- is(xsys('git', "--git-dir=$dir", 'fetch', '-q'), 0,
- 'fetch successful');
+ my $mf = "$tmpdir/m/manifest.js.gz";
+ if (my @st = stat($mf)) {
+ utime($st[8], $st[9] - 1, $mf) or xbail "utime $mf: $!";
}
+ my %before = map { $_ => 1 } glob("$tmpdir/m/git/*");
+ run_script([qw(-fetch -q)], undef, {-C => "$tmpdir/m"}) or
+ xbail '-fetch fail';
+ my @after = grep { !$before{$_} } glob("$tmpdir/m/git/*");
+ push @new_epochs, @after;
};
$fetch_each_epoch->();
@@ -233,6 +233,7 @@ EOF
$mset = $mibx->search->reopen->mset('m:2big@a');
is(scalar($mset->items), 0, 'large message not re-indexed');
}
+ok(scalar(@new_epochs), 'new epochs were created and fetched');
ok($td->kill, 'killed httpd');
$td->join;
prev parent reply other threads:[~2021-09-12 10:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-12 9:12 [PATCH] fetch: fix half-baked v1 manifest.js.gz handling Eric Wong
2021-09-12 10:53 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210912105334.GA16954@dcvr \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).