Mercurial > hg > nginx-tests
comparison stream_proxy_protocol.t @ 974:882267679006
Tests: simplified parallel modifications in tests.
Mail tests were simplified in c227348453db.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 12 Jul 2016 17:39:03 +0300 |
parents | e9064d691790 |
children | 196d33c2bb45 |
comparison
equal
deleted
inserted
replaced
973:7d7aef8b9f3a | 974:882267679006 |
---|---|
38 | 38 |
39 stream { | 39 stream { |
40 proxy_protocol on; | 40 proxy_protocol on; |
41 | 41 |
42 server { | 42 server { |
43 listen 127.0.0.1:%%PORT_0%%; | 43 listen 127.0.0.1:8080; |
44 proxy_pass 127.0.0.1:%%PORT_1%%; | 44 proxy_pass 127.0.0.1:8081; |
45 } | 45 } |
46 | 46 |
47 server { | 47 server { |
48 listen 127.0.0.1:%%PORT_2%%; | 48 listen 127.0.0.1:8082; |
49 proxy_pass 127.0.0.1:%%PORT_1%%; | 49 proxy_pass 127.0.0.1:8081; |
50 proxy_protocol off; | 50 proxy_protocol off; |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 EOF | 54 EOF |
55 | 55 |
56 $t->run_daemon(\&stream_daemon); | 56 $t->run_daemon(\&stream_daemon); |
57 $t->try_run('no stream proxy_protocol')->plan(2); | 57 $t->try_run('no stream proxy_protocol')->plan(2); |
58 $t->waitforsocket('127.0.0.1:' . port(1)); | 58 $t->waitforsocket('127.0.0.1:' . port(8081)); |
59 | 59 |
60 ############################################################################### | 60 ############################################################################### |
61 | 61 |
62 my $dp = port(0); | 62 my $dp = port(8080); |
63 my $s = stream('127.0.0.1:' . $dp); | 63 my $s = stream('127.0.0.1:' . $dp); |
64 my $data = $s->io('close'); | 64 my $data = $s->io('close'); |
65 my $sp = $s->sockport(); | 65 my $sp = $s->sockport(); |
66 is($data, "PROXY TCP4 127.0.0.1 127.0.0.1 $sp $dp${CRLF}close", 'protocol on'); | 66 is($data, "PROXY TCP4 127.0.0.1 127.0.0.1 $sp $dp${CRLF}close", 'protocol on'); |
67 | 67 |
68 is(stream('127.0.0.1:' . port(2))->io('close'), 'close', 'protocol off'); | 68 is(stream('127.0.0.1:' . port(8082))->io('close'), 'close', 'protocol off'); |
69 | 69 |
70 ############################################################################### | 70 ############################################################################### |
71 | 71 |
72 sub stream_daemon { | 72 sub stream_daemon { |
73 my $server = IO::Socket::INET->new( | 73 my $server = IO::Socket::INET->new( |
74 Proto => 'tcp', | 74 Proto => 'tcp', |
75 LocalAddr => '127.0.0.1:' . port(1), | 75 LocalAddr => '127.0.0.1:' . port(8081), |
76 Listen => 5, | 76 Listen => 5, |
77 Reuse => 1 | 77 Reuse => 1 |
78 ) | 78 ) |
79 or die "Can't create listening socket: $!\n"; | 79 or die "Can't create listening socket: $!\n"; |
80 | 80 |