annotate proxy_cache_path.t @ 568:907e89fba9c3

Tests: removed TODO and try_run() checks for legacy versions.
author Sergey Kandaurov <pluknet@nginx.com>
date Sun, 03 May 2015 12:45:09 +0300
parents 5b5ef52d6fd2
children 2cd00179f4b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for http proxy cache with use_temp_path parameter.
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 plan(skip_all => 'win32') if $^O eq 'MSWin32';
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26
568
907e89fba9c3 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 522
diff changeset
27 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(7)
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 ->write_file_expand('nginx.conf', <<'EOF');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 %%TEST_GLOBALS%%
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 daemon off;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 events {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 http {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS_HTTP%%
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 proxy_cache_path %%TESTDIR%%/cache1
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 keys_zone=ON:1m use_temp_path=on;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 proxy_cache_path %%TESTDIR%%/cache2
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 keys_zone=OFF:1m use_temp_path=off;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 proxy_cache_path %%TESTDIR%%/cache4 levels=1:2
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 keys_zone=LEVELS:1m use_temp_path=off;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 server {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 listen 127.0.0.1:8080;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 server_name localhost;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 location / {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 proxy_pass http://127.0.0.1:8081;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 proxy_cache $arg_c;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 proxy_cache_valid any 1m;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 add_header X-Cache-Status $upstream_cache_status;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 server {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 listen 127.0.0.1:8081;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 server_name localhost;
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 location / {
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 }
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 EOF
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 $t->write_file('t', 'SEE-THIS');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74
568
907e89fba9c3 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 522
diff changeset
75 $t->run();
521
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 ###############################################################################
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 like(http_get('/t?c=ON'), qr/MISS.*SEE-THIS/ms, 'temp path');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 like(http_get('/t?c=OFF'), qr/MISS.*SEE-THIS/ms, 'temp path off');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 like(http_get('/t?c=LEVELS'), qr/MISS.*SEE-THIS/ms, 'temp path levels');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 $t->write_file('t', 'SEE-THAT');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 like(http_get('/t?c=ON'), qr/HIT.*SEE-THIS/ms, 'temp path cached');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 like(http_get('/t?c=OFF'), qr/HIT.*SEE-THIS/ms, 'temp path cached off');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 like(http_get('/t?c=LEVELS'), qr/HIT.*SEE-THIS/ms, 'temp path cached levels');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts');
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90
6b9bfe18fdc8 Tests: proxy_cache_path with use_temp_path parameter.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 ###############################################################################