ok($es->has_threadid, '->has_threadid');
}
+if ('with boost') {
+ xsys([qw(git config publicinbox.v1test.boost), 10],
+ { GIT_CONFIG => $cfg_path });
+ ok(run_script([qw(-extindex --all), "$home/extindex-b"]),
+ 'extindex init with boost');
+ my $es = PublicInbox::ExtSearch->new("$home/extindex-b");
+ my $smsg = $es->over->get_art(1);
+ ok($smsg, 'got first article');
+ my $xref3 = $es->over->get_xref3($smsg->{num});
+ my @v1 = grep(/\Av1/, @$xref3);
+ my @v2 = grep(/\Av2/, @$xref3);
+ like($v1[0], qr/\Av1\.example.*?\b\Q$smsg->{blob}\E\b/,
+ 'smsg->{blob} respected boost');
+ is(scalar(@$xref3), 2, 'only to entries');
+ undef $es;
+
+ xsys([qw(git config publicinbox.v2test.boost), 20],
+ { GIT_CONFIG => $cfg_path });
+ ok(run_script([qw(-extindex --all --reindex), "$home/extindex-b"]),
+ 'extindex --reindex with altered boost');
+
+ $es = PublicInbox::ExtSearch->new("$home/extindex-b");
+ $smsg = $es->over->get_art(1);
+ like($v2[0], qr/\Av2\.example.*?\b\Q$smsg->{blob}\E\b/,
+ 'smsg->{blob} respects boost after reindex');
+
+ # high boost added later
+ my $b2 = "$home/extindex-bb";
+ ok(run_script([qw(-extindex), $b2, "$home/v1test"]),
+ 'extindex with low boost inbox only');
+ ok(run_script([qw(-extindex), $b2, "$home/v2test"]),
+ 'extindex with high boost inbox only');
+ $es = PublicInbox::ExtSearch->new($b2);
+ $smsg = $es->over->get_art(1);
+ $xref3 = $es->over->get_xref3($smsg->{num});
+ like($v2[0], qr/\Av2\.example.*?\b\Q$smsg->{blob}\E\b/,
+ 'smsg->{blob} respected boost across 2 index runs');
+
+ xsys([qw(git config --unset publicinbox.v1test.boost)],
+ { GIT_CONFIG => $cfg_path });
+ xsys([qw(git config --unset publicinbox.v2test.boost)],
+ { GIT_CONFIG => $cfg_path });
+}
+
{ # TODO: -extindex should write this to config
open $fh, '>>', $cfg_path or BAIL_OUT $!;
print $fh <<EOF or BAIL_OUT $!;
'--dry-run alone fails');
}
+for my $j (1, 3, 6) {
+ my $o = { 2 => \(my $err = '') };
+ my $d = "$home/extindex-j$j";
+ ok(run_script(['-extindex', "-j$j", '--all', $d], undef, $o),
+ "init with -j$j");
+ my $max = $j - 2;
+ $max = 0 if $max < 0;
+ my @dirs = glob("$d/ei*/?");
+ like($dirs[-1], qr!/ei[0-9]+/$max\z!, '-j works');
+}
+
+SKIP: {
+ my $d = "$home/extindex-j1";
+ my $o = { 2 => \(my $err = '') };
+ ok(run_script([qw(-xcpdb -R4), $d]), 'xcpdb R4');
+ my @dirs = glob("$d/ei*/?");
+ for my $i (0..3) {
+ is(grep(m!/ei[0-9]+/$i\z!, @dirs), 1, "shard [$i] created");
+ }
+ for my $i (4..5) {
+ is(grep(m!/ei[0-9]+/$i\z!, @dirs), 0, "no shard [$i]");
+ }
+
+ ok(run_script([qw(-xcpdb -R2), $d]), 'xcpdb -R2');
+ @dirs = glob("$d/ei*/?");
+ for my $i (0..1) {
+ is(grep(m!/ei[0-9]+/$i\z!, @dirs), 1, "shard [$i] kept");
+ }
+ for my $i (2..3) {
+ is(grep(m!/ei[0-9]+/$i\z!, @dirs), 0, "no shard [$i]");
+ }
+ skip 'xapian-compact missing', 4 unless have_xapian_compact;
+ ok(run_script([qw(-compact), $d], undef, $o), 'compact');
+ # n.b. stderr contains xapian-compact output
+
+ my @d2 = glob("$d/ei*/?");
+ is_deeply(\@d2, \@dirs, 'dirs consistent after compact');
+ ok(run_script([qw(-extindex --dedupe --all), $d]),
+ '--dedupe works after compact');
+ ok(run_script([qw(-extindex --gc), $d], undef, $o),
+ '--gc works after compact');
+}
+
done_testing;