"Eric W. Biederman" <[email protected]> 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
--
unsubscribe: [email protected]
archive: https://public-inbox.org/meta/