]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/xcpdb-reshard.t
t/v1-add-remove-add: quiet down "git init"
[public-inbox.git] / t / xcpdb-reshard.t
index bf56404deb79ed1c00d2a155638a113aafac7f73..88e6c3dc3494db9c8d86421d235b154ac1ddf49f 100644 (file)
@@ -27,14 +27,13 @@ my $mime = PublicInbox::MIME->create(
 my ($this) = (split('/', $0))[-1];
 my $tmpdir = tempdir($this.'-XXXXXX', TMPDIR => 1, CLEANUP => 1);
 my $ibx = PublicInbox::Inbox->new({
-       mainrepo => "$tmpdir/testbox",
+       inboxdir => "$tmpdir/testbox",
        name => $this,
        version => 2,
        -primary_address => 'test@example.com',
        indexlevel => 'medium',
 });
-my $path = 'blib/script';
-my @xcpdb = ("$path/public-inbox-xcpdb", '-q');
+my @xcpdb = qw(-xcpdb -q);
 my $nproc = 8;
 my $ndoc = 13;
 my $im = PublicInbox::InboxWritable->new($ibx, {nproc => $nproc})->importer(1);
@@ -43,17 +42,17 @@ for my $i (1..$ndoc) {
        ok($im->add($mime), "message $i added");
 }
 $im->done;
-my @parts = grep(m!/\d+\z!, glob("$ibx->{mainrepo}/xap*/*"));
-is(scalar(@parts), $nproc, 'got expected parts');
+my @shards = grep(m!/\d+\z!, glob("$ibx->{inboxdir}/xap*/*"));
+is(scalar(@shards), $nproc, 'got expected shards');
 my $orig = $ibx->over->query_xover(1, $ndoc);
 my %nums = map {; "$_->{num}" => 1 } @$orig;
 
 # ensure we can go up or down in shards, or stay the same:
 for my $R (qw(2 4 1 3 3)) {
        delete $ibx->{search}; # release old handles
-       is(system(@xcpdb, "-R$R", $ibx->{mainrepo}), 0, "xcpdb -R$R");
-       my @new_parts = grep(m!/\d+\z!, glob("$ibx->{mainrepo}/xap*/*"));
-       is(scalar(@new_parts), $R, 'resharded to two parts');
+       ok(run_script([@xcpdb, "-R$R", $ibx->{inboxdir}]), "xcpdb -R$R");
+       my @new_shards = grep(m!/\d+\z!, glob("$ibx->{inboxdir}/xap*/*"));
+       is(scalar(@new_shards), $R, 'resharded to two shards');
        my $msgs = $ibx->search->query('s:this');
        is(scalar(@$msgs), $ndoc, 'got expected docs after resharding');
        my %by_mid = map {; "$_->{mid}" => $_ } @$msgs;
@@ -64,7 +63,7 @@ for my $R (qw(2 4 1 3 3)) {
        # ensure docids in Xapian match NNTP article numbers
        my $tot = 0;
        my %tmp = %nums;
-       foreach my $d (@new_parts) {
+       foreach my $d (@new_shards) {
                my $xdb = Search::Xapian::Database->new($d);
                $tot += $xdb->get_doccount;
                my $it = $xdb->postlist_begin('');