From 34709e6f0153bd92a117f542a7bfb76e7d289d2e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 5 May 2024 23:35:10 +0000 Subject: search: fix altid search with XapHelper process External Xapian helper processes need to support non-standard QueryParser prefixes. The only way to do this is to specify these prefixes in every `mset' request since we have no idea if the XH worker servicing the request has initialized the extra prefixes, yet. --- t/www_altid.t | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 't') diff --git a/t/www_altid.t b/t/www_altid.t index de1e6ed6..7ad4a1d2 100644 --- a/t/www_altid.t +++ b/t/www_altid.t @@ -6,7 +6,7 @@ use PublicInbox::Config; use PublicInbox::Spawn qw(spawn); require_cmd('sqlite3'); require_mods(qw(DBD::SQLite HTTP::Request::Common Plack::Test URI::Escape - Plack::Builder IO::Uncompress::Gunzip)); + Plack::Builder IO::Uncompress::Gunzip Xapian)); use_ok($_) for qw(Plack::Test HTTP::Request::Common); require_ok 'PublicInbox::Msgmap'; require_ok 'PublicInbox::AltId'; @@ -14,17 +14,13 @@ require_ok 'PublicInbox::WWW'; my ($tmpdir, $for_destroy) = tmpdir(); my $aid = 'xyz'; my $cfgpath; -my $ibx = create_inbox 'test', indexlevel => 'basic', sub { +my $spec = "serial:$aid:file=blah.sqlite3"; +my $ibx = create_inbox 'test-altid', indexlevel => 'medium', + altid => [ $spec ], sub { my ($im, $ibx) = @_; - $im->add(PublicInbox::Eml->new(<<'EOF')) or BAIL_OUT; -From: a@example.com -Message-Id: - -EOF - # $im->done; - my $spec = "serial:$aid:file=blah.sqlite3"; my $altid = PublicInbox::AltId->new($ibx, $spec, 1); $altid->mm_alt->mid_set(1, 'a@example.com'); + undef $altid; $cfgpath = "$ibx->{inboxdir}/cfg"; open my $fh, '>', $cfgpath or BAIL_OUT "open $cfgpath: $!"; print $fh <add(PublicInbox::Eml->new(<<'EOF')) or BAIL_OUT; +From: a@example.com +Message-Id: + +EOF }; $cfgpath //= "$ibx->{inboxdir}/cfg"; my $cfg = PublicInbox::Config->new($cfgpath); @@ -56,6 +57,11 @@ my $client = sub { is($mm_cmp->mid_for(1), 'a@example.com', 'sqlite3 dump valid'); $mm_cmp = undef; unlink $cmpfile or die; + + $res = $cb->(GET('/test/?q=xyz:1')); + is $res->code, 200, 'altid search hit'; + $res = $cb->(GET('/test/?q=xyz:10')); + is $res->code, 404, 'altid search miss'; }; test_psgi(sub { $www->call(@_) }, $client); SKIP: { -- cgit v1.2.3-24-ge0c7