Mercurial > hg > nginx-tests
annotate stream_proxy_bind.t @ 1542:451e787aad76
Tests: reworked libgd version detection.
The "libgd-config" binary is deprecated in recent versions and may not exist
or have unexpected output. More, it may not present within older versions,
as well, if installed separately, which previously broke test assumptions.
The fix is change the fallback to skip tests. In addition, recent Perl GD
module (2.57) started to export libgd version, which is now also consulted.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 13 Jan 2020 18:15:35 +0300 |
parents | 882267679006 |
children | f3ba4c74de31 |
rev | line source |
---|---|
622
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
2 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Zelenkov |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
5 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
6 # Test for stream proxy_bind directive. |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
7 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
9 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
11 use strict; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
12 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
14 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
16 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
19 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
21 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
24 |
626
5f9dfe85a1f2
Tests: skipped proxy_bind tests on win32.
Sergey Kandaurov <pluknet@nginx.com>
parents:
622
diff
changeset
|
25 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
622
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
26 plan(skip_all => '127.0.0.2 local address required') |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
27 unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.2' ); |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
28 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
29 my $t = Test::Nginx->new()->has(qw/http proxy stream/)->plan(1) |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
30 ->write_file_expand('nginx.conf', <<'EOF'); |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
31 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
32 %%TEST_GLOBALS%% |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
33 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
34 daemon off; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
35 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
36 events { |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
37 } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
38 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
39 stream { |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
40 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 listen 127.0.0.1:8081; |
622
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
42 proxy_bind 127.0.0.2; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
43 proxy_pass 127.0.0.1:8082; |
622
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
44 } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
45 } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
46 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
47 http { |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
48 %%TEST_GLOBALS_HTTP%% |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
49 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
50 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
51 listen 127.0.0.1:8080; |
622
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
52 server_name localhost; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
53 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
54 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
55 proxy_pass http://127.0.0.1:8081; |
622
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
56 } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
57 } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
58 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
59 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
60 listen 127.0.0.1:8082; |
622
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
61 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
62 location / { |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
63 add_header X-IP $remote_addr; |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
64 } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
65 } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
66 } |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
67 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
68 EOF |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
69 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
70 $t->write_file('index.html', ''); |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
71 $t->run(); |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
72 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
73 ############################################################################### |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
74 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
75 like(http_get('/'), qr/X-IP: 127.0.0.2/, 'bind'); |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
76 |
b241c3c0119b
Tests: stream proxy_bind test.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
diff
changeset
|
77 ############################################################################### |