Mercurial > hg > nginx-tests
comparison stream_proxy_complex.t @ 987:d6a2c7bcdc4c
Tests: stream proxy tests with complex value.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 21 Jul 2016 13:49:17 +0300 |
parents | |
children | 6246d69857cc |
comparison
equal
deleted
inserted
replaced
986:99f93be57416 | 987:d6a2c7bcdc4c |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for stream proxy module with complex value. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::Stream qw/ stream /; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
26 my $t = Test::Nginx->new()->has(qw/stream stream_return/) | |
27 ->write_file_expand('nginx.conf', <<'EOF'); | |
28 | |
29 %%TEST_GLOBALS%% | |
30 | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 stream { | |
37 upstream 8081 { | |
38 server 127.0.0.1:8091; | |
39 } | |
40 | |
41 upstream 8082 { | |
42 server 127.0.0.1:8092; | |
43 server 127.0.0.1:8093; | |
44 } | |
45 | |
46 server { | |
47 listen 127.0.0.1:8081; | |
48 listen 127.0.0.1:8082; | |
49 proxy_pass $server_port; | |
50 } | |
51 | |
52 server { | |
53 listen 127.0.0.1:8083; | |
54 proxy_pass $server_addr:%%PORT_8093%%; | |
55 } | |
56 | |
57 server { | |
58 listen 127.0.0.1:8091; | |
59 listen 127.0.0.1:8092; | |
60 listen 127.0.0.1:8093; | |
61 return $server_port; | |
62 } | |
63 } | |
64 | |
65 EOF | |
66 | |
67 $t->try_run('no stream proxy_pass with complex value')->plan(5); | |
68 | |
69 ############################################################################### | |
70 | |
71 is(stream('127.0.0.1:' . port(8081))->io('foo'), port(8091), 'upstream'); | |
72 is(stream('127.0.0.1:' . port(8081))->io('foo'), port(8091), 'upstream again'); | |
73 | |
74 is(stream('127.0.0.1:' . port(8082))->io('foo'), port(8092), 'upstream 2'); | |
75 is(stream('127.0.0.1:' . port(8082))->io('foo'), port(8093), 'upstream second'); | |
76 | |
77 is(stream('127.0.0.1:' . port(8083))->io('foo'), port(8093), 'implicit'); | |
78 | |
79 ############################################################################### |