Mercurial > hg > nginx-tests
annotate upstream_ip_hash_ipv6.t @ 1817:c045fbb98e9a
Tests: revised tests for listen port ranges.
Renumbered testing ports to get more chance to execute when run in parallel.
Relaxed condition to skip tests only when the port range is out of sequence.
Adjacent port numbers out of a specified range aren't crucial to skip tests:
if not in sequence, statistically this will be caught in subsequent runs.
Unsafe tests that use wildcard addresses are moved to a separate file.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 23 Dec 2022 19:20:50 +0400 |
parents | 40e5f2a0a238 |
children |
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/) |
1497
40e5f2a0a238
Tests: upstream_ip_hash_ipv6.t startup fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1429
diff
changeset
|
29 ->write_file_expand('nginx.conf', <<'EOF'); |
1429
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 |
1497
40e5f2a0a238
Tests: upstream_ip_hash_ipv6.t startup fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1429
diff
changeset
|
98 $t->try_run('no inet6 support'); |
40e5f2a0a238
Tests: upstream_ip_hash_ipv6.t startup fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1429
diff
changeset
|
99 |
1429
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 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
|
101 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
|
102 |
1497
40e5f2a0a238
Tests: upstream_ip_hash_ipv6.t startup fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1429
diff
changeset
|
103 $t->plan(4); |
1429
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 ############################################################################### |
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 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
|
108 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 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
|
110 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
|
111 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 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
|
113 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
|
114 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 ############################################################################### |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 sub many { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 my ($uri, $count) = @_; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 my %ports; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 for my $i (1 .. $count) { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 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
|
123 . "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
|
124 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 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
|
126 $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
|
127 $ports{$1}++; |
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 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 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
|
132 return join ', ', map { $_ . ": " . $ports{$_} } @keys; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 sub many_ip6 { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 my ($uri, $count) = @_; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 my %ports; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 for my $i (1 .. $count) { |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 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
|
141 . "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
|
142 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 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
|
144 $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
|
145 $ports{$1}++; |
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 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 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
|
150 return join ', ', map { $_ . ": " . $ports{$_} } @keys; |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 } |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
f7f387086278
Tests: upstream ip_hash tests with IPv6 and unix sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 ############################################################################### |