X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fxcpdb-reshard.t;h=0d78d2b200b3e58136a9d5e997f4de788c114f42;hb=3c313f9034aac96182e2efdc2f92c40803626f32;hp=43e08639d8ba72e0f3894f5d6f49eefabd1544a4;hpb=3c39f9c942a6975245fda878e9b957d8d3367662;p=public-inbox.git diff --git a/t/xcpdb-reshard.t b/t/xcpdb-reshard.t index 43e08639..0d78d2b2 100644 --- a/t/xcpdb-reshard.t +++ b/t/xcpdb-reshard.t @@ -8,9 +8,8 @@ foreach my $mod (@mods) { eval "require $mod"; plan skip_all => "missing $mod for $0" if $@; }; -require './t/common.perl'; +use PublicInbox::TestCommon; require_git('2.6'); -use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::InboxWritable; @@ -25,7 +24,8 @@ my $mime = PublicInbox::MIME->create( ); my ($this) = (split('/', $0))[-1]; -my $tmpdir = tempdir($this.'-XXXXXX', TMPDIR => 1, CLEANUP => 1); +my ($tmpdir, $for_destroy) = tmpdir(); +local $ENV{PI_CONFIG} = "$tmpdir/config"; my $ibx = PublicInbox::Inbox->new({ inboxdir => "$tmpdir/testbox", name => $this, @@ -33,8 +33,7 @@ my $ibx = PublicInbox::Inbox->new({ -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); @@ -51,7 +50,9 @@ 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->{inboxdir}), 0, "xcpdb -R$R"); + my $cmd = [@xcpdb, "-R$R", $ibx->{inboxdir}]; + push @$cmd, '--compact' if $R == 1; + ok(run_script($cmd), "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');