Mercurial > hg > nginx-tests
annotate stream_access.t @ 1269:a32ef40ab48a
Tests: corrected proxy_cache_error.t comment.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 11 Jan 2018 19:58:20 +0300 |
parents | fcd65708672d |
children | f3ba4c74de31 |
rev | line source |
---|---|
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
2 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Zelenkov |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
5 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
6 # Tests for stream access module. |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
7 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
9 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
11 use strict; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
12 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
14 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
16 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
816
77359b849cd5
Tests: stream package.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
726
diff
changeset
|
19 use Test::Nginx::Stream qw/ stream /; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
20 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
22 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
25 |
1170
cf14cfe9ec8c
Tests: dropped obsolete ipv6 prerequisite.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/stream stream_access unix/); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
27 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
29 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
31 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
33 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
34 events { |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
35 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
36 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
37 stream { |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
38 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 listen 127.0.0.1:8082; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
40 proxy_pass [::1]:%%PORT_8080%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
41 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
42 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
43 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
44 listen 127.0.0.1:8083; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
45 proxy_pass unix:%%TESTDIR%%/unix.sock.0; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
46 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
47 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
48 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
49 listen 127.0.0.1:8085; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
50 proxy_pass [::1]:%%PORT_8081%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
51 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
52 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
53 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
54 listen 127.0.0.1:8086; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
55 proxy_pass unix:%%TESTDIR%%/unix.sock.1; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
56 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
57 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
58 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
59 listen 127.0.0.1:8088; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
60 proxy_pass [::1]:%%PORT_8082%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
61 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
62 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
63 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
64 listen 127.0.0.1:8089; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
65 proxy_pass unix:%%TESTDIR%%/unix.sock.2; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
66 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
67 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
68 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
69 listen 127.0.0.1:8091; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
70 proxy_pass [::1]:%%PORT_8083%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
71 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
72 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
73 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
74 listen 127.0.0.1:8092; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
75 proxy_pass unix:%%TESTDIR%%/unix.sock.3; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
76 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
77 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
78 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
79 listen 127.0.0.1:8094; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
80 proxy_pass [::1]:%%PORT_8084%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
81 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
82 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
83 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
84 listen 127.0.0.1:8095; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
85 proxy_pass unix:%%TESTDIR%%/unix.sock.4; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
86 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
87 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
88 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
89 listen 127.0.0.1:8097; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
90 proxy_pass [::1]:%%PORT_8085%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
91 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
92 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
93 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
94 listen 127.0.0.1:8098; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
95 proxy_pass unix:%%TESTDIR%%/unix.sock.5; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
96 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
97 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
98 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
99 listen 127.0.0.1:8081; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
100 listen [::1]:%%PORT_8080%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
101 listen unix:%%TESTDIR%%/unix.sock.0; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
102 proxy_pass 127.0.0.1:8080; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
103 allow all; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
104 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
105 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
106 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
107 listen 127.0.0.1:8084; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
108 listen [::1]:%%PORT_8081%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
109 listen unix:%%TESTDIR%%/unix.sock.1; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
110 proxy_pass 127.0.0.1:8080; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
111 deny all; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
112 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
113 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
114 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
115 listen 127.0.0.1:8087; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
116 listen [::1]:%%PORT_8082%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
117 listen unix:%%TESTDIR%%/unix.sock.2; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
118 proxy_pass 127.0.0.1:8080; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
119 allow unix:; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
120 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
121 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
122 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
123 listen 127.0.0.1:8090; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
124 listen [::1]:%%PORT_8083%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
125 listen unix:%%TESTDIR%%/unix.sock.3; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
126 proxy_pass 127.0.0.1:8080; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
127 deny 127.0.0.1; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
128 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
129 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
130 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
131 listen 127.0.0.1:8093; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
132 listen [::1]:%%PORT_8084%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
133 listen unix:%%TESTDIR%%/unix.sock.4; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
134 proxy_pass 127.0.0.1:8080; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
135 deny ::1; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
136 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
137 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
138 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
139 listen 127.0.0.1:8096; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
140 listen [::1]:%%PORT_8085%%; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
141 listen unix:%%TESTDIR%%/unix.sock.5; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
142 proxy_pass 127.0.0.1:8080; |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
143 deny unix:; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
144 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
145 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
146 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
147 EOF |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
148 |
1190
fcd65708672d
Tests: let tests pass on travis-ci VMs with disabled IPv6 loopback.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1171
diff
changeset
|
149 $t->try_run('no inet6 support')->plan(18); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
150 $t->run_daemon(\&stream_daemon); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
151 $t->waitforsocket('127.0.0.1:' . port(8080)); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
152 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
153 ############################################################################### |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
154 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
155 my $str = 'SEE-THIS'; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
156 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
157 # allow all |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
158 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
159 is(stream('127.0.0.1:' . port(8081))->io($str), $str, 'inet allow all'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
160 is(stream('127.0.0.1:' . port(8082))->io($str), $str, 'inet6 allow all'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
161 is(stream('127.0.0.1:' . port(8083))->io($str), $str, 'unix allow all'); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
162 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
163 # deny all |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
164 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
165 is(stream('127.0.0.1:' . port(8084))->io($str), '', 'inet deny all'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
166 is(stream('127.0.0.1:' . port(8085))->io($str), '', 'inet6 deny all'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
167 is(stream('127.0.0.1:' . port(8086))->io($str), '', 'unix deny all'); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
168 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
169 # allow unix |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
170 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
171 is(stream('127.0.0.1:' . port(8087))->io($str), $str, 'inet allow unix'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
172 is(stream('127.0.0.1:' . port(8088))->io($str), $str, 'inet6 allow unix'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
173 is(stream('127.0.0.1:' . port(8089))->io($str), $str, 'unix allow unix'); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
174 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
175 # deny inet |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
176 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
177 is(stream('127.0.0.1:' . port(8090))->io($str), '', 'inet deny inet'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
178 is(stream('127.0.0.1:' . port(8091))->io($str), $str, 'inet6 deny inet'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
179 is(stream('127.0.0.1:' . port(8092))->io($str), $str, 'unix deny inet'); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
180 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
181 # deny inet6 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
182 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
183 is(stream('127.0.0.1:' . port(8093))->io($str), $str, 'inet deny inet6'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
184 is(stream('127.0.0.1:' . port(8094))->io($str), '', 'inet6 deny inet6'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
185 is(stream('127.0.0.1:' . port(8095))->io($str), $str, 'unix deny inet6'); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
186 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
187 # deny unix |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
188 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
189 is(stream('127.0.0.1:' . port(8096))->io($str), $str, 'inet deny unix'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
190 is(stream('127.0.0.1:' . port(8097))->io($str), $str, 'inet6 deny unix'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
191 is(stream('127.0.0.1:' . port(8098))->io($str), '', 'unix deny unix'); |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
192 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
193 ############################################################################### |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
194 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
195 sub stream_daemon { |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
196 my $server = IO::Socket::INET->new( |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
197 Proto => 'tcp', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
198 LocalAddr => '127.0.0.1:' . port(8080), |
631
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
199 Listen => 5, |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
200 Reuse => 1 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
201 ) |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
202 or die "Can't create listening socket: $!\n"; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
203 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
204 local $SIG{PIPE} = 'IGNORE'; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
205 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
206 while (my $client = $server->accept()) { |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
207 $client->autoflush(1); |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
208 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
209 log2c("(new connection $client)"); |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
210 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
211 $client->sysread(my $buffer, 65536) or next; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
212 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
213 log2i("$client $buffer"); |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
214 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
215 log2o("$client $buffer"); |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
216 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
217 $client->syswrite($buffer); |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
218 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
219 close $client; |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
220 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
221 } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
222 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
223 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
224 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
225 sub log2c { Test::Nginx::log_core('||', @_); } |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
226 |
fca0079e0aab
Tests: stream access tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
227 ############################################################################### |