user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
e56b28204ca13f1e0fb616a0c2c60f24d48798e1 blob 3386 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
 
#!perl -w
# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use v5.10.1;
use List::Util qw(shuffle max);
use PublicInbox::TestCommon;
use PublicInbox::Eml;
require_mods(qw(DBD::SQLite Search::Xapian));
require PublicInbox::ExtSearchIdx;
require_git 2.6;
require_ok 'PublicInbox::LeiXSearch';
require_ok 'PublicInbox::LeiALE';
my ($home, $for_destroy) = tmpdir();
my @ibx;
for my $V (1..2) {
	for my $i (3..6) {
		push @ibx, create_inbox("v$V-$i", indexlevel => 'full',
					version => $V, sub {
			my ($im, $ibx) = @_;
			for my $j (0..9) {
				my $eml = PublicInbox::Eml->new(<<EOM);
From: x\@example.com
To: $ibx->{-primary_address}
Date: Fri, 02 Oct 1993 0$V:0$i:0$j +0000
Subject: v${V}i${i}j$j
Message-ID: <v${V}i${i}j$j\@example>

${V}er ${i}on j$j
EOM
				$im->add($eml) or BAIL_OUT '->add';
			}
		}); # create_inbox
	}
}
my $first = shift @ibx; is($first->{name}, 'v1-3', 'first plucked');
my $last = pop @ibx; is($last->{name}, 'v2-6', 'last plucked');
my $eidx = PublicInbox::ExtSearchIdx->new("$home/eidx");
$eidx->attach_inbox($first);
$eidx->attach_inbox($last);
$eidx->eidx_sync({fsync => 0});
my $es = PublicInbox::ExtSearch->new("$home/eidx");
my $lxs = PublicInbox::LeiXSearch->new;
for my $ibxish (shuffle($es, @ibx)) {
	$lxs->prepare_external($ibxish);
}
for my $loc ($lxs->locals) {
	$lxs->attach_external($loc);
}
my $nr = $lxs->xdb->get_doccount;
my $mset = $lxs->mset('d:19931002..19931003', { limit => $nr });
is($mset->size, $nr, 'got all messages');
my @msgs;
for my $mi ($mset->items) {
	if (my $smsg = $lxs->smsg_for($mi)) {
		push @msgs, $smsg;
	} else {
		diag "E: ${\$mi->get_docid} missing";
	}
}
is(scalar(@msgs), $nr, 'smsgs retrieved for all');

$mset = $lxs->recent(undef, { limit => 1 });
is($mset->size, 1, 'one result');
my $max = max(map { $_->{docid} } @msgs);
is($lxs->smsg_for(($mset->items)[0])->{docid}, $max,
	'got highest docid');

my @ibxish = $lxs->locals;
is(scalar(@ibxish), scalar(@ibx) + 1, 'got locals back');
is($lxs->search, $lxs, '->search works');
is($lxs->over, undef, '->over fails');

{
	$lxs = PublicInbox::LeiXSearch->new;
	my $v2ibx = create_inbox 'v2full', version => 2, sub {
		$_[0]->add(eml_load('t/plack-qp.eml'));
	};
	my $v1ibx = create_inbox 'v1medium', indexlevel => 'medium',
				tmpdir => "$home/v1tmp", sub {
		$_[0]->add(eml_load('t/utf8.eml'));
	};
	$lxs->prepare_external($v1ibx);
	$lxs->prepare_external($v2ibx);
	for my $loc ($lxs->locals) {
		$lxs->attach_external($loc);
	}
	my $mset = $lxs->mset('m:testmessage@example.com');
	is($mset->size, 1, 'got m: match on medium+full XSearch mix');
	my $mitem = ($mset->items)[0];
	my $smsg = $lxs->smsg_for($mitem) or BAIL_OUT 'smsg_for broken';

	my $ale = PublicInbox::LeiALE::_new("$home/ale");
	$ale->refresh_externals($lxs);
	my $exp = [ $smsg->{blob}, 'blob', -s 't/utf8.eml' ];
	is_deeply([ $ale->git->check($smsg->{blob}) ], $exp, 'ale->git->check');

	$lxs = PublicInbox::LeiXSearch->new;
	$lxs->prepare_external($v2ibx);
	$ale->refresh_externals($lxs);
	is_deeply([ $ale->git->check($smsg->{blob}) ], $exp,
			'ale->git->check remembered inactive external');

	rename("$home/v1tmp", "$home/v1moved") or BAIL_OUT "rename: $!";
	$ale->refresh_externals($lxs);
	is($ale->git->check($smsg->{blob}), undef,
			'missing after directory gone');
}

done_testing;
debug log:

solving e56b2820 ...
found e56b2820 in public-inbox.git

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git