comparison proxy_redirect.t @ 952:e9064d691790

Tests: converted tests to run in parallel.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 21 Jun 2016 16:39:13 +0300
parents ba992cfdc606
children 882267679006
comparison
equal deleted inserted replaced
951:9361c7eddfc1 952:e9064d691790
35 35
36 http { 36 http {
37 %%TEST_GLOBALS_HTTP%% 37 %%TEST_GLOBALS_HTTP%%
38 38
39 server { 39 server {
40 listen 127.0.0.1:8080; 40 listen 127.0.0.1:%%PORT_0%%;
41 server_name localhost; 41 server_name localhost;
42 42
43 location / { 43 location / {
44 set $some_var var_here; 44 set $some_var var_here;
45 45
46 proxy_pass http://127.0.0.1:8081; 46 proxy_pass http://127.0.0.1:%%PORT_1%%;
47 47
48 proxy_redirect http://127.0.0.1:8081/var_in_second/ /$some_var/; 48 proxy_redirect http://127.0.0.1:%%PORT_1%%/var_in_second/
49 proxy_redirect http://127.0.0.1:8081/$some_var/ /replaced/; 49 /$some_var/;
50 proxy_redirect http://127.0.0.1:%%PORT_1%%/$some_var/ /replaced/;
50 51
51 proxy_redirect ~^(.+)81/regex_w_([^/]+) $180/$2/test.html; 52 proxy_redirect ~^(.+)/regex_w_([^/]+) $1/$2/test.html;
52 proxy_redirect ~*re+gexp? /replaced/test.html; 53 proxy_redirect ~*re+gexp? /replaced/test.html;
53 } 54 }
54 55
55 location /expl_default/ { 56 location /expl_default/ {
56 proxy_pass http://127.0.0.1:8081/replace_this/; 57 proxy_pass http://127.0.0.1:%%PORT_1%%/replace_this/;
57 proxy_redirect wrong wrong; 58 proxy_redirect wrong wrong;
58 proxy_redirect default; 59 proxy_redirect default;
59 } 60 }
60 61
61 location /impl_default/ { 62 location /impl_default/ {
62 proxy_pass http://127.0.0.1:8081/replace_this/; 63 proxy_pass http://127.0.0.1:%%PORT_1%%/replace_this/;
63 } 64 }
64 65
65 location /off/ { 66 location /off/ {
66 proxy_pass http://127.0.0.1:8081/; 67 proxy_pass http://127.0.0.1:%%PORT_1%%/;
67 proxy_redirect off; 68 proxy_redirect off;
68 69
69 location /off/on/ { 70 location /off/on/ {
70 proxy_pass http://127.0.0.1:8081; 71 proxy_pass http://127.0.0.1:%%PORT_1%%;
71 proxy_redirect http://127.0.0.1:8081/off/ /; 72 proxy_redirect http://127.0.0.1:%%PORT_1%%/off/ /;
72 73
73 location /off/on/on/ { 74 location /off/on/on/ {
74 proxy_pass http://127.0.0.1:8081; 75 proxy_pass http://127.0.0.1:%%PORT_1%%;
75 } 76 }
76 } 77 }
77 } 78 }
78 } 79 }
79 80
80 server { 81 server {
81 listen 127.0.0.1:8081; 82 listen 127.0.0.1:%%PORT_1%%;
82 server_name localhost; 83 server_name localhost;
83 84
84 location / { 85 location / {
85 add_header Refresh "7; url=http://127.0.0.1:8081$uri"; 86 add_header Refresh "7; url=http://127.0.0.1:%%PORT_1%%$uri";
86 return http://127.0.0.1:8081$uri; 87 return http://127.0.0.1:%%PORT_1%%$uri;
87 } 88 }
88 } 89 }
89 } 90 }
90 91
91 EOF 92 EOF
92 93
93 $t->run(); 94 $t->run();
94 95
95 ############################################################################### 96 ###############################################################################
96 97
98 my ($p0, $p1) = (port(0), port(1));
97 99
98 is(http_get_location('http://127.0.0.1:8080/impl_default/test.html'), 100 is(http_get_location("http://127.0.0.1:$p0/impl_default/test.html"),
99 'http://127.0.0.1:8080/impl_default/test.html', 'implicit default'); 101 "http://127.0.0.1:$p0/impl_default/test.html", 'implicit default');
100 is(http_get_location('http://127.0.0.1:8080/expl_default/test.html'), 102 is(http_get_location("http://127.0.0.1:$p0/expl_default/test.html"),
101 'http://127.0.0.1:8080/expl_default/test.html', 'explicit default'); 103 "http://127.0.0.1:$p0/expl_default/test.html", 'explicit default');
102 104
103 is(http_get_refresh('http://127.0.0.1:8080/impl_default/test.html'), 105 is(http_get_refresh("http://127.0.0.1:$p0/impl_default/test.html"),
104 '7; url=/impl_default/test.html', 'implicit default (refresh)'); 106 '7; url=/impl_default/test.html', 'implicit default (refresh)');
105 is(http_get_refresh('http://127.0.0.1:8080/expl_default/test.html'), 107 is(http_get_refresh("http://127.0.0.1:$p0/expl_default/test.html"),
106 '7; url=/expl_default/test.html', 'explicit default (refresh)'); 108 '7; url=/expl_default/test.html', 'explicit default (refresh)');
107 109
108 is(http_get_location('http://127.0.0.1:8080/var_in_second/test.html'), 110 is(http_get_location("http://127.0.0.1:$p0/var_in_second/test.html"),
109 'http://127.0.0.1:8080/var_here/test.html', 'variable in second arg'); 111 "http://127.0.0.1:$p0/var_here/test.html", 'variable in second arg');
110 is(http_get_refresh('http://127.0.0.1:8080/var_in_second/test.html'), 112 is(http_get_refresh("http://127.0.0.1:$p0/var_in_second/test.html"),
111 '7; url=/var_here/test.html', 'variable in second arg (refresh)'); 113 '7; url=/var_here/test.html', 'variable in second arg (refresh)');
112 114
113 is(http_get_location('http://127.0.0.1:8080/off/test.html'), 115 is(http_get_location("http://127.0.0.1:$p0/off/test.html"),
114 'http://127.0.0.1:8081/test.html', 'rewrite off'); 116 "http://127.0.0.1:$p1/test.html", 'rewrite off');
115 is(http_get_location('http://127.0.0.1:8080/off/on/test.html'), 117 is(http_get_location("http://127.0.0.1:$p0/off/on/test.html"),
116 'http://127.0.0.1:8080/on/test.html', 'rewrite off overwrite'); 118 "http://127.0.0.1:$p0/on/test.html", 'rewrite off overwrite');
117 119
118 is(http_get_location('http://127.0.0.1:8080/off/on/on/test.html'), 120 is(http_get_location("http://127.0.0.1:$p0/off/on/on/test.html"),
119 'http://127.0.0.1:8080/on/on/test.html', 'rewrite inheritance'); 121 "http://127.0.0.1:$p0/on/on/test.html", 'rewrite inheritance');
120 122
121 is(http_get_location('http://127.0.0.1:8080/var_here/test.html'), 123 is(http_get_location("http://127.0.0.1:$p0/var_here/test.html"),
122 'http://127.0.0.1:8080/replaced/test.html', 'variable in first arg'); 124 "http://127.0.0.1:$p0/replaced/test.html", 'variable in first arg');
123 is(http_get_refresh('http://127.0.0.1:8080/var_here/test.html'), 125 is(http_get_refresh("http://127.0.0.1:$p0/var_here/test.html"),
124 '7; url=/replaced/test.html', 'variable in first arg (refresh)'); 126 '7; url=/replaced/test.html', 'variable in first arg (refresh)');
125 127
126 is(http_get_location('http://127.0.0.1:8080/ReeegEX/test.html'), 128 is(http_get_location("http://127.0.0.1:$p0/ReeegEX/test.html"),
127 'http://127.0.0.1:8080/replaced/test.html', 'caseless regexp'); 129 "http://127.0.0.1:$p0/replaced/test.html", 'caseless regexp');
128 is(http_get_location('http://127.0.0.1:8080/regex_w_captures/test.html'), 130 is(http_get_location("http://127.0.0.1:$p0/regex_w_captures/test.html"),
129 'http://127.0.0.1:8080/captures/test.html', 'regexp w/captures'); 131 "http://127.0.0.1:$p1/captures/test.html", 'regexp w/captures');
130 132
131 is(http_get_refresh('http://127.0.0.1:8080/ReeegEX/test.html'), 133 is(http_get_refresh("http://127.0.0.1:$p0/ReeegEX/test.html"),
132 '7; url=/replaced/test.html', 'caseless regexp (refresh)'); 134 '7; url=/replaced/test.html', 'caseless regexp (refresh)');
133 is(http_get_refresh('http://127.0.0.1:8080/regex_w_captures/test.html'), 135 is(http_get_refresh("http://127.0.0.1:$p0/regex_w_captures/test.html"),
134 '7; url=http://127.0.0.1:8080/captures/test.html', 136 "7; url=http://127.0.0.1:$p1/captures/test.html",
135 'regexp w/captures (refresh)'); 137 'regexp w/captures (refresh)');
136 138
137 ############################################################################### 139 ###############################################################################
138 140
139 sub http_get_location { 141 sub http_get_location {