Tests: explicit peer port in stream tests now required. Notably, this eliminates extra port acquire for the default port number in cases when it was not actually used.
diff --git a/lib/Test/Nginx/Stream.pm b/lib/Test/Nginx/Stream.pm index 4fb9806..b05486b 100644 --- a/lib/Test/Nginx/Stream.pm +++ b/lib/Test/Nginx/Stream.pm
@@ -41,7 +41,6 @@ $self->{_socket} = IO::Socket::INET->new( Proto => "tcp", PeerAddr => '127.0.0.1', - PeerPort => port(8080), @_ ) or die "Can't connect to nginx: $!\n";
diff --git a/stream_error_log.t b/stream_error_log.t index 903e56c..068ca48 100644 --- a/stream_error_log.t +++ b/stream_error_log.t
@@ -88,7 +88,7 @@ ############################################################################### -stream()->io('data'); +stream('127.0.0.1:' . port(8080))->io('data'); # error_log levels
diff --git a/stream_geo.t b/stream_geo.t index 0cb6bfd..eace495 100644 --- a/stream_geo.t +++ b/stream_geo.t
@@ -223,7 +223,7 @@ ############################################################################### -my %data = stream()->read() =~ /(\w+):(\w+)/g; +my %data = stream('127.0.0.1:' . port(8080))->read() =~ /(\w+):(\w+)/g; is($data{geo}, 'loopback', 'geo'); is($data{geo_include}, 'loopback', 'geo include'); is($data{geo_delete}, 'world', 'geo delete');
diff --git a/stream_geo_binary.t b/stream_geo_binary.t index 92d703c..a3fdd21 100644 --- a/stream_geo_binary.t +++ b/stream_geo_binary.t
@@ -65,7 +65,7 @@ ############################################################################### -my %data = stream()->read() =~ /(\w+):(\w+)/g; +my %data = stream('127.0.0.1:' . port(8080))->read() =~ /(\w+):(\w+)/g; is($data{geo_base_create}, 'loopback', 'geo binary base create'); is($data{geo_base_include}, 'loopback', 'geo binary base include');
diff --git a/stream_geo_ipv6.t b/stream_geo_ipv6.t index 04a73b0..f9d6ee5 100644 --- a/stream_geo_ipv6.t +++ b/stream_geo_ipv6.t
@@ -90,7 +90,7 @@ ############################################################################### -my %data = stream()->read() =~ /(\w+):(\w+)/g; +my %data = stream('127.0.0.1:' . port(8080))->read() =~ /(\w+):(\w+)/g; is($data{geo}, 'loopback', 'geo ipv6'); is($data{geo_delete}, 'world', 'geo ipv6 delete'); is($data{geo_var}, 'default', 'geo ipv6 from variable');
diff --git a/stream_geoip.t b/stream_geoip.t index 0b1c6cb..bef3840 100644 --- a/stream_geoip.t +++ b/stream_geoip.t
@@ -178,7 +178,8 @@ sub stream_pp { my ($ip) = @_; my $type = ($ip =~ ':' ? 'TCP6' : 'TCP4'); - return stream()->io("PROXY $type $ip 127.0.0.1 8080 8080${CRLF}"); + return stream('127.0.0.1:' . port(8080)) + ->io("PROXY $type $ip 127.0.0.1 8080 8080${CRLF}"); } sub pack_node {
diff --git a/stream_proxy.t b/stream_proxy.t index 9e98797..ebf1237 100644 --- a/stream_proxy.t +++ b/stream_proxy.t
@@ -50,14 +50,14 @@ ############################################################################### -my $s = stream(); +my $s = stream('127.0.0.1:' . port(8080)); is($s->io('foo1', length => 4), 'bar1', 'proxy connection'); is($s->io('foo3', length => 4), 'bar3', 'proxy connection again'); is($s->io('close'), 'close', 'proxy connection close'); is($s->io('test'), '', 'proxy connection closed'); -$s = stream(); +$s = stream('127.0.0.1:' . port(8080)); sleep 3;
diff --git a/stream_split_clients.t b/stream_split_clients.t index 6bee1d2..2dbdc7f 100644 --- a/stream_split_clients.t +++ b/stream_split_clients.t
@@ -65,7 +65,7 @@ my %dist; for (1 .. $count) { - if (my $data = stream()->read()) { + if (my $data = stream('127.0.0.1:' . port(8080))->read()) { $dist{$data} = 0 unless defined $data; $dist{$data}++; }
diff --git a/stream_ssl_preread.t b/stream_ssl_preread.t index fc4c42a..1a9d71f 100644 --- a/stream_ssl_preread.t +++ b/stream_ssl_preread.t
@@ -159,7 +159,8 @@ is(get_ssl('', 8081), $p3, 'no sni'); is(get_ssl('foo', 8082), $p3, 'preread off'); is(get_ssl('foo', 8083), undef, 'preread buffer full'); -is(stream()->io('x' x 1000), "127.0.0.1:$p3", 'not a handshake'); +is(stream('127.0.0.1:' . port(8080))->io('x' x 1000), "127.0.0.1:$p3", + 'not a handshake'); # ticket #1317
diff --git a/stream_ssl_variables.t b/stream_ssl_variables.t index 88b0731..031d54e 100644 --- a/stream_ssl_variables.t +++ b/stream_ssl_variables.t
@@ -96,7 +96,7 @@ my ($s, $ssl); -is(stream()->read(), ':::', 'no ssl'); +is(stream('127.0.0.1:' . port(8080))->read(), ':::', 'no ssl'); ($s, $ssl) = get_ssl_socket(port(8081)); like(Net::SSLeay::read($ssl), qr/^\.:(\w{64})?:[\w-]+:(TLS|SSL)v(\d|\.)+$/,
diff --git a/stream_ssl_verify_client.t b/stream_ssl_verify_client.t index e129417..dd3cc30 100644 --- a/stream_ssl_verify_client.t +++ b/stream_ssl_verify_client.t
@@ -115,7 +115,7 @@ TODO: { todo_skip 'leaves coredump', 1 unless $t->has_version('1.11.9'); -is(stream()->read(), ':', 'plain connection'); +is(stream('127.0.0.1:' . port(8080))->read(), ':', 'plain connection'); }
diff --git a/stream_udp_upstream_least_conn.t b/stream_udp_upstream_least_conn.t index b04d55e..2c17108 100644 --- a/stream_udp_upstream_least_conn.t +++ b/stream_udp_upstream_least_conn.t
@@ -66,7 +66,7 @@ my @sockets; for (1 .. 2) { - my $s = dgram(); + my $s = dgram('127.0.0.1:' . port(8080)); $s->write('w'); push @sockets, $s; } @@ -82,7 +82,7 @@ my (%ports); for (1 .. $count) { - if (dgram()->io('.') =~ /(\d+)/) { + if (dgram('127.0.0.1:' . port(8080))->io('.') =~ /(\d+)/) { $ports{$1} = 0 unless defined $ports{$1}; $ports{$1}++; }
diff --git a/stream_upstream_least_conn.t b/stream_upstream_least_conn.t index 47158bc..929dfd1 100644 --- a/stream_upstream_least_conn.t +++ b/stream_upstream_least_conn.t
@@ -65,7 +65,7 @@ my @sockets; for (1 .. 2) { - my $s = stream(); + my $s = stream('127.0.0.1:' . port(8080)); $s->write('w'); push @sockets, $s; } @@ -81,7 +81,7 @@ my (%ports); for (1 .. $count) { - if (stream()->io('.') =~ /(\d+)/) { + if (stream('127.0.0.1:' . port(8080))->io('.') =~ /(\d+)/) { $ports{$1} = 0 unless defined $ports{$1}; $ports{$1}++; }
diff --git a/stream_variables.t b/stream_variables.t index f93dda8..0afa55e 100644 --- a/stream_variables.t +++ b/stream_variables.t
@@ -81,7 +81,8 @@ ############################################################################### chomp(my $hostname = lc `hostname`); -like(stream()->read(), qr/^\d+:[\d.]+:$hostname:\d+:0$/, 'vars'); +like(stream('127.0.0.1:' . port(8080))->read(), + qr/^\d+:[\d.]+:$hostname:\d+:0$/, 'vars'); my $dport = port(8081); my $s = stream("127.0.0.1:$dport");