diff options
author | Eric Wong <e@80x24.org> | 2021-09-24 10:56:41 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-09-24 23:22:05 +0000 |
commit | 69b5ab18a594fa434d79cacee35c4d9a0df7b55c (patch) | |
tree | 051f0118b39ff5e5f59c177e7cde5c936eb90513 /t | |
parent | b319bb7276457d01ab4bc779d867368f884bd522 (diff) | |
download | public-inbox-69b5ab18a594fa434d79cacee35c4d9a0df7b55c.tar.gz |
Partial (v2) clones should be useful addition for users wanting to conserve storage while having fast access to recent messages. Continuing work started in 876e74283ff3 (fetch: ignore non-writable epoch dirs, 2021-09-17), this creates bare, read-only epoch git repos. These git repos have the remotes pre-configured, but does not fetch any objects. The goal is to allow users to set the writable bit on a previously-skipped epoch and start fetching it. Shell completion support may not be necessary given how short the epoch ranges are, here. Cc: Luis Chamberlain <mcgrof@kernel.org> Link: https://public-inbox.org/meta/20210917002204.GA13112@dcvr/T/#u
Diffstat (limited to 't')
-rw-r--r-- | t/lei-mirror.t | 8 | ||||
-rw-r--r-- | t/v2mirror.t | 25 |
2 files changed, 33 insertions, 0 deletions
diff --git a/t/lei-mirror.t b/t/lei-mirror.t index 7dd03b26..de5246b6 100644 --- a/t/lei-mirror.t +++ b/t/lei-mirror.t @@ -65,6 +65,14 @@ test_lei({ tmpdir => $tmpdir }, sub { lei_ok('ls-external'); unlike($lei_out, qr!\Q$d\E!s, 'not added to ls-external'); + $d = "$home/bad-epoch"; + ok(!lei(qw(add-external -q --epoch=0.. --mirror), "$http/t1/", $d), + 'v1 fails on --epoch'); + ok(!-d $d, 'destination not created on unacceptable --epoch'); + ok(!lei(qw(add-external -q --epoch=1 --mirror), "$http/t2/", $d), + 'v2 fails on bad epoch range'); + ok(!-d $d, 'destination not created on bad epoch'); + my %phail = ( HTTPS => 'https://public-inbox.org/' . 'phail', ONION => diff --git a/t/v2mirror.t b/t/v2mirror.t index 665a4d59..20a8daaa 100644 --- a/t/v2mirror.t +++ b/t/v2mirror.t @@ -263,6 +263,31 @@ if ('test read-only epoch dirs') { 'fetch restored objects once GIT_DIR became writable'); } +{ + my $dst = "$tmpdir/partial"; + run_script([qw(-clone -q --epoch=~0), "http://$host:$port/v2/", $dst]); + is($?, 0, 'no error from partial clone'); + my @g = glob("$dst/git/*.git"); + my @w = grep { -w $_ } @g; + my @r = grep { ! -w $_ } @g; + is(scalar(@w), 1, 'one writable directory'); + my ($w) = ($w[0] =~ m!/([0-9]+)\.git\z!); + is((grep { + m!/([0-9]+)\.git\z! or xbail "no digit in $_"; + $w > ($1 + 0) + } @r), scalar(@r), 'writable epoch # exceeds read-only ones'); + run_script([qw(-fetch -q)], undef, { -C => $dst }); + is($?, 0, 'no error from partial fetch'); + remove_tree($dst); + + run_script([qw(-clone -q --epoch=~1..), + "http://$host:$port/v2/", $dst]); + my @g2 = glob("$dst/git/*.git") ; + is_deeply(\@g2, \@g, 'cloned again'); + is(scalar(grep { -w $_ } @g2), scalar(@w) + 1, + 'got one more cloned epoch'); +} + ok($td->kill, 'killed httpd'); $td->join; |