diff proxy.t @ 1079:cbc8641a204e

Tests: fixed "proxy connect timeout" http tests. Previously, proxy connection hadn't been established before delay so proxy_connect_timeout had no chances to break connection. Now used backend with delay greater than proxy_connect_timeout value.
author Andrey Zelenkov <zelenkov@nginx.com>
date Mon, 21 Nov 2016 02:07:21 +0300
parents e4d5e7afb6e0
children 41690e007ad8
line wrap: on
line diff
--- a/proxy.t
+++ b/proxy.t
@@ -56,6 +56,11 @@ http {
             proxy_read_timeout 1s;
             proxy_connect_timeout 2s;
         }
+
+        location /timeout {
+            proxy_pass http://127.0.0.1:8081;
+            proxy_connect_timeout 2s;
+        }
     }
 }
 
@@ -89,11 +94,7 @@ ok(http_get("/var?b=[::]"), 'proxy with 
 
 }
 
-my $s = http('', start => 1);
-
-sleep 3;
-
-like(http_get('/', socket => $s), qr/200 OK/, 'proxy connect timeout');
+like(http_get('/timeout'), qr/200 OK/, 'proxy connect timeout');
 
 ###############################################################################
 
@@ -142,6 +143,15 @@ EOF
 			select undef, undef, undef, 0.1;
 			print $client 'AND-THIS';
 
+		} elsif ($uri eq '/timeout') {
+			sleep 3;
+
+			print $client <<"EOF";
+HTTP/1.1 200 OK
+Connection: close
+
+EOF
+
 		} else {
 
 			print $client <<"EOF";