]> Sergey Matveev's repositories - public-inbox.git/blobdiff - xt/httpd-async-stream.t
No ext_urls
[public-inbox.git] / xt / httpd-async-stream.t
index 29bcb61254791c51f1fa2b27e9994243c4385889..0658c691c826131a5080acba36ace71858591f86 100644 (file)
@@ -1,21 +1,26 @@
 #!perl -w
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 # Expensive test to validate compression and TLS.
 use strict;
-use Test::More;
+use v5.10.1;
 use PublicInbox::TestCommon;
 use PublicInbox::DS qw(now);
-use PublicInbox::Spawn qw(which popen_rd);
+use PublicInbox::Spawn qw(popen_rd);
 use Digest::MD5;
 use POSIX qw(_exit);
 my $inboxdir = $ENV{GIANT_INBOX_DIR};
 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless $inboxdir;
-my $curl = which('curl') or plan skip_all => "curl(1) missing for $0";
+my $curl = require_cmd('curl');
 my ($tmpdir, $for_destroy) = tmpdir();
 require_mods(qw(DBD::SQLite));
 my $JOBS = $ENV{TEST_JOBS} // 4;
-diag "TEST_JOBS=$JOBS";
+my $endpoint = $ENV{TEST_ENDPOINT} // 'all.mbox.gz';
+my $curl_opt = $ENV{TEST_CURL_OPT} // '';
+diag "TEST_JOBS=$JOBS TEST_ENDPOINT=$endpoint TEST_CURL_OPT=$curl_opt";
+
+# we set Host: to ensure stable results across test runs
+my @CURL_OPT = (qw(-HHost:example.com -sSf), split(' ', $curl_opt));
 
 my $make_local_server = sub {
        my $pi_config = "$tmpdir/config";
@@ -36,9 +41,9 @@ address = test\@example.com
        # not using multiple workers, here, since we want to increase
        # the chance of tripping concurrency bugs within PublicInbox/HTTP*.pm
        my $cmd = [ '-httpd', "--stdout=$out", "--stderr=$err", '-W0' ];
-       my $host_port = $http->sockhost.':'.$http->sockport;
+       my $host_port = tcp_host_port($http);
        push @$cmd, "-lhttp://$host_port";
-       my $url = "$host_port/test/all.mbox.gz";
+       my $url = "$host_port/test/$endpoint";
        print STDERR "# CMD ". join(' ', @$cmd). "\n";
        my $env = { PI_CONFIG => $pi_config };
        (start_script($cmd, $env, $rdr), $url);
@@ -53,7 +58,7 @@ my $do_get_all = sub {
        my ($buf, $nr);
        my $bytes = 0;
        my $t0 = now();
-       my ($rd, $pid) = popen_rd([$curl, qw(-HHost:example.com -sSf), $url]);
+       my ($rd, $pid) = popen_rd([$curl, @CURL_OPT, $url]);
        while (1) {
                $nr = sysread($rd, $buf, 65536);
                last if !$nr;