# HG changeset patch # User Sergey Kandaurov # Date 1474282714 -10800 # Node ID 38ed3dda327995e5ea6bee64f5b3b850aa64d19d # Parent c0accd6fab6c8bef9fb70b8d351fc1ede1a2fdca Tests: $upstream_addr tests in hash module with no live upstream. diff --git a/upstream_hash.t b/upstream_hash.t --- a/upstream_hash.t +++ b/upstream_hash.t @@ -22,7 +22,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http proxy rewrite upstream_hash/)->plan(11); +my $t = Test::Nginx->new()->has(qw/http proxy rewrite upstream_hash/)->plan(13); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -115,6 +115,14 @@ http { location /cbad { proxy_pass http://cbad; } + location /busy { + proxy_pass http://bad/busy; + add_header X-IP $upstream_addr always; + } + location /cbusy { + proxy_pass http://cbad/busy; + add_header X-IP $upstream_addr always; + } location /pnu { proxy_pass http://u/; proxy_next_upstream http_502; @@ -139,6 +147,10 @@ http { } return 204; } + + location /busy { + return 444; + } } server { @@ -184,6 +196,17 @@ is(@res, 20, 'all hashed peers - bad'); @res = grep { $_ == $p1 } iter('/cbad', 20); is(@res, 20, 'all hashed peers - bad consistent'); +like(http_get('/busy'), qr/X-IP: 127.0.0.1:$p1, bad/, + 'upstream name - busy'); + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.11.5'); + +like(http_get('/cbusy'), qr/X-IP: 127.0.0.1:$p1, cbad/, + 'upstream name - busy consistent'); + +} + ############################################################################### # Returns true if two arrays follow consistency, i.e., they may only differ