comparison fastcgi_request_buffering_chunked.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 http { 43 http {
44 %%TEST_GLOBALS_HTTP%% 44 %%TEST_GLOBALS_HTTP%%
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 client_header_buffer_size 1k; 50 client_header_buffer_size 1k;
51 fastcgi_request_buffering off; 51 fastcgi_request_buffering off;
52 fastcgi_param REQUEST_URI $request_uri; 52 fastcgi_param REQUEST_URI $request_uri;
53 53
54 location / { 54 location / {
55 client_body_buffer_size 2k; 55 client_body_buffer_size 2k;
56 fastcgi_pass 127.0.0.1:8081; 56 fastcgi_pass 127.0.0.1:%%PORT_1%%;
57 } 57 }
58 location /single { 58 location /single {
59 client_body_in_single_buffer on; 59 client_body_in_single_buffer on;
60 fastcgi_pass 127.0.0.1:8081; 60 fastcgi_pass 127.0.0.1:%%PORT_1%%;
61 } 61 }
62 location /preread { 62 location /preread {
63 fastcgi_pass 127.0.0.1:8082; 63 fastcgi_pass 127.0.0.1:%%PORT_2%%;
64 } 64 }
65 location /error_page { 65 location /error_page {
66 fastcgi_pass 127.0.0.1:8081; 66 fastcgi_pass 127.0.0.1:%%PORT_1%%;
67 error_page 404 /404; 67 error_page 404 /404;
68 fastcgi_intercept_errors on; 68 fastcgi_intercept_errors on;
69 } 69 }
70 location /404 { 70 location /404 {
71 return 200 "$request_body\n"; 71 return 200 "$request_body\n";
74 } 74 }
75 75
76 EOF 76 EOF
77 77
78 $t->run_daemon(\&fastcgi_daemon); 78 $t->run_daemon(\&fastcgi_daemon);
79 $t->run()->waitforsocket('127.0.0.1:8081'); 79 $t->run()->waitforsocket('127.0.0.1:' . port(1));
80 80
81 ############################################################################### 81 ###############################################################################
82 82
83 like(http_get('/'), qr/X-Body: \x0d\x0a?/ms, 'no body'); 83 like(http_get('/'), qr/X-Body: \x0d\x0a?/ms, 'no body');
84 84
101 like(http_get_body('/', '0123456789' x 128, '0123456789' x 512, '0123456789', 101 like(http_get_body('/', '0123456789' x 128, '0123456789' x 512, '0123456789',
102 'foobar'), qr/X-Body: foobar\x0d?$/ms, 'body pipelined 2'); 102 'foobar'), qr/X-Body: foobar\x0d?$/ms, 'body pipelined 2');
103 103
104 # interactive tests 104 # interactive tests
105 105
106 my $s = get_body('/preread', 8082); 106 my $s = get_body('/preread', port(2));
107 ok($s, 'no preread'); 107 ok($s, 'no preread');
108 108
109 SKIP: { 109 SKIP: {
110 skip 'no preread failed', 3 unless $s; 110 skip 'no preread failed', 3 unless $s;
111 111
114 114
115 like($s->{http_end}(), qr/200 OK/, 'no preread - response'); 115 like($s->{http_end}(), qr/200 OK/, 'no preread - response');
116 116
117 } 117 }
118 118
119 $s = get_body('/preread', 8082, '01234'); 119 $s = get_body('/preread', port(2), '01234');
120 ok($s, 'preread'); 120 ok($s, 'preread');
121 121
122 SKIP: { 122 SKIP: {
123 skip 'preread failed', 3 unless $s; 123 skip 'preread failed', 3 unless $s;
124 124
127 127
128 like($s->{http_end}(), qr/200 OK/, 'preread - response'); 128 like($s->{http_end}(), qr/200 OK/, 'preread - response');
129 129
130 } 130 }
131 131
132 $s = get_body('/preread', 8082, '01234', many => 1); 132 $s = get_body('/preread', port(2), '01234', many => 1);
133 ok($s, 'chunks'); 133 ok($s, 'chunks');
134 134
135 SKIP: { 135 SKIP: {
136 skip 'chunks failed', 3 unless $s; 136 skip 'chunks failed', 3 unless $s;
137 137
384 sub log2c { Test::Nginx::log_core('||', @_); } 384 sub log2c { Test::Nginx::log_core('||', @_); }
385 385
386 ############################################################################### 386 ###############################################################################
387 387
388 sub fastcgi_daemon { 388 sub fastcgi_daemon {
389 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5); 389 my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
390 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, 390 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
391 $socket); 391 $socket);
392 392
393 my $count; 393 my $count;
394 my ($body, $buf); 394 my ($body, $buf);
406 print "Status: 404 Not Found" . CRLF . CRLF; 406 print "Status: 404 Not Found" . CRLF . CRLF;
407 next; 407 next;
408 } 408 }
409 409
410 print <<EOF; 410 print <<EOF;
411 Location: http://127.0.0.1:8080/redirect 411 Location: http://localhost/redirect
412 Content-Type: text/html 412 Content-Type: text/html
413 X-Body: $body 413 X-Body: $body
414 414
415 SEE-THIS 415 SEE-THIS
416 $count 416 $count