Mercurial > hg > nginx-tests
annotate stream_proxy_complex.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 | 766bcbb632ee |
children | f3ba4c74de31 |
rev | line source |
---|---|
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for stream proxy module with complex value. |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::Stream qw/ stream /; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/stream stream_return/) |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->write_file_expand('nginx.conf', <<'EOF'); |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 stream { |
991
6246d69857cc
Tests: fixed stream_proxy_complex.t when run in parallel.
Sergey Kandaurov <pluknet@nginx.com>
parents:
987
diff
changeset
|
37 upstream %%PORT_8081%% { |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 server 127.0.0.1:8091; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
991
6246d69857cc
Tests: fixed stream_proxy_complex.t when run in parallel.
Sergey Kandaurov <pluknet@nginx.com>
parents:
987
diff
changeset
|
41 upstream %%PORT_8082%% { |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 server 127.0.0.1:8092; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server 127.0.0.1:8093; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server { |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 listen 127.0.0.1:8081; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 listen 127.0.0.1:8082; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 proxy_pass $server_port; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 server { |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 listen 127.0.0.1:8083; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 proxy_pass $server_addr:%%PORT_8093%%; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 server { |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 listen 127.0.0.1:8091; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 listen 127.0.0.1:8092; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 listen 127.0.0.1:8093; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 return $server_port; |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 } |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 EOF |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
992
diff
changeset
|
67 $t->run()->plan(5); |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 ############################################################################### |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
992
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
71 is(stream('127.0.0.1:' . port(8081))->read(), port(8091), 'upstream'); |
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
72 is(stream('127.0.0.1:' . port(8081))->read(), port(8091), 'upstream again'); |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
992
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
74 is(stream('127.0.0.1:' . port(8082))->read(), port(8092), 'upstream 2'); |
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
75 is(stream('127.0.0.1:' . port(8082))->read(), port(8093), 'upstream second'); |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
992
1beb641e21c9
Tests: fixed tests on win32 with stream return module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
991
diff
changeset
|
77 is(stream('127.0.0.1:' . port(8083))->read(), port(8093), 'implicit'); |
987
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 ############################################################################### |