Mercurial > hg > nginx-tests
comparison proxy_cache_path.t @ 521:6b9bfe18fdc8
Tests: proxy_cache_path with use_temp_path parameter.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 02 Feb 2015 16:07:15 +0300 |
parents | |
children | 5b5ef52d6fd2 |
comparison
equal
deleted
inserted
replaced
520:4bcf8bc2bafe | 521:6b9bfe18fdc8 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for http proxy cache with use_temp_path 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 plan(skip_all => 'win32') if $^O eq 'MSWin32'; | |
26 | |
27 my $t = Test::Nginx->new()->has(qw/http proxy cache/) | |
28 ->write_file_expand('nginx.conf', <<'EOF'); | |
29 | |
30 %%TEST_GLOBALS%% | |
31 | |
32 daemon off; | |
33 | |
34 events { | |
35 } | |
36 | |
37 http { | |
38 %%TEST_GLOBALS_HTTP%% | |
39 | |
40 proxy_cache_path %%TESTDIR%%/cache1 | |
41 keys_zone=ON:1m use_temp_path=on; | |
42 proxy_cache_path %%TESTDIR%%/cache2 | |
43 keys_zone=OFF:1m use_temp_path=off; | |
44 proxy_cache_path %%TESTDIR%%/cache4 levels=1:2 | |
45 keys_zone=LEVELS:1m use_temp_path=off; | |
46 | |
47 server { | |
48 listen 127.0.0.1:8080; | |
49 server_name localhost; | |
50 | |
51 location / { | |
52 proxy_pass http://127.0.0.1:8081; | |
53 | |
54 proxy_cache $arg_c; | |
55 | |
56 proxy_cache_valid any 1m; | |
57 | |
58 add_header X-Cache-Status $upstream_cache_status; | |
59 } | |
60 } | |
61 | |
62 server { | |
63 listen 127.0.0.1:8081; | |
64 server_name localhost; | |
65 | |
66 location / { | |
67 } | |
68 } | |
69 } | |
70 | |
71 EOF | |
72 | |
73 $t->write_file('t', 'SEE-THIS'); | |
74 | |
75 $t->try_run('no use_temp_path')->plan(7); | |
76 | |
77 ############################################################################### | |
78 | |
79 like(http_get('/t?c=ON'), qr/MISS.*SEE-THIS/ms, 'temp path'); | |
80 like(http_get('/t?c=OFF'), qr/MISS.*SEE-THIS/ms, 'temp path off'); | |
81 | |
82 TODO: { | |
83 local $TODO = 'not yet'; | |
84 | |
85 like(http_get('/t?c=LEVELS'), qr/MISS.*SEE-THIS/ms, 'temp path levels'); | |
86 | |
87 } | |
88 | |
89 $t->write_file('t', 'SEE-THAT'); | |
90 | |
91 like(http_get('/t?c=ON'), qr/HIT.*SEE-THIS/ms, 'temp path cached'); | |
92 like(http_get('/t?c=OFF'), qr/HIT.*SEE-THIS/ms, 'temp path cached off'); | |
93 | |
94 TODO: { | |
95 local $TODO = 'not yet'; | |
96 | |
97 like(http_get('/t?c=LEVELS'), qr/HIT.*SEE-THIS/ms, 'temp path cached levels'); | |
98 | |
99 } | |
100 | |
101 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); | |
102 | |
103 ############################################################################### |