comparison proxy_cache_range.t @ 500:b4d657ba1a62

Tests: tests for range requests below proxy_cache_min_uses.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 19 Nov 2014 19:45:33 +0300
parents 847ea345becb
children 907e89fba9c3
comparison
equal deleted inserted replaced
499:a3b03c333ad5 500:b4d657ba1a62
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 plan(skip_all => 'win32') if $^O eq 'MSWin32'; 24 plan(skip_all => 'win32') if $^O eq 'MSWin32';
25 25
26 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(5) 26 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(7)
27 ->write_file_expand('nginx.conf', <<'EOF'); 27 ->write_file_expand('nginx.conf', <<'EOF');
28 28
29 %%TEST_GLOBALS%% 29 %%TEST_GLOBALS%%
30 30
31 daemon off; 31 daemon off;
45 45
46 location / { 46 location / {
47 proxy_pass http://127.0.0.1:8081; 47 proxy_pass http://127.0.0.1:8081;
48 proxy_cache NAME; 48 proxy_cache NAME;
49 proxy_cache_valid 200 1m; 49 proxy_cache_valid 200 1m;
50 }
51 location /min_uses {
52 proxy_pass http://127.0.0.1:8081/;
53 proxy_cache NAME;
54 proxy_cache_valid 200 1m;
55 proxy_cache_min_uses 2;
50 } 56 }
51 } 57 }
52 58
53 server { 59 server {
54 listen 127.0.0.1:8081; 60 listen 127.0.0.1:8081;
79 like(http_get_range('/t.html?1', 'Range: bytes=4-'), qr/^THIS/m, 85 like(http_get_range('/t.html?1', 'Range: bytes=4-'), qr/^THIS/m,
80 'cached range'); 86 'cached range');
81 like(http_get_range('/t.html?1', 'Range: bytes=0-2,4-'), qr/^SEE.*^THIS/ms, 87 like(http_get_range('/t.html?1', 'Range: bytes=0-2,4-'), qr/^SEE.*^THIS/ms,
82 'cached multipart range'); 88 'cached multipart range');
83 89
90 TODO: {
91 local $TODO = 'not yet' unless $t->has_version('1.7.8');
92
93 like(http_get_range('/min_uses/t.html?3', 'Range: bytes=4-'),
94 qr/^THIS/m, 'range below min_uses');
95
96 like(http_get_range('/min_uses/t.html?4', 'Range: bytes=0-2,4-'),
97 qr/^SEE.*^THIS/ms, 'multipart range below min_uses');
98
99 }
100
84 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); 101 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts');
85 102
86 ############################################################################### 103 ###############################################################################
87 104
88 sub http_get_range { 105 sub http_get_range {