Mercurial > hg > nginx-tests
comparison http_listen.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 | 144c6ce732e4 |
children | e6b20af0be5b |
comparison
equal
deleted
inserted
replaced
1816:5817625792bd | 1817:c045fbb98e9a |
---|---|
36 http { | 36 http { |
37 %%TEST_GLOBALS_HTTP%% | 37 %%TEST_GLOBALS_HTTP%% |
38 | 38 |
39 server { | 39 server { |
40 listen 127.0.0.1:8080; | 40 listen 127.0.0.1:8080; |
41 listen 127.0.0.1:%%PORT_8082%%-%%PORT_8083%%; | 41 listen 127.0.0.1:%%PORT_8182%%-%%PORT_8183%%; |
42 listen %%PORT_8085%%-%%PORT_8086%%; | 42 listen [::1]:%%PORT_8182%%-%%PORT_8183%%; |
43 listen [::1]:%%PORT_8085%%-%%PORT_8086%%; | |
44 server_name localhost; | 43 server_name localhost; |
45 | 44 |
46 location / { | 45 location / { |
47 proxy_pass http://$arg_b/t; | 46 proxy_pass http://$arg_b/t; |
48 } | 47 } |
53 } | 52 } |
54 | 53 |
55 # catch out of range | 54 # catch out of range |
56 | 55 |
57 server { | 56 server { |
58 listen 127.0.0.1:8081; | 57 listen 127.0.0.1:8181; |
59 listen 127.0.0.1:8084; | 58 listen 127.0.0.1:8184; |
60 listen 127.0.0.1:8087; | 59 listen [::1]:%%PORT_8181%%; |
61 listen [::1]:%%PORT_8084%%; | 60 listen [::1]:%%PORT_8184%%; |
62 listen [::1]:%%PORT_8087%%; | |
63 server_name localhost; | 61 server_name localhost; |
64 } | 62 } |
65 } | 63 } |
66 | 64 |
67 EOF | 65 EOF |
68 | 66 |
69 my $p0 = port(8080); my $p3 = port(8083); my $p6 = port(8086); | 67 my $p0 = port(8080); my $p3 = port(8183); |
70 my $p1 = port(8081); my $p4 = port(8084); my $p7 = port(8087); | 68 my $p1 = port(8181); my $p4 = port(8184); |
71 my $p2 = port(8082); my $p5 = port(8085); | 69 my $p2 = port(8182); |
72 | |
73 plan(skip_all => 'listen on wildcard address') | |
74 unless $ENV{TEST_NGINX_UNSAFE}; | |
75 | 70 |
76 plan(skip_all => 'no requested ranges') | 71 plan(skip_all => 'no requested ranges') |
77 if "$p0$p1$p2$p3$p4$p5$p6$p7" ne "80808081808280838084808580868087"; | 72 if "$p2$p3" ne "81828183"; |
78 | 73 |
79 $t->run()->plan(12); | 74 $t->run()->plan(9); |
80 | 75 |
81 ############################################################################### | 76 ############################################################################### |
82 | 77 |
83 like(http_get("/?b=127.0.0.1:$p0"), qr/127.0.0.1:$p0/, 'single'); | 78 like(http_get("/?b=127.0.0.1:$p0"), qr/127.0.0.1:$p0/, 'single'); |
84 unlike(http_get("/?b=127.0.0.1:$p1"), qr/127.0.0.1:$p1/, 'out of range 1'); | 79 unlike(http_get("/?b=127.0.0.1:$p1"), qr/127.0.0.1:$p1/, 'out of range 1'); |
85 like(http_get("/?b=127.0.0.1:$p2"), qr/127.0.0.1:$p2/, 'range 1'); | 80 like(http_get("/?b=127.0.0.1:$p2"), qr/127.0.0.1:$p2/, 'range 1'); |
86 like(http_get("/?b=127.0.0.1:$p3"), qr/127.0.0.1:$p3/, 'range 2'); | 81 like(http_get("/?b=127.0.0.1:$p3"), qr/127.0.0.1:$p3/, 'range 2'); |
87 unlike(http_get("/?b=127.0.0.1:$p4"), qr/127.0.0.$p4/, 'out of range 2'); | 82 unlike(http_get("/?b=127.0.0.1:$p4"), qr/127.0.0.1:$p4/, 'out of range 2'); |
88 like(http_get("/?b=127.0.0.1:$p5"), qr/127.0.0.1:$p5/, 'wildcard range 1'); | |
89 like(http_get("/?b=127.0.0.1:$p6"), qr/127.0.0.1:$p6/, 'wildcard range 2'); | |
90 unlike(http_get("/?b=127.0.0.1:$p7"), qr/127.0.0.1:$p7/, 'out of range 3'); | |
91 | 83 |
92 unlike(http_get("/?b=[::1]:$p4"), qr/::1:$p4/, 'out of range 4'); | 84 unlike(http_get("/?b=[::1]:$p1"), qr/::1:$p1/, 'inet6 out of range 1'); |
93 like(http_get("/?b=[::1]:$p5"), qr/::1:$p5/, 'ipv6 range 1'); | 85 like(http_get("/?b=[::1]:$p2"), qr/::1:$p2/, 'inet6 range 1'); |
94 like(http_get("/?b=[::1]:$p6"), qr/::1:$p6/, 'ipv6 range 2'); | 86 like(http_get("/?b=[::1]:$p3"), qr/::1:$p3/, 'inet6 range 2'); |
95 unlike(http_get("/?b=[::1]:$p7"), qr/::1:$p7/, 'out of range 5'); | 87 unlike(http_get("/?b=[::1]:$p4"), qr/::1:$p4/, 'inet6 out of range 2'); |
96 | 88 |
97 ############################################################################### | 89 ############################################################################### |