comparison fastcgi_request_buffering.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
41 41
42 http { 42 http {
43 %%TEST_GLOBALS_HTTP%% 43 %%TEST_GLOBALS_HTTP%%
44 44
45 server { 45 server {
46 listen 127.0.0.1:8080; 46 listen 127.0.0.1:%%PORT_0%%;
47 server_name localhost; 47 server_name localhost;
48 48
49 client_header_buffer_size 1k; 49 client_header_buffer_size 1k;
50 fastcgi_request_buffering off; 50 fastcgi_request_buffering off;
51 fastcgi_param REQUEST_URI $request_uri; 51 fastcgi_param REQUEST_URI $request_uri;
52 fastcgi_param CONTENT_LENGTH $content_length; 52 fastcgi_param CONTENT_LENGTH $content_length;
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, 10); 106 my $s = get_body('/preread', port(2), 10);
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, 10, '01234'); 119 $s = get_body('/preread', port(2), 10, '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
339 sub log2c { Test::Nginx::log_core('||', @_); } 339 sub log2c { Test::Nginx::log_core('||', @_); }
340 340
341 ############################################################################### 341 ###############################################################################
342 342
343 sub fastcgi_daemon { 343 sub fastcgi_daemon {
344 my $socket = FCGI::OpenSocket('127.0.0.1:8081', 5); 344 my $socket = FCGI::OpenSocket('127.0.0.1:' . port(1), 5);
345 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, 345 my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV,
346 $socket); 346 $socket);
347 347
348 my $count; 348 my $count;
349 my $body; 349 my $body;
356 print "Status: 404 Not Found" . CRLF . CRLF; 356 print "Status: 404 Not Found" . CRLF . CRLF;
357 next; 357 next;
358 } 358 }
359 359
360 print <<EOF; 360 print <<EOF;
361 Location: http://127.0.0.1:8080/redirect 361 Location: http://localhost/redirect
362 Content-Type: text/html 362 Content-Type: text/html
363 X-Body: $body 363 X-Body: $body
364 364
365 SEE-THIS 365 SEE-THIS
366 $count 366 $count