Mercurial > hg > nginx-tests
comparison stream_proxy_protocol.t @ 952:e9064d691790
Tests: converted tests to run in parallel.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 21 Jun 2016 16:39:13 +0300 |
parents | 77359b849cd5 |
children | 882267679006 |
comparison
equal
deleted
inserted
replaced
951:9361c7eddfc1 | 952:e9064d691790 |
---|---|
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:8080; | 43 listen 127.0.0.1:%%PORT_0%%; |
44 proxy_pass 127.0.0.1:8081; | 44 proxy_pass 127.0.0.1:%%PORT_1%%; |
45 } | 45 } |
46 | 46 |
47 server { | 47 server { |
48 listen 127.0.0.1:8082; | 48 listen 127.0.0.1:%%PORT_2%%; |
49 proxy_pass 127.0.0.1:8081; | 49 proxy_pass 127.0.0.1:%%PORT_1%%; |
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:8081'); | 58 $t->waitforsocket('127.0.0.1:' . port(1)); |
59 | 59 |
60 ############################################################################### | 60 ############################################################################### |
61 | 61 |
62 my $s = stream(); | 62 my $dp = port(0); |
63 my $s = stream('127.0.0.1:' . $dp); | |
63 my $data = $s->io('close'); | 64 my $data = $s->io('close'); |
64 my $sp = $s->sockport(); | 65 my $sp = $s->sockport(); |
65 is($data, "PROXY TCP4 127.0.0.1 127.0.0.1 $sp 8080${CRLF}close", 'protocol on'); | 66 is($data, "PROXY TCP4 127.0.0.1 127.0.0.1 $sp $dp${CRLF}close", 'protocol on'); |
66 | 67 |
67 is(stream('127.0.0.1:8082')->io('close'), 'close', 'protocol off'); | 68 is(stream('127.0.0.1:' . port(2))->io('close'), 'close', 'protocol off'); |
68 | 69 |
69 ############################################################################### | 70 ############################################################################### |
70 | 71 |
71 sub stream_daemon { | 72 sub stream_daemon { |
72 my $server = IO::Socket::INET->new( | 73 my $server = IO::Socket::INET->new( |
73 Proto => 'tcp', | 74 Proto => 'tcp', |
74 LocalAddr => '127.0.0.1:8081', | 75 LocalAddr => '127.0.0.1:' . port(1), |
75 Listen => 5, | 76 Listen => 5, |
76 Reuse => 1 | 77 Reuse => 1 |
77 ) | 78 ) |
78 or die "Can't create listening socket: $!\n"; | 79 or die "Can't create listening socket: $!\n"; |
79 | 80 |