user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/2] fix handling of missing Xapian
@ 2021-08-08  1:14 Eric Wong
  2021-08-08  1:14 ` [PATCH 1/2] tests: fix test failures when Xapian is missing Eric Wong
  2021-08-08  1:14 ` [PATCH 2/2] searchidx: die on Xapian load errors Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-08  1:14 UTC (permalink / raw)
  To: meta

Xapian is still optional, and we should handle it better and
avoid confusing users if something is broken.

Eric Wong (2):
  tests: fix test failures when Xapian is missing
  searchidx: die on Xapian load errors

 lib/PublicInbox/SearchIdx.pm | 6 +++---
 lib/PublicInbox/Xapcmd.pm    | 2 +-
 t/imapd.t                    | 9 ++++++---
 t/thread-index-gap.t         | 4 ++--
 4 files changed, 12 insertions(+), 9 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] tests: fix test failures when Xapian is missing
  2021-08-08  1:14 [PATCH 0/2] fix handling of missing Xapian Eric Wong
@ 2021-08-08  1:14 ` Eric Wong
  2021-08-08  1:14 ` [PATCH 2/2] searchidx: die on Xapian load errors Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-08  1:14 UTC (permalink / raw)
  To: meta

We still support usage without Xapian, so ensure our tests
work when Xapian bindings are missing
---
 t/imapd.t            | 9 ++++++---
 t/thread-index-gap.t | 4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/t/imapd.t b/t/imapd.t
