comparison fastcgi_keepalive.t @ 251:df984d23f9d1

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 25 Jan 2013 20:53:53 +0400
parents 0c9f15938545
children 9f0ed4d54ae3
comparison
equal deleted inserted replaced
250:0c9f15938545 251:df984d23f9d1
66 66
67 like(http_get('/'), qr/SEE-THIS/, 'fastcgi request'); 67 like(http_get('/'), qr/SEE-THIS/, 'fastcgi request');
68 like(http_get('/redir'), qr/302/, 'fastcgi redirect'); 68 like(http_get('/redir'), qr/302/, 'fastcgi redirect');
69 like(http_get('/'), qr/^request: 3$/m, 'fastcgi third request'); 69 like(http_get('/'), qr/^request: 3$/m, 'fastcgi third request');
70 70
71 TODO: {
72 local $TODO = 'not yet';
73
71 like(http_get('/single'), qr/^connection: 1$/m, 'single connection used'); 74 like(http_get('/single'), qr/^connection: 1$/m, 'single connection used');
75
76 }
72 77
73 # New connection to fastcgi application should be established after HEAD 78 # New connection to fastcgi application should be established after HEAD
74 # requests since nginx doesn't read whole response (as it doesn't need 79 # requests since nginx doesn't read whole response (as it doesn't need
75 # body). 80 # body).
76 81
77 unlike(http_head('/head'), qr/SEE-THIS/, 'no data in HEAD'); 82 unlike(http_head('/head'), qr/SEE-THIS/, 'no data in HEAD');
78 83
84 TODO: {
85 local $TODO = 'not yet';
86
79 like(http_get('/after'), qr/^connection: 2$/m, 'new connection after HEAD'); 87 like(http_get('/after'), qr/^connection: 2$/m, 'new connection after HEAD');
88
89 }
80 90
81 ############################################################################### 91 ###############################################################################
82 92
83 # Simple FastCGI responder implementation. Unlike FCGI and FCGI::Async it's 93 # Simple FastCGI responder implementation. Unlike FCGI and FCGI::Async it's
84 # able to count connections. 94 # able to count connections.
108 sub fastcgi_respond($$) { 118 sub fastcgi_respond($$) {
109 my ($h, $body) = @_; 119 my ($h, $body) = @_;
110 120
111 # stdout 121 # stdout
112 $h->{socket}->write(pack("CCnnCx", $h->{version}, 6, $h->{id}, 122 $h->{socket}->write(pack("CCnnCx", $h->{version}, 6, $h->{id},
113 length($body), 0)); 123 length($body), 8));
114 $h->{socket}->write($body); 124 $h->{socket}->write($body);
125 select(undef, undef, undef, 0.1);
126 $h->{socket}->write(pack("xxxxxxxx"));
127 select(undef, undef, undef, 0.1);
115 128
116 # write some text to stdout and stderr splitted over multiple network 129 # write some text to stdout and stderr splitted over multiple network
117 # packets to test if we correctly set pipe length in various places 130 # packets to test if we correctly set pipe length in various places
118 131
119 my $tt = "test text, just for test"; 132 my $tt = "test text, just for test";
122 length($tt . $tt), 0) . $tt); 135 length($tt . $tt), 0) . $tt);
123 select(undef, undef, undef, 0.1); 136 select(undef, undef, undef, 0.1);
124 $h->{socket}->write($tt . pack("CC", $h->{version}, 7)); 137 $h->{socket}->write($tt . pack("CC", $h->{version}, 7));
125 select(undef, undef, undef, 0.1); 138 select(undef, undef, undef, 0.1);
126 $h->{socket}->write(pack("nnCx", $h->{id}, length($tt), 0)); 139 $h->{socket}->write(pack("nnCx", $h->{id}, length($tt), 0));
140 select(undef, undef, undef, 0.1);
127 $h->{socket}->write($tt); 141 $h->{socket}->write($tt);
142 select(undef, undef, undef, 0.1);
128 143
129 # close stdout 144 # close stdout
130 $h->{socket}->write(pack("CCnnCx", $h->{version}, 6, $h->{id}, 0, 0)); 145 $h->{socket}->write(pack("CCnnCx", $h->{version}, 6, $h->{id}, 0, 0));
131 146
132 select(undef, undef, undef, 0.1); 147 select(undef, undef, undef, 0.1);
133 148
134 # end request 149 # end request
135 $h->{socket}->write(pack("CCnnCx", $h->{version}, 3, $h->{id}, 8, 0)); 150 $h->{socket}->write(pack("CCnnCx", $h->{version}, 3, $h->{id}, 8, 0));
151 select(undef, undef, undef, 0.1);
136 $h->{socket}->write(pack("NCxxx", 0, 0)); 152 $h->{socket}->write(pack("NCxxx", 0, 0));
137 } 153 }
138 154
139 sub fastcgi_test_daemon { 155 sub fastcgi_test_daemon {
140 my $server = IO::Socket::INET->new( 156 my $server = IO::Socket::INET->new(