about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2024-04-24 06:44:47 +0000
committerEric Wong <e@80x24.org>2024-04-24 21:34:47 +0000
commit9987cc1cc687f3b2d03a78938773c4f0c5b64d98 (patch)
tree89a65b32d436ae0b729ed583328aec7836d69b16 /t
parent1682c7a2264b1083a9cd37151134667edbc31059 (diff)
downloadpublic-inbox-9987cc1cc687f3b2d03a78938773c4f0c5b64d98.tar.gz
The C++ version of xap_helper will allow more complex and
expensive queries.  Both the Perl and C++-only version will
allow offloading search into a separate process which can be
killed via ITIMER_REAL or RLIMIT_CPU in the face of overload.

The xap_helper `mset' command wrapper is simplified to
unconditionally return rank, percentage, and estimated matches
information.  This may slightly penalize mbox retrievals and
lei users, but perhaps that can be a different command entirely.
Diffstat (limited to 't')
-rw-r--r--t/cindex.t8
-rw-r--r--t/xap_helper.t14
2 files changed, 13 insertions, 9 deletions
diff --git a/t/cindex.t b/t/cindex.t
index acd74a5d..90236287 100644
--- a/t/cindex.t
+++ b/t/cindex.t
@@ -152,10 +152,12 @@ my $test_xhc = sub {
         my ($r, @l);
         $r = $xhc->mkreq([], qw(mset -c -g), $zp_git, @xh_args, 'NUL');
         chomp(@l = <$r>);
-        is(shift(@l), 'mset.size=2', "got expected header $impl");
+        like shift(@l), qr/\bmset\.size=2\b/, "got expected header $impl";
         my %docid2data;
         my @got = sort map {
-                my ($docid, @extra) = split /\0/;
+                my ($docid, $pct, $rank, @extra) = split /\0/;
+                ok $pct >= 0 && $pct <= 100, 'pct in range';
+                ok $rank >= 0 && $rank <= 100000, 'rank ok';
                 is scalar(@extra), 0, 'no extra fields';
                 $docid2data{$docid} =
                         $csrch->xdb->get_document($docid)->get_data;
@@ -164,7 +166,7 @@ my $test_xhc = sub {
 
         $r = $xhc->mkreq([], qw(mset -c -g), "$tmp/wt0/.git", @xh_args, 'NUL');
         chomp(@l = <$r>);
-        is(shift(@l), 'mset.size=0', "got miss in wrong dir $impl");
+        like shift(@l), qr/\bmset.size=0\b/, "got miss in wrong dir $impl";
         is_deeply(\@l, [], "no extra lines $impl");
 
         while (my ($did, $expect) = each %docid2data) {
diff --git a/t/xap_helper.t b/t/xap_helper.t
index 70c634ac..effe8bc5 100644
--- a/t/xap_helper.t
+++ b/t/xap_helper.t
@@ -204,10 +204,11 @@ for my $n (@NO_CXX) {
         $err = do { local $/; <$err_r> };
         is $err, "mset.size=6 nr_out=5\n", "got expected status ($xhc->{impl})";
 
-        $r = $xhc->mkreq([], qw(mset -p), @ibx_shard_args,
+        $r = $xhc->mkreq([], qw(mset), @ibx_shard_args,
                                 'dfn:lib/PublicInbox/Search.pm');
         chomp((my $hdr, @res) = readline($r));
-        is $hdr, 'mset.size=1', "got expected header via mset ($xhc->{impl}";
+        like $hdr, qr/\bmset\.size=1\b/,
+                "got expected header via mset ($xhc->{impl}";
         is scalar(@res), 1, 'got one result';
         @res = split /\0/, $res[0];
         {
@@ -217,19 +218,20 @@ for my $n (@NO_CXX) {
                 is_deeply \@q, [ $mid ], 'docid usable';
         }
         ok $res[1] > 0 && $res[1] <= 100, 'pct > 0 && <= 100';
-        is scalar(@res), 2, 'only 2 columns in result';
+        is scalar(@res), 3, 'only 3 columns in result';
 
-        $r = $xhc->mkreq([], qw(mset -p), @ibx_shard_args,
+        $r = $xhc->mkreq([], qw(mset), @ibx_shard_args,
                                 'dt:19700101'.'000000..');
         chomp(($hdr, @res) = readline($r));
-        is $hdr, 'mset.size=6',
+        like $hdr, qr/\bmset\.size=6\b/,
                 "got expected header via multi-result mset ($xhc->{impl}";
         is(scalar(@res), 6, 'got 6 rows');
         for my $r (@res) {
-                my ($docid, $pct, @rest) = split /\0/, $r;
+                my ($docid, $pct, $rank, @rest) = split /\0/, $r;
                 my $doc = $v2->search->xdb->get_document($docid);
                 ok $pct > 0 && $pct <= 100,
                         "pct > 0 && <= 100 #$docid ($xhc->{impl})";
+                like $rank, qr/\A\d+\z/, 'rank is a digit';
                 is scalar(@rest), 0, 'no extra rows returned';
         }
         my $nr;