From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A42601FBC8 for ; Wed, 10 Jun 2020 07:06:24 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 29/82] add imapd compression test Date: Wed, 10 Jun 2020 07:04:26 +0000 Message-Id: <20200610070519.18252-30-e@yhbt.net> In-Reply-To: <20200610070519.18252-1-e@yhbt.net> References: <20200610070519.18252-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Include a test for Mail::IMAPTalk, here, since Mail::IMAPClient stalls with compression enabled: https://rt.cpan.org/Ticket/Display.html?id=132720 --- MANIFEST | 1 + xt/cmp-imapd-compress.t | 83 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 xt/cmp-imapd-compress.t diff --git a/MANIFEST b/MANIFEST index 82f047f3623..f74852b6e90 100644 --- a/MANIFEST +++ b/MANIFEST @@ -346,6 +346,7 @@ t/www_listing.t t/www_static.t t/x-unknown-alpine.eml t/xcpdb-reshard.t +xt/cmp-imapd-compress.t xt/cmp-msgstr.t xt/cmp-msgview.t xt/eml_check_limits.t diff --git a/xt/cmp-imapd-compress.t b/xt/cmp-imapd-compress.t new file mode 100644 index 00000000000..b12cf74e2d5 --- /dev/null +++ b/xt/cmp-imapd-compress.t @@ -0,0 +1,83 @@ +#!perl -w +# Copyright (C) 2020 all contributors +# License: AGPL-3.0+ +use strict; +use Test::More; +use PublicInbox::TestCommon; +require_mods('Data::Dumper'); +Data::Dumper->import('Dumper'); +my $inboxdir = $ENV{GIANT_INBOX_DIR}; +(defined($inboxdir) && -d $inboxdir) or + plan skip_all => "GIANT_INBOX_DIR not defined for $0"; +plan skip_all => "bad characters in $inboxdir" if $inboxdir =~ m![^\w\.\-/]!; +my ($tmpdir, $for_destroy) = tmpdir(); +my $cfg = "$tmpdir/cfg"; +my $mailbox = 'inbox.test'; +{ + open my $fh, '>', $cfg or BAIL_OUT "open: $!"; + print $fh < $cfg }; +my $td = start_script($cmd, $env, { 3 => $sock }) or BAIL_OUT "-imapd: $?"; +my ($host, $port) = ($sock->sockhost, $sock->sockport); +my $c = tcp_connect($sock); +like(readline($c), qr/CAPABILITY /, 'got greeting'); +undef $c; + +SKIP: { + require_mods('Mail::IMAPClient', 3); + unless ($ENV{RT_132720_FIXED}) { + my $bug = 'https://rt.cpan.org/Ticket/Display.html?id=132720'; + skip "<$bug>, RT_132720_FIXED not defined", 3; + } + my %opt = (Server => $host, Port => $port, + User => 'u', Password => 'p', Clear => 1); + my $uc = Mail::IMAPClient->new(%opt); + my $c = Mail::IMAPClient->new(%opt); + ok($c->compress, 'enabled compression'); + ok $c->examine($mailbox), 'compressed EXAMINE-ed'; + ok $uc->examine($mailbox), 'uncompress EXAMINE-ed'; + my $range = $uc->search('all'); + for my $uid (@$range) { + my $A = $uc->fetch_hash($uid, 'BODY[]'); + my $B = $c->fetch_hash($uid, 'BODY[]'); + if (!is_deeply($A, $B, "$uid identical")) { + diag Dumper([$A, $B]); + diag Dumper([$uc, $c]); + last; + } + } + $uc->logout; + $c->logout; +} + +SKIP: { + require_mods('Mail::IMAPTalk', 3); + my %opt = (Server => $host, Port => $port, UseSSL => 0, + Username => 'u', Password => 'p', Uid => 1); + my $uc = Mail::IMAPTalk->new(%opt) or BAIL_OUT 'IMAPTalk->new'; + my $c = Mail::IMAPTalk->new(%opt, UseCompress => 1) or + BAIL_OUT 'IMAPTalk->new(UseCompress => 1)'; + ok $c->examine($mailbox), 'compressed EXAMINE-ed'; + ok $uc->examine($mailbox), 'uncompress EXAMINE-ed'; + my $range = $uc->search('all'); + for my $uid (@$range) { + my $A = $uc->fetch($uid, 'rfc822'); + my $B = $c->fetch($uid, 'rfc822'); + if (!is_deeply($A, $B, "$uid identical")) { + diag Dumper([$A, $B]); + diag Dumper([$uc, $c]); + last; + } + } +} +done_testing;