about summary refs log tree commit homepage
path: root/t
diff options
authorEric Wong <e@yhbt.net>2020-03-28 00:56:03 +0000
committerEric Wong <e@yhbt.net>2020-03-29 23:28:28 +0000
commit8e1ec8836dabc58dfc0115b36ed440b4371b70d7 (patch)
tree49746b343d3570a858fbde12d46be26253c9597d /t
parent6d6c6d27dd3ecafd523962dff2170d48a71680cf (diff)
For sharded v2 repositories with few-enough messages, it is
possible for shard[0] to go unused and never trigger the
->commit_txn_lazy to set the indexlevel field in Xapian

So set it immediately at initialization and avoid this case.
While we're at it, avoid triggering needless pwrite syscalls
from ->set_metadata by checking with ->get_metadata, first.
Diffstat (limited to 't')
1 files changed, 6 insertions, 1 deletions
diff --git a/t/init.t b/t/init.t
index e20ff006..a78c2fc8 100644
--- a/t/init.t
+++ b/t/init.t
@@ -5,6 +5,7 @@ use warnings;
 use Test::More;
 use PublicInbox::Config;
 use PublicInbox::TestCommon;
+use PublicInbox::Admin;
 use File::Basename;
 my ($tmpdir, $for_destroy) = tmpdir();
 sub quiet_fail {
@@ -72,11 +73,15 @@ SKIP: {
         quiet_fail($cmd, 'initializing V2 as V1 fails');
         foreach my $lvl (qw(medium basic)) {
+                my $dir = "$tmpdir/v2$lvl";
                 $cmd = [ '-init', "v2$lvl", '-V2', '-L', $lvl,
-                        "$tmpdir/v2$lvl", "http://example.com/v2$lvl",
+                        $dir, "http://example.com/v2$lvl",
                         "v2$lvl\@example.com" ];
                 ok(run_script($cmd), "-init -L $lvl");
                 is(read_indexlevel("v2$lvl"), $lvl, "indexlevel set to '$lvl'");
+                my $ibx = PublicInbox::Inbox->new({ inboxdir => $dir });
+                is(PublicInbox::Admin::detect_indexlevel($ibx), $lvl,
+                        'detected expected level w/o config');
         # loop for idempotency