changeset 269:970bb423e59f

Tests: proxy_next_upstream tests in body.t, body_chunked.t.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 12 Mar 2013 20:07:25 +0400
parents 8dac281ff522
children f857180657c9
files body.t body_chunked.t
diffstat 2 files changed, 46 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/body.t
+++ b/body.t
@@ -22,7 +22,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(11);
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(12);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -36,6 +36,11 @@ events {
 http {
     %%TEST_GLOBALS_HTTP%%
 
+    upstream u {
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8080 backup;
+    }
+
     server {
         listen       127.0.0.1:8080;
         server_name  localhost;
@@ -68,6 +73,9 @@ http {
         location /discard {
             return 200 "TEST\n";
         }
+        location /next {
+            proxy_pass http://u/;
+        }
     }
 
     server {
@@ -78,6 +86,15 @@ http {
             return 200 "TEST\n";
         }
     }
+
+    server {
+        listen       127.0.0.1:8082;
+        server_name  localhost;
+
+        location / {
+            return 444;
+        }
+    }
 }
 
 EOF
@@ -122,6 +139,11 @@ like(http_get_body('/discard', '01234567
 like(http_get_body('/small', '0123456789'),
 	qr/X-Body: 0123456789\x0d?$/ms, 'small body in file only');
 
+# proxy_next_upstream
+
+like(http_get_body('/next', '0123456789'),
+	qr/X-Body: 0123456789\x0d?$/ms, 'body next upstream');
+
 ###############################################################################
 
 sub read_body_file {
--- a/body_chunked.t
+++ b/body_chunked.t
@@ -22,7 +22,7 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(9);
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(10);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -36,6 +36,11 @@ events {
 http {
     %%TEST_GLOBALS_HTTP%%
 
+    upstream u {
+        server 127.0.0.1:8082;
+        server 127.0.0.1:8080 backup;
+    }
+
     server {
         listen       127.0.0.1:8080;
         server_name  localhost;
@@ -64,6 +69,9 @@ http {
         location /discard {
             return 200 "TEST\n";
         }
+        location /next {
+            proxy_pass http://u/;
+        }
     }
 
     server {
@@ -74,6 +82,15 @@ http {
             return 200 "TEST\n";
         }
     }
+
+    server {
+        listen       127.0.0.1:8082;
+        server_name  localhost;
+
+        location / {
+            return 444;
+        }
+    }
 }
 
 EOF
@@ -114,6 +131,11 @@ like(http_get_body('/discard', '01234567
 	'0123456789', 'foobar'), qr/(TEST.*){4}/ms,
 	'chunked body discard 2');
 
+# proxy_next_upstream
+
+like(http_get_body('/next', '0123456789'),
+        qr/X-Body: 0123456789\x0d?$/ms, 'body chunked next upstream');
+
 }
 
 ###############################################################################