Mercurial > hg > nginx-tests
comparison stream_proxy_protocol_ssl.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 | f02dac68d584 |
children | 882267679006 |
comparison
equal
deleted
inserted
replaced
951:9361c7eddfc1 | 952:e9064d691790 |
---|---|
41 stream { | 41 stream { |
42 proxy_ssl on; | 42 proxy_ssl on; |
43 proxy_protocol on; | 43 proxy_protocol on; |
44 | 44 |
45 server { | 45 server { |
46 listen 127.0.0.1:8080; | 46 listen 127.0.0.1:%%PORT_0%%; |
47 proxy_pass 127.0.0.1:8081; | 47 proxy_pass 127.0.0.1:%%PORT_1%%; |
48 } | 48 } |
49 | 49 |
50 server { | 50 server { |
51 listen 127.0.0.1:8082; | 51 listen 127.0.0.1:%%PORT_2%%; |
52 proxy_pass 127.0.0.1:8083; | 52 proxy_pass 127.0.0.1:%%PORT_3%%; |
53 proxy_protocol off; | 53 proxy_protocol off; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 EOF | 57 EOF |
72 . "-out '$d/$name.crt' -keyout '$d/$name.key' " | 72 . "-out '$d/$name.crt' -keyout '$d/$name.key' " |
73 . ">>$d/openssl.out 2>&1") == 0 | 73 . ">>$d/openssl.out 2>&1") == 0 |
74 or die "Can't create certificate for $name: $!\n"; | 74 or die "Can't create certificate for $name: $!\n"; |
75 } | 75 } |
76 | 76 |
77 $t->run_daemon(\&stream_daemon_ssl, 8081, path => $d, pp => 1); | 77 $t->run_daemon(\&stream_daemon_ssl, port(1), path => $d, pp => 1); |
78 $t->run_daemon(\&stream_daemon_ssl, 8083, path => $d, pp => 0); | 78 $t->run_daemon(\&stream_daemon_ssl, port(3), path => $d, pp => 0); |
79 $t->try_run('no stream proxy_protocol')->plan(2); | 79 $t->try_run('no stream proxy_protocol')->plan(2); |
80 | 80 |
81 $t->waitforsocket('127.0.0.1:8081'); | 81 $t->waitforsocket('127.0.0.1:' . port(1)); |
82 $t->waitforsocket('127.0.0.1:8083'); | 82 $t->waitforsocket('127.0.0.1:' . port(3)); |
83 | 83 |
84 ############################################################################### | 84 ############################################################################### |
85 | 85 |
86 my %r = pp_get('test'); | 86 my $dp = port(0); |
87 is($r{'data'}, "PROXY TCP4 127.0.0.1 127.0.0.1 $r{'sp'} 8080" . CRLF . 'test', | 87 |
88 my %r = pp_get('test', '127.0.0.1:' . $dp); | |
89 is($r{'data'}, "PROXY TCP4 127.0.0.1 127.0.0.1 $r{'sp'} $dp" . CRLF . 'test', | |
88 'protocol on'); | 90 'protocol on'); |
89 | 91 |
90 %r = pp_get('test', '127.0.0.1:8082'); | 92 %r = pp_get('test', '127.0.0.1:' . port(2)); |
91 is($r{'data'}, 'test', 'protocol off'); | 93 is($r{'data'}, 'test', 'protocol off'); |
92 | 94 |
93 ############################################################################### | 95 ############################################################################### |
94 | 96 |
95 sub pp_get { | 97 sub pp_get { |
103 | 105 |
104 sub getconn { | 106 sub getconn { |
105 my $peer = shift; | 107 my $peer = shift; |
106 my $s = IO::Socket::INET->new( | 108 my $s = IO::Socket::INET->new( |
107 Proto => 'tcp', | 109 Proto => 'tcp', |
108 PeerAddr => $peer || '127.0.0.1:8080' | 110 PeerAddr => $peer |
109 ) | 111 ) |
110 or die "Can't connect to nginx: $!\n"; | 112 or die "Can't connect to nginx: $!\n"; |
111 | 113 |
112 return $s; | 114 return $s; |
113 } | 115 } |