+ # pipelined requests:
+ {
+ my $nreq = 90;
+ my $nart = 2;
+ syswrite($s, "GROUP $group\r\n");
+ my $res = <$s>;
+ my $rdr = fork;
+ if ($rdr == 0) {
+ for (1..$nreq) {
+ <$s> =~ /\A224 / or _exit(1);
+ <$s> =~ /\A1/ or _exit(2);
+ <$s> eq ".\r\n" or _exit(3);
+ }
+ my %sums;
+ for (1..$nart) {
+ <$s> =~ /\A220 / or _exit(4);
+ my $dig = Digest::SHA->new(1);
+ while (my $l = <$s>) {
+ last if $l eq ".\r\n";
+ $dig->add($l);
+ }
+ $dig = $dig->hexdigest;
+ $sums{$dig}++;
+ }
+ if ($nart) {
+ scalar(keys(%sums)) == 1 or _exit(5);
+ (values(%sums))[0] == $nart or _exit(6);
+ }
+ _exit(0);
+ }
+ for (1..$nreq) {
+ syswrite($s, "XOVER 1\r\n");
+ }
+ syswrite($s, "ARTICLE 1\r\n" x $nart);
+ is($rdr, waitpid($rdr, 0), 'reader done');
+ is($? >> 8, 0, 'no errors');
+ }
+ my $noerr = { 2 => \(my $null) };
+ SKIP: {
+ if ($INC{'Search/Xapian.pm'} && ($ENV{TEST_RUN_MODE}//2)) {
+ skip 'Search/Xapian.pm pre-loaded (by t/run.perl?)', 1;
+ }
+ $lsof or skip 'lsof missing', 1;
+ my @of = xqx([$lsof, '-p', $td->{pid}], undef, $noerr);
+ skip('lsof broken', 1) if (!scalar(@of) || $?);
+ my @xap = grep m!Search/Xapian!, @of;
+ is_deeply(\@xap, [], 'Xapian not loaded in nntpd');
+ }
+ # -compact requires Xapian
+ SKIP: {
+ require_mods('Search::Xapian', 2);
+ have_xapian_compact or skip 'xapian-compact missing', 2;
+ is(xsys(qw(git config), "--file=$home/.public-inbox/config",
+ "publicinbox.$group.indexlevel", 'medium'),
+ 0, 'upgraded indexlevel');
+ my $ex = eml_load('t/data/0001.patch');
+ is($n->article($ex->header('Message-ID')), undef,
+ 'article did not exist');
+ my $im = $ibx->importer(0);
+ $im->add($ex);
+ $im->done;
+ {
+ my $f = $ibx->mm->{dbh}->sqlite_db_filename;
+ my $tmp = "$tmpdir/tmp.sqlite3";
+ $ibx->mm->{dbh}->sqlite_backup_to_file($tmp);
+ delete $ibx->{mm};
+ rename($tmp, $f) or BAIL_OUT "rename($tmp, $f): $!";
+ }
+ ok(run_script([qw(-index -c -j0 --reindex), $ibx->{inboxdir}],
+ undef, $noerr), '-compacted');
+ select(undef, undef, undef, $fast_idle ? 0.1 : 2.1);
+ $art = $n->article($ex->header('Message-ID'));
+ ok($art, 'new article retrieved after compact');
+ $lsof or skip 'lsof missing', 1;
+ ($^O =~ /\A(?:linux)\z/) or
+ skip "lsof /(deleted)/ check untested on $^O", 1;
+ my @lsof = xqx([$lsof, '-p', $td->{pid}], undef, $noerr);
+ my $d = [ grep(/\(deleted\)/, @lsof) ];
+ is_deeply($d, [], 'no deleted files') or diag explain($d);
+ };
+ SKIP: { test_watch($tmpdir, $host_port, $group) };