Skip to content

Commit af8dbef

Browse files
committed
added (passing) test cases for using nginx variables in redis_pass, which requires variables_in_redis_pass.patch for ngx_redis 0.3.6.
1 parent 73bc7a9 commit af8dbef

File tree

2 files changed

+129
-2
lines changed

2 files changed

+129
-2
lines changed

t/redis.t

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $ENV{TEST_NGINX_REDIS_PORT} ||= 6379;
1313
#no_long_string();
1414
no_shuffle();
1515

16-
log_level('warn');
16+
#log_level('warn');
1717
run_tests();
1818

1919
__DATA__
@@ -125,3 +125,123 @@ hiya
125125
--- no_error_log
126126
[error]
127127
128+
129+
130+
=== TEST 4: flush all - cluster
131+
--- config
132+
location /flush {
133+
redis2_query flushall;
134+
redis2_pass 127.0.0.1:$TEST_NGINX_REDIS_PORT;
135+
}
136+
--- response_headers
137+
Content-Type: text/plain
138+
!Content-Length
139+
--- request
140+
GET /flush
141+
--- response_body eval: "+OK\r\n"
142+
--- no_error_log
143+
[error]
144+
145+
146+
147+
=== TEST 5: basic fetch (cache miss) - cluster
148+
--- timeout: 3
149+
--- http_config
150+
upstream foo {
151+
server 127.0.0.1:$TEST_NGINX_REDIS_PORT;
152+
}
153+
--- config
154+
location /foo {
155+
default_type text/css;
156+
157+
set $key $uri;
158+
set_escape_uri $escaped_key $key;
159+
#srcache_fetch GET /redis $key;
160+
srcache_store POST /redis2 key=$escaped_key&exptime=120;
161+
162+
echo hello;
163+
echo hiya;
164+
}
165+
166+
location = /redis {
167+
internal;
168+
169+
set_md5 $redis_key $args;
170+
set $backend foo;
171+
redis_pass $backend;
172+
}
173+
174+
location = /redis2 {
175+
internal;
176+
177+
set_unescape_uri $exptime $arg_exptime;
178+
set_unescape_uri $key $arg_key;
179+
set_md5 $key;
180+
set $backend foo;
181+
182+
redis2_query set $key $echo_request_body;
183+
redis2_query expire $key $exptime;
184+
redis2_pass $backend;
185+
}
186+
--- request
187+
GET /foo
188+
--- response_headers
189+
Content-Type: text/css
190+
!Content-Length
191+
--- response_body
192+
hello
193+
hiya
194+
--- no_error_log
195+
[error]
196+
197+
198+
199+
=== TEST 6: basic fetch (cache hit) - cluster
200+
--- http_config
201+
upstream foo {
202+
server 127.0.0.1:$TEST_NGINX_REDIS_PORT;
203+
}
204+
205+
--- config
206+
location /foo {
207+
default_type text/css;
208+
209+
set $key $uri;
210+
srcache_fetch GET /redis $key;
211+
srcache_store PUT /redis2 key=$key&exptime=10;
212+
213+
echo world;
214+
}
215+
216+
location = /redis {
217+
#internal;
218+
219+
set_md5 $redis_key $args;
220+
set $backend foo;
221+
redis_pass $backend;
222+
}
223+
224+
location = /redis2 {
225+
internal;
226+
227+
set_unescape_uri $exptime $arg_exptime;
228+
set_unescape_uri $key $arg_key;
229+
set_md5 $key;
230+
231+
redis2_query set $key $echo_request_body;
232+
redis2_query expire $key $exptime;
233+
234+
set $backend foo;
235+
redis2_pass $backend;
236+
}
237+
--- request
238+
GET /foo
239+
--- response_headers
240+
Content-Type: text/css
241+
Content-Length: 11
242+
--- response_body
243+
hello
244+
hiya
245+
--- no_error_log
246+
[error]
247+

util/build.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ version=$1
77
home=~
88
force=$2
99

10+
ngx_redis_version=0.3.6
11+
ngx_redis_path=$home/work/nginx/ngx_http_redis-$ngx_redis_version
12+
13+
cd $ngx_redis_path
14+
patch -N -p1 < $root/../ngx_openresty/patches/ngx_http_redis-$ngx_redis_version-variables_in_redis_pass.patch
15+
cd $root
16+
1017
#--without-http_memcached_module \
1118
ngx-build $force $version \
1219
--with-cc-opt="-O0" \
@@ -22,7 +29,7 @@ ngx-build $force $version \
2229
--without-http_userid_module \
2330
--add-module=$root/../ndk-nginx-module \
2431
--add-module=$root/../set-misc-nginx-module \
25-
--add-module=$home/work/nginx/ngx_http_redis-0.3.6 \
32+
--add-module=$ngx_redis_path \
2633
--add-module=$root/../xss-nginx-module \
2734
--add-module=$root/../redis2-nginx-module \
2835
--add-module=$root/../eval-nginx-module \

0 commit comments

Comments
 (0)