Mercurial > hg > nginx-tests
comparison proxy_cache_min_free.t @ 1576:8177323823d6
Tests: proxy_cache_path with min_free parameter.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 18 Jun 2020 12:42:01 +0300 |
parents | |
children | 5ac6efbe5552 |
comparison
equal
deleted
inserted
replaced
1575:577e72267fec | 1576:8177323823d6 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for http proxy cache, min_free parameter. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/http proxy cache/) | |
26 ->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 daemon off; | |
31 | |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 proxy_cache_path %%TESTDIR%%/cache levels=1:2 min_free=4k | |
39 keys_zone=NAME:1m; | |
40 | |
41 server { | |
42 listen 127.0.0.1:8080; | |
43 server_name localhost; | |
44 | |
45 location / { | |
46 proxy_pass http://127.0.0.1:8081; | |
47 | |
48 proxy_cache NAME; | |
49 | |
50 proxy_cache_valid any 1m; | |
51 | |
52 add_header X-Cache-Status $upstream_cache_status; | |
53 } | |
54 } | |
55 | |
56 server { | |
57 listen 127.0.0.1:8081; | |
58 server_name localhost; | |
59 | |
60 location / { } | |
61 } | |
62 } | |
63 | |
64 EOF | |
65 | |
66 $t->write_file('t.html', 'SEE-THIS'); | |
67 $t->try_run('no proxy_cache_path min_free')->plan(2); | |
68 | |
69 ############################################################################### | |
70 | |
71 like(http_get('/t.html'), qr/SEE-THIS/, 'proxy request'); | |
72 | |
73 $t->write_file('t.html', 'NOOP'); | |
74 like(http_get('/t.html'), qr/SEE-THIS/, 'proxy request cached'); | |
75 | |
76 ############################################################################### |