index 8cdb4e4a..906b6926 100644
--- a/t/imapd.t
+++ b/t/imapd.t
@@ -39,7 +39,8 @@ print $cfgfh <<EOM or BAIL_OUT;
 EOM
 my $eml;
 for my $V (@V) {
-	my $ibx = create_inbox("i$V", tmpdir => "$tmpdir/i$V", version => $V,
+	my $ibx = create_inbox("i$V-$level",
+				tmpdir => "$tmpdir/i$V", version => $V,
 				indexlevel => $level, sub {
 		my ($im) = @_;
 		$im->add($eml //= eml_load('t/utf8.eml')) or BAIL_OUT;
@@ -52,6 +53,7 @@ for my $V (@V) {
 	address = $ibx->{-primary_address};
 	newsgroup = inbox.i$V
 	url = http://example.com/i$V
+	indexlevel = $level
 EOF
 }
 close $cfgfh or BAIL_OUT;
@@ -444,7 +446,7 @@ SKIP: {
 	mkdir "$home/.public-inbox" or BAIL_OUT $!;
 	local $ENV{HOME} = $home;
 	my $name = 'watchimap';
-	my $addr = "i1\@example.com";
+	my $addr = "i1-$level\@example.com";
 	my $url = "http://example.com/i1";
 	my $inboxdir = "$tmpdir/watchimap";
 	my $cmd = ['-init', '-V2', '-Lbasic', $name, $inboxdir, $url, $addr];
@@ -472,7 +474,8 @@ SKIP: {
 	open my $fh, '<', 't/iso-2202-jp.eml' or BAIL_OUT $!;
 	$old_env->{ORIGINAL_RECIPIENT} = $addr;
 	ok(run_script([qw(-mda --no-precheck)], $old_env, { 0 => $fh }),
-		'delivered a message for IDLE to kick -watch');
+		'delivered a message for IDLE to kick -watch') or
+		diag "mda error \$?=$?";
 	diag 'waiting for IMAP IDLE wakeup';
 	PublicInbox::DS->SetPostLoopCallback(undef);
 	PublicInbox::DS->EventLoop;
diff --git a/t/thread-index-gap.t b/t/thread-index-gap.t
index d3cb6204..15c362f0 100644
--- a/t/thread-index-gap.t
+++ b/t/thread-index-gap.t
@@ -31,9 +31,9 @@ EOF
 my ($home, $for_destroy) = tmpdir();
 for my $msgs (['orig', reverse @msgs], ['shuffle', shuffle(@msgs)]) {
 	my $desc = shift @$msgs;
-	my $n = "index-cap-$desc";
+	my $n = "index-cap-$desc-basic";
 	# yes, the shuffle case gets memoized by create_inbox, oh well
-	my $ibx = create_inbox $desc, version => 2, indexlevel => 'full',
+	my $ibx = create_inbox $desc, version => 2, indexlevel => 'basic',
 				tmpdir => "$home/$desc", sub {
 		my ($im) = @_;
 		for my $m (@$msgs) {

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] searchidx: die on Xapian load errors
  2021-08-08  1:14 [PATCH 0/2] fix handling of missing Xapian Eric Wong
  2021-08-08  1:14 ` [PATCH 1/2] tests: fix test failures when Xapian is missing Eric Wong
@ 2021-08-08  1:14 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2021-08-08  1:14 UTC (permalink / raw)
  To: meta; +Cc: Toke Høiland-Jørgensen

Xapian bindings may not be installed or be out-of-date w.r.t. the
Perl version, improve the visibility of errors in those cases.
Cleanup and drop some redundant checks while we're at it.

Cc: "Toke Høiland-Jørgensen" <toke@toke.dk>
Link: https://public-inbox.org/meta/87k0ky5mbd.fsf@toke.dk/
---
 lib/PublicInbox/SearchIdx.pm | 6 +++---
 lib/PublicInbox/Xapcmd.pm    | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index f4f3ba34..5b0e4458 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -94,7 +94,7 @@ sub need_xapian ($) { $_[0]->{indexlevel} =~ $xapianlevels }
 sub idx_release {
 	my ($self, $wake) = @_;
 	if (need_xapian($self)) {
-		my $xdb = delete $self->{xdb} or croak 'not acquired';
+		my $xdb = delete $self->{xdb} or croak '{xdb} not acquired';
 		$xdb->close;
 	}
 	$self->lock_release($wake) if $self->{creat};
@@ -103,7 +103,7 @@ sub idx_release {
 
 sub load_xapian_writable () {
 	return 1 if $X->{WritableDatabase};
-	PublicInbox::Search::load_xapian() or return;
+	PublicInbox::Search::load_xapian() or die "failed to load Xapian: $@\n";
 	my $xap = $PublicInbox::Search::Xap;
 	for (qw(Document TermGenerator WritableDatabase)) {
 		$X->{$_} = $xap.'::'.$_;
@@ -783,7 +783,7 @@ sub v1_checkpoint ($$;$) {
 	${$sync->{max}} = $self->{batch_bytes};
 
 	$self->{mm}->{dbh}->commit;
-	my $xdb = need_xapian($self) ? $self->{xdb} : undef;
+	my $xdb = $self->{xdb};
 	if ($newest && $xdb) {
 		my $cur = $xdb->get_metadata('last_commit');
 		if (need_update($self, $cur, $newest)) {
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index e37eece5..8b8958c7 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -406,7 +406,7 @@ sub cpdb ($$) { # cb_spawn callback
 	my $new = $newdir->dirname;
 	my ($src, $cur_shard);
 	my $reshard;
-	PublicInbox::SearchIdx::load_xapian_writable() or die;
+	PublicInbox::SearchIdx::load_xapian_writable();
 	my $XapianDatabase = $PublicInbox::Search::X{Database};
 	if (ref($old) eq 'ARRAY') {
 		($cur_shard) = ($new =~ m!(?:xap|ei)[0-9]+/([0-9]+)\b!);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-08  1:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-08  1:14 [PATCH 0/2] fix handling of missing Xapian Eric Wong
2021-08-08  1:14 ` [PATCH 1/2] tests: fix test failures when Xapian is missing Eric Wong
2021-08-08  1:14 ` [PATCH 2/2] searchidx: die on Xapian load errors Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).