comparison proxy_websocket.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
45 45
46 http { 46 http {
47 %%TEST_GLOBALS_HTTP%% 47 %%TEST_GLOBALS_HTTP%%
48 48
49 server { 49 server {
50 listen 127.0.0.1:8080; 50 listen 127.0.0.1:%%PORT_0%%;
51 server_name localhost; 51 server_name localhost;
52 52
53 location / { 53 location / {
54 proxy_pass http://127.0.0.1:8081; 54 proxy_pass http://127.0.0.1:%%PORT_1%%;
55 proxy_http_version 1.1; 55 proxy_http_version 1.1;
56 proxy_set_header Upgrade $http_upgrade; 56 proxy_set_header Upgrade $http_upgrade;
57 proxy_set_header Connection "Upgrade"; 57 proxy_set_header Connection "Upgrade";
58 proxy_read_timeout 2s; 58 proxy_read_timeout 2s;
59 send_timeout 2s; 59 send_timeout 2s;
64 EOF 64 EOF
65 65
66 $t->run_daemon(\&websocket_fake_daemon); 66 $t->run_daemon(\&websocket_fake_daemon);
67 $t->run(); 67 $t->run();
68 68
69 $t->waitforsocket('127.0.0.1:8081') 69 $t->waitforsocket('127.0.0.1:' . port(1))
70 or die "Can't start test backend"; 70 or die "Can't start test backend";
71 71
72 ############################################################################### 72 ###############################################################################
73 73
74 # establish websocket connection 74 # establish websocket connection
123 sub websocket_connect { 123 sub websocket_connect {
124 my ($message) = @_; 124 my ($message) = @_;
125 125
126 my $s = IO::Socket::INET->new( 126 my $s = IO::Socket::INET->new(
127 Proto => 'tcp', 127 Proto => 'tcp',
128 PeerAddr => '127.0.0.1:8080' 128 PeerAddr => '127.0.0.1:' . port(0)
129 ) 129 )
130 or die "Can't connect to nginx: $!\n"; 130 or die "Can't connect to nginx: $!\n";
131 131
132 my $h = Protocol::WebSocket::Handshake::Client->new( 132 my $h = Protocol::WebSocket::Handshake::Client->new(
133 url => 'ws://localhost'); 133 url => 'ws://localhost');
208 ############################################################################### 208 ###############################################################################
209 209
210 sub websocket_fake_daemon { 210 sub websocket_fake_daemon {
211 my $server = IO::Socket::INET->new( 211 my $server = IO::Socket::INET->new(
212 Proto => 'tcp', 212 Proto => 'tcp',
213 LocalAddr => '127.0.0.1:8081', 213 LocalAddr => '127.0.0.1:' . port(1),
214 Listen => 5, 214 Listen => 5,
215 Reuse => 1 215 Reuse => 1
216 ) 216 )
217 or die "Can't create listening socket: $!\n"; 217 or die "Can't create listening socket: $!\n";
218 218