@@ -13,7 +13,7 @@ $ENV{TEST_NGINX_REDIS_PORT} ||= 6379;
13
13
# no_long_string();
14
14
no_shuffle();
15
15
16
- log_level(' warn' );
16
+ # log_level('warn');
17
17
run_tests();
18
18
19
19
__DATA__
@@ -125,3 +125,123 @@ hiya
125
125
--- no_error_log
126
126
[error]
127
127
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
+
0 commit comments