annotate upstream_ip_hash_ipv6.t @ 1434:fc8341cf92a3

Tests: removed ngx_parse_inet6_url() "::" test from proxy.t. It results in WSAEADDRNOTAVAIL on win32, be the connection errors detected, which leads to connect() alert. On other systems, connect() is successful but it uses the default port (80), which is out of documented ports range.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 24 Jan 2019 17:05:04 +0300
parents f7f387086278
children 40e5f2a0a238
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1429
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Maxim Dounin
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Sergey Kandaurov
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5 # (C) Nginx, Inc.
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7 # Tests for upstream ip_hash balancer with IPv6 and unix sockets.
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9 ###############################################################################
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use warnings;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12 use strict;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14 use Test::More;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16 use Socket qw/ CRLF /;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 BEGIN { use FindBin; chdir($FindBin::Bin); }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 use lib 'lib';
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 use Test::Nginx;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 ###############################################################################
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 select STDERR; $| = 1;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 select STDOUT; $| = 1;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 my $t = Test::Nginx->new()->has(qw/http proxy upstream_ip_hash realip unix/)
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 ->write_file_expand('nginx.conf', <<'EOF')->run();
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 %%TEST_GLOBALS%%
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 daemon off;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 events {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 http {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 %%TEST_GLOBALS_HTTP%%
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 upstream u {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 ip_hash;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 server 127.0.0.1:8081;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 server 127.0.0.1:8082;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 server {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 listen 127.0.0.1:8080;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 server_name localhost;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 add_header X-IP $remote_addr always;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 location / {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 set_real_ip_from 127.0.0.0/8;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 proxy_pass http://u;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 location /unix {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 proxy_pass http://unix:%%TESTDIR%%/unix.sock;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 proxy_set_header X-Real-IP $http_x_real_ip;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 location /ipv6 {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 proxy_pass http://[::1]:%%PORT_8080%%;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 proxy_set_header X-Real-IP $http_x_real_ip;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 server {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 listen unix:%%TESTDIR%%/unix.sock;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 listen [::1]:%%PORT_8080%%;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 server_name localhost;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 location / {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 set_real_ip_from unix:;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 set_real_ip_from ::1;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 proxy_pass http://u;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 location /unix/none {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 proxy_pass http://u;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 server {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 listen 127.0.0.1:8081;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 listen 127.0.0.1:8082;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 server_name localhost;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 location / {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 add_header X-Port $server_port always;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 EOF
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 plan(skip_all => 'no 127.0.0.1 on host')
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 if http_get('/') !~ /X-IP: 127.0.0.1/m;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101 $t->try_run('no inet6 support')->plan(4);
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103 ###############################################################################
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105 my @ports = my ($port1, $port2) = (port(8081), port(8082));
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 is(many('/unix', 30), "$port1: 15, $port2: 15", 'ip_hash realip via unix');
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 is(many('/ipv6', 30), "$port1: 15, $port2: 15", 'ip_hash realip via ipv6');
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 is(many_ip6('/', 30), "$port1: 15, $port2: 15", 'ip_hash ipv6');
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111 like(many('/unix/none', 30), qr/($port1|$port2): 30/, 'ip_hash unix');
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
112
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113 ###############################################################################
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115 sub many {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116 my ($uri, $count) = @_;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117 my %ports;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
118
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
119 for my $i (1 .. $count) {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120 my $req = "GET $uri HTTP/1.0" . CRLF
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121 . "X-Real-IP: 127.0.$i.2" . CRLF . CRLF;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123 if (http($req) =~ /X-Port: (\d+)/) {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 $ports{$1} = 0 unless defined $ports{$1};
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125 $ports{$1}++;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 my @keys = map { my $p = $_; grep { $p == $_ } keys %ports } @ports;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130 return join ', ', map { $_ . ": " . $ports{$_} } @keys;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 sub many_ip6 {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 my ($uri, $count) = @_;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135 my %ports;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137 for my $i (1 .. $count) {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 my $req = "GET $uri HTTP/1.0" . CRLF
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139 . "X-Real-IP: ::$i" . CRLF . CRLF;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 if (http($req) =~ /X-Port: (\d+)/) {
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 $ports{$1} = 0 unless defined $ports{$1};
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
143 $ports{$1}++;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 my @keys = map { my $p = $_; grep { $p == $_ } keys %ports } @ports;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 return join ', ', map { $_ . ": " . $ports{$_} } @keys;
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149 }
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150
f7f387086278 Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 ###############################################################################