Mercurial > hg > nginx-tests
comparison proxy_upgrade.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 | 6bb1f2ccd386 |
children | 882267679006 |
comparison
equal
deleted
inserted
replaced
951:9361c7eddfc1 | 952:e9064d691790 |
---|---|
42 | 42 |
43 log_format test "$bytes_sent $body_bytes_sent"; | 43 log_format test "$bytes_sent $body_bytes_sent"; |
44 access_log %%TESTDIR%%/cc.log test; | 44 access_log %%TESTDIR%%/cc.log test; |
45 | 45 |
46 server { | 46 server { |
47 listen 127.0.0.1:8080; | 47 listen 127.0.0.1:%%PORT_0%%; |
48 server_name localhost; | 48 server_name localhost; |
49 | 49 |
50 location / { | 50 location / { |
51 proxy_pass http://127.0.0.1:8081; | 51 proxy_pass http://127.0.0.1:%%PORT_1%%; |
52 proxy_http_version 1.1; | 52 proxy_http_version 1.1; |
53 proxy_set_header Upgrade $http_upgrade; | 53 proxy_set_header Upgrade $http_upgrade; |
54 proxy_set_header Connection "Upgrade"; | 54 proxy_set_header Connection "Upgrade"; |
55 proxy_read_timeout 2s; | 55 proxy_read_timeout 2s; |
56 send_timeout 2s; | 56 send_timeout 2s; |
63 my $d = $t->testdir(); | 63 my $d = $t->testdir(); |
64 | 64 |
65 $t->run_daemon(\&upgrade_fake_daemon); | 65 $t->run_daemon(\&upgrade_fake_daemon); |
66 $t->run(); | 66 $t->run(); |
67 | 67 |
68 $t->waitforsocket('127.0.0.1:8081') | 68 $t->waitforsocket('127.0.0.1:' . port(1)) |
69 or die "Can't start test backend"; | 69 or die "Can't start test backend"; |
70 | 70 |
71 ############################################################################### | 71 ############################################################################### |
72 | 72 |
73 # establish connection | 73 # establish connection |
145 sub upgrade_connect { | 145 sub upgrade_connect { |
146 my (%opts) = @_; | 146 my (%opts) = @_; |
147 | 147 |
148 my $s = IO::Socket::INET->new( | 148 my $s = IO::Socket::INET->new( |
149 Proto => 'tcp', | 149 Proto => 'tcp', |
150 PeerAddr => '127.0.0.1:8080', | 150 PeerAddr => '127.0.0.1:' . port(0), |
151 ) | 151 ) |
152 or die "Can't connect to nginx: $!\n"; | 152 or die "Can't connect to nginx: $!\n"; |
153 | 153 |
154 # send request, $h->to_string | 154 # send request, $h->to_string |
155 | 155 |
248 ############################################################################### | 248 ############################################################################### |
249 | 249 |
250 sub upgrade_fake_daemon { | 250 sub upgrade_fake_daemon { |
251 my $server = IO::Socket::INET->new( | 251 my $server = IO::Socket::INET->new( |
252 Proto => 'tcp', | 252 Proto => 'tcp', |
253 LocalAddr => '127.0.0.1:8081', | 253 LocalAddr => '127.0.0.1:' . port(1), |
254 Listen => 5, | 254 Listen => 5, |
255 Reuse => 1 | 255 Reuse => 1 |
256 ) | 256 ) |
257 or die "Can't create listening socket: $!\n"; | 257 or die "Can't create listening socket: $!\n"; |
258 | 258 |