changeset 87:f2d09159a8f3

Tests: proxy_store leaving temporary files bug test. It shouldn't even if client closed prematurely connection.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 26 Apr 2009 03:54:40 +0400
parents 2dbe4ecdd254
children a31296de1987
files lib/Test/Nginx.pm proxy-store.t
diffstat 2 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -260,6 +260,7 @@ sub http($;%) {
 		$s->print($request);
 		local $/;
 		select undef, undef, undef, $extra{sleep} if $extra{sleep};
+		return '' if $extra{aborted};
 		$reply = $s->getline();
 		log_in($reply);
 		alarm(0);
--- a/proxy-store.t
+++ b/proxy-store.t
@@ -9,7 +9,7 @@
 use warnings;
 use strict;
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 
 BEGIN { use FindBin; chdir($FindBin::Bin); }
 
@@ -51,9 +51,16 @@ http {
             proxy_pass http://127.0.0.1:8080/index-nostore.html;
             proxy_store on;
         }
+        location /big {
+            proxy_pass http://127.0.0.1:8080/index-big.html;
+            proxy_store on;
+        }
         location /index-nostore.html {
             add_header  X-Accel-Expires  0;
         }
+        location /index-big.html {
+            limit_rate  200k;
+        }
     }
 }
 
@@ -61,6 +68,7 @@ EOF
 
 $t->write_file('index.html', 'SEE-THIS');
 $t->write_file('index-nostore.html', 'SEE-THIS');
+$t->write_file('index-big.html', 'x' x (100 << 10));
 $t->run();
 
 ###############################################################################
@@ -78,4 +86,14 @@ ok(!-e $t->testdir() . '/nostore', 'resu
 
 ok(scalar @{[ glob $t->testdir() . '/proxy_temp/*' ]} == 0, 'no temp files');
 
+TODO: {
+local $TODO = 'patch under review';
+
+http_get('/big', aborted => 1, sleep => 0.1);
+sleep(1);
+
+ok(scalar @{[ glob $t->testdir() . '/proxy_temp/*' ]} == 0,
+	'no temp files after aborted request');
+}
+
 ###############################################################################