X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fextsearch.t;h=ca586f61c29f5ecab581d56a1dc7a1bdb71e51c5;hb=76f5361d8b8d2bea828ac66dc98a0de24b761b3d;hp=ad4f2c6db85a0277d1ad8b54ec1b663d5640c594;hpb=3f27381a79782be136ae8d27c8f585edbbc6f6bf;p=public-inbox.git diff --git a/t/extsearch.t b/t/extsearch.t index ad4f2c6d..ca586f61 100644 --- a/t/extsearch.t +++ b/t/extsearch.t @@ -423,6 +423,7 @@ if ('dedupe + dry-run') { '--dry-run alone fails'); } +# chmod 0755, $home or xbail "chmod: $!"; for my $j (1, 3, 6) { my $o = { 2 => \(my $err = '') }; my $d = "$home/extindex-j$j"; @@ -436,12 +437,33 @@ for my $j (1, 3, 6) { SKIP: { my $d = "$home/extindex-j1"; + my $es = PublicInbox::ExtSearch->new($d); + ok(my $nresult0 = $es->mset('z:0..')->size, 'got results'); + ok(ref($es->{xdb}), '{xdb} created'); + my $nshards1 = $es->{nshard}; + is($nshards1, 1, 'correct shard count'); + my $xdb_str = "$es->{xdb}"; + ok($es->cleanup_shards, 'cleanup_shards noop'); + is("$es->{xdb}", $xdb_str, '{xdb} unchanged'); + + my @ei_dir = glob("$d/ei*/"); + chmod 0755, $ei_dir[0] or xbail "chmod: $!"; + my $mode = sprintf('%04o', 07777 & (stat($ei_dir[0]))[2]); + is($mode, '0755', 'mode set on ei*/ dir'); 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"); + my $m = sprintf('%04o', 07777 & (stat($dirs[$i]))[2]); + is($m, $mode, "shard [$i] mode"); } + is($es->cleanup_shards, undef, 'cleanup_shards cleaned'); + ok(!defined($es->{xdb}), 'old {xdb} gone'); + is($es->cleanup_shards, undef, 'cleanup_shards clean idempotent'); + is($es->mset('z:0..')->size, $nresult0, 'new shards, same results'); + ok($es->cleanup_shards, 'cleanup_shards true after open'); + for my $i (4..5) { is(grep(m!/ei[0-9]+/$i\z!, @dirs), 0, "no shard [$i]"); }