From 4caa768779a9b417321736b090d50f3421a799de Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 19 Jul 2018 21:43:10 +0000 Subject: 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(-) (limited to 't') diff --git a/t/v1reindex.t b/t/v1reindex.t index ff32750f..d97938d3 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 20903967..1543309c 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(); -- cgit v1.2.3-24-ge0c7