# HG changeset patch # User Maxim Dounin # Date 1359132833 -14400 # Node ID df984d23f9d1ef8ac054849dd76f5cd4bd1a6ffb # Parent 0c9f15938545e7c6ea2402db401c540c88e9a68b Tests: improve fastcgi keepalive tests. On some platforms fastcgi_keepalive.t tests failed due to problems in handling of data split into multiple packets. Harden tests to fail on all platforms by adding more sleeps, and mark them as TODO till underlying problems are fixed. Additionally, add some padding testing. diff --git a/fastcgi_keepalive.t b/fastcgi_keepalive.t --- a/fastcgi_keepalive.t +++ b/fastcgi_keepalive.t @@ -68,16 +68,26 @@ like(http_get('/'), qr/SEE-THIS/, 'fastc like(http_get('/redir'), qr/302/, 'fastcgi redirect'); like(http_get('/'), qr/^request: 3$/m, 'fastcgi third request'); +TODO: { +local $TODO = 'not yet'; + like(http_get('/single'), qr/^connection: 1$/m, 'single connection used'); +} + # New connection to fastcgi application should be established after HEAD # requests since nginx doesn't read whole response (as it doesn't need # body). unlike(http_head('/head'), qr/SEE-THIS/, 'no data in HEAD'); +TODO: { +local $TODO = 'not yet'; + like(http_get('/after'), qr/^connection: 2$/m, 'new connection after HEAD'); +} + ############################################################################### # Simple FastCGI responder implementation. Unlike FCGI and FCGI::Async it's @@ -110,8 +120,11 @@ sub fastcgi_respond($$) { # stdout $h->{socket}->write(pack("CCnnCx", $h->{version}, 6, $h->{id}, - length($body), 0)); + length($body), 8)); $h->{socket}->write($body); + select(undef, undef, undef, 0.1); + $h->{socket}->write(pack("xxxxxxxx")); + select(undef, undef, undef, 0.1); # write some text to stdout and stderr splitted over multiple network # packets to test if we correctly set pipe length in various places @@ -124,7 +137,9 @@ sub fastcgi_respond($$) { $h->{socket}->write($tt . pack("CC", $h->{version}, 7)); select(undef, undef, undef, 0.1); $h->{socket}->write(pack("nnCx", $h->{id}, length($tt), 0)); + select(undef, undef, undef, 0.1); $h->{socket}->write($tt); + select(undef, undef, undef, 0.1); # close stdout $h->{socket}->write(pack("CCnnCx", $h->{version}, 6, $h->{id}, 0, 0)); @@ -133,6 +148,7 @@ sub fastcgi_respond($$) { # end request $h->{socket}->write(pack("CCnnCx", $h->{version}, 3, $h->{id}, 8, 0)); + select(undef, undef, undef, 0.1); $h->{socket}->write(pack("NCxxx", 0, 0)); }