@@ -5,7 +5,7 @@ use Test::Nginx::Socket;
5
5
6
6
# repeat_each(2);
7
7
8
- plan tests => repeat_each() * 2 * blocks();
8
+ plan tests => repeat_each() * ( 2 * blocks() + 10 );
9
9
10
10
$ENV {TEST_NGINX_MEMCACHED_PORT } ||= 11211;
11
11
@@ -337,3 +337,129 @@ hello, world
337
337
--- response_body chomp
338
338
hello
339
339
340
+
341
+
342
+ === TEST 19: flush all
343
+ --- config
344
+ location /flush {
345
+ set $memc_cmd 'flush_all';
346
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
347
+ }
348
+ --- response_headers
349
+ Content-Type: text/plain
350
+ Content-Length: 4
351
+ --- request
352
+ GET /flush
353
+ --- response_body eval: "OK\r\n"
354
+
355
+
356
+
357
+ === TEST 20: basic fetch (cache miss)
358
+ --- config
359
+ location /foo {
360
+ default_type text/css;
361
+ srcache_fetch GET /memc $uri;
362
+ srcache_store PUT /memc $uri;
363
+
364
+ echo hello;
365
+ }
366
+
367
+ location /memc {
368
+ internal;
369
+
370
+ set $memc_key $query_string;
371
+ set $memc_exptime 300;
372
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
373
+ }
374
+ --- request
375
+ GET /foo
376
+ --- response_headers
377
+ Content-Type: text/css
378
+ Content-Length:
379
+ --- response_body
380
+ hello
381
+
382
+
383
+
384
+ === TEST 21: basic fetch (cache hit)
385
+ --- config
386
+ location /foo {
387
+ default_type text/css;
388
+ srcache_fetch GET /memc $uri;
389
+ srcache_store PUT /memc $uri;
390
+
391
+ echo world;
392
+ }
393
+
394
+ location /memc {
395
+ internal;
396
+
397
+ set $memc_key $query_string;
398
+ set $memc_exptime 300;
399
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
400
+ }
401
+ --- request
402
+ GET /foo
403
+ --- response_headers
404
+ Content-Type: text/css
405
+ Content-Length: 6
406
+ --- response_body
407
+ hello
408
+
409
+
410
+
411
+ === TEST 22: fetch skip true
412
+ --- config
413
+ location /foo {
414
+ default_type text/css;
415
+ srcache_fetch GET /memc $uri;
416
+ srcache_store PUT /memc $uri;
417
+ srcache_fetch_skip 1;
418
+
419
+ echo world;
420
+ }
421
+
422
+ location /memc {
423
+ internal;
424
+
425
+ set $memc_key $query_string;
426
+ set $memc_exptime 300;
427
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
428
+ }
429
+ --- request
430
+ GET /foo
431
+ --- more_headers
432
+ cache-control: No-Cache
433
+ --- response_headers
434
+ Content-Type: text/css
435
+ Content-Length:
436
+ --- response_body
437
+ world
438
+
439
+
440
+
441
+ === TEST 23: basic fetch (cache hit again)
442
+ --- config
443
+ location /foo {
444
+ default_type text/css;
445
+ srcache_fetch GET /memc $uri;
446
+ srcache_store PUT /memc $uri;
447
+
448
+ echo world;
449
+ }
450
+
451
+ location /memc {
452
+ internal;
453
+
454
+ set $memc_key $query_string;
455
+ set $memc_exptime 300;
456
+ memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
457
+ }
458
+ --- request
459
+ GET /foo
460
+ --- response_headers
461
+ Content-Type: text/css
462
+ Content-Length: 6
463
+ --- response_body
464
+ world
465
+
0 commit comments