From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6F9D21F597; Thu, 19 Jul 2018 21:51:14 +0000 (UTC) Date: Thu, 19 Jul 2018 21:51:14 +0000 From: Eric Wong To: "Eric W. Biederman" Cc: meta@public-inbox.org Subject: [PATCH] tests: fixup indexlevel setting in tests Message-ID: <20180719215114.zdzysw77vfzgdyfz@whir> References: <87pnzkh4fx.fsf_-_@xmission.com> <20180718165325.19834-3-ebiederm@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180718165325.19834-3-ebiederm@xmission.com> List-Id: "Eric W. Biederman" wrote: > +$ibx_config->{index_level} = 'medium'; Oops, I missed that underscore in my initial review. (and I dislike the lack of '_' in git-config naming conventions, even). ----------8<-------- Subject: [PATCH] tests: fixup indexlevel setting in tests The correct field is underscore-less for consistency with git-config naming conventions. While we're at it, beef up the v2 tests with actual size checks, too. I also noticed phrase searching still seems to work for the limited test case, so I left it documented; but the size checking verifies the space savings. --- t/v1reindex.t | 4 ++-- t/v2reindex.t | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/t/v1reindex.t b/t/v1reindex.t index ff32750..d97938d 100644 --- a/t/v1reindex.t +++ b/t/v1reindex.t @@ -111,7 +111,7 @@ ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap'); remove_tree($xap); ok(!-d $xap, 'Xapian directories removed again'); -$ibx_config->{index_level} = 'medium'; +$ibx_config->{indexlevel} = 'medium'; $ibx = PublicInbox::Inbox->new($ibx_config); $rw = PublicInbox::SearchIdx->new($ibx, 1); { @@ -131,7 +131,7 @@ ok(unlink "$mainrepo/public-inbox/msgmap.sqlite3", 'remove msgmap'); remove_tree($xap); ok(!-d $xap, 'Xapian directories removed again'); -$ibx_config->{index_level} = 'basic'; +$ibx_config->{indexlevel} = 'basic'; $ibx = PublicInbox::Inbox->new($ibx_config); $rw = PublicInbox::SearchIdx->new($ibx, 1); { diff --git a/t/v2reindex.t b/t/v2reindex.t index 2090396..1543309 100644 --- a/t/v2reindex.t +++ b/t/v2reindex.t @@ -81,6 +81,7 @@ ok(!-d $xap, 'Xapian directories removed again'); is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); } +my %sizes; ok(unlink "$mainrepo/msgmap.sqlite3", 'remove msgmap'); remove_tree($xap); ok(!-d $xap, 'Xapian directories removed again'); @@ -94,13 +95,16 @@ ok(!-d $xap, 'Xapian directories removed again'); ok(-d $xap, 'Xapian directories recreated'); delete $ibx->{mm}; is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); + my $mset = $ibx->search->query('"hello world"', {mset=>1}); + isnt(0, $mset->size, "phrase search succeeds on indexlevel=full"); + for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ } } ok(unlink "$mainrepo/msgmap.sqlite3", 'remove msgmap'); remove_tree($xap); ok(!-d $xap, 'Xapian directories removed again'); -$ibx_config->{index_level} = 'medium'; +$ibx_config->{indexlevel} = 'medium'; $ibx = PublicInbox::Inbox->new($ibx_config); $im = PublicInbox::V2Writable->new($ibx); { @@ -113,14 +117,26 @@ $im = PublicInbox::V2Writable->new($ibx); ok(-d $xap, 'Xapian directories recreated'); delete $ibx->{mm}; is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); -} + if (0) { + # not sure why, but Xapian seems to fallback to terms and + # phrase searches still work + delete $ibx->{search}; + my $mset = $ibx->search->query('"hello world"', {mset=>1}); + is(0, $mset->size, 'phrase search does not work on medium'); + } + + my $mset = $ibx->search->query('hello world', {mset=>1}); + isnt(0, $mset->size, "normal search works on indexlevel=medium"); + for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ } + ok($sizes{full} > $sizes{medium}, 'medium is smaller than full'); +} ok(unlink "$mainrepo/msgmap.sqlite3", 'remove msgmap'); remove_tree($xap); ok(!-d $xap, 'Xapian directories removed again'); -$ibx_config->{index_level} = 'basic'; +$ibx_config->{indexlevel} = 'basic'; $ibx = PublicInbox::Inbox->new($ibx_config); $im = PublicInbox::V2Writable->new($ibx); { @@ -133,6 +149,10 @@ $im = PublicInbox::V2Writable->new($ibx); ok(-d $xap, 'Xapian directories recreated'); delete $ibx->{mm}; is_deeply([ $ibx->mm->minmax ], $minmax, 'minmax unchanged'); + my $mset = $ibx->search->query('hello', {mset=>1}); + is(0, $mset->size, "search fails on indexlevel='basic'"); + for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ } + ok($sizes{medium} > $sizes{basic}, 'basic is smaller than medium'); } done_testing(); -- EW