X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=xt%2Fperf-nntpd.t;h=85db036c78997063bc3ef7a538086c155e955612;hb=60848de2194f0c518bd660860e9458dd765d0a3e;hp=f73afacc75ea27bb896d132033c5d067a829ddc5;hpb=95bdac7f09c69036efed537a4d03d5bdd2ae4eb6;p=public-inbox.git
diff --git a/xt/perf-nntpd.t b/xt/perf-nntpd.t
index f73afacc..85db036c 100644
--- a/xt/perf-nntpd.t
+++ b/xt/perf-nntpd.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2020 all contributors
+# Copyright (C) 2018-2021 all contributors
# License: AGPL-3.0+
use strict;
use warnings;
@@ -8,12 +8,15 @@ use PublicInbox::Inbox;
use Net::NNTP;
my $inboxdir = $ENV{GIANT_INBOX_DIR} // $ENV{GIANT_PI_DIR};
plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless defined($inboxdir);
-my ($host_port, $group, %opts, $s, $td, $tmp_obj);
+my ($host_port, $group, $s, $td, $tmp_obj);
use PublicInbox::TestCommon;
if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
($host_port, $group) = ($1, $2);
$host_port .= ":119" unless index($host_port, ':') > 0;
+ my $six = substr($host_port, 0, 1) eq '[' ? '6' : '';
+ my $cls = "IO::Socket::INET$six";
+ $cls->new(Proto => 'tcp', Timeout => 1, PeerAddr => $host_port);
} else {
$group = 'inbox.test.perf.nntpd';
my $ibx = { inboxdir => $inboxdir, newsgroup => $group };
@@ -34,18 +37,11 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) {
}
my $sock = tcp_server();
- ok($sock, 'sock created');
my $cmd = [ '-nntpd', '-W0' ];
$td = start_script($cmd, { PI_CONFIG => $pi_config }, { 3 => $sock });
- $host_port = $sock->sockhost . ':' . $sock->sockport;
+ $host_port = tcp_host_port($sock);
+ $s = tcp_connect($sock);
}
-%opts = (
- PeerAddr => $host_port,
- Proto => 'tcp',
- Timeout => 1,
-);
-$s = IO::Socket::INET->new(%opts);
-$s->autoflush(1);
my $buf = $s->getline;
like($buf, qr/\A201 .* ready - post via email\r\n/s, 'got greeting');