Mercurial > hg > nginx-tests
comparison proxy_cache_range.t @ 1008:bab7b53a156f
Tests: proxy cache range with sendfile in threads.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 22 Aug 2016 13:09:56 +0300 |
parents | 882267679006 |
children | 196d33c2bb45 |
comparison
equal
deleted
inserted
replaced
1007:174e900c00dc | 1008:bab7b53a156f |
---|---|
19 ############################################################################### | 19 ############################################################################### |
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(6) | 24 my $t = Test::Nginx->new()->has(qw/http proxy cache shmem/)->plan(7) |
25 ->write_file_expand('nginx.conf', <<'EOF'); | 25 ->write_file_expand('nginx.conf', <<'EOF'); |
26 | 26 |
27 %%TEST_GLOBALS%% | 27 %%TEST_GLOBALS%% |
28 | 28 |
29 daemon off; | 29 daemon off; |
57 server { | 57 server { |
58 listen 127.0.0.1:8081; | 58 listen 127.0.0.1:8081; |
59 server_name localhost; | 59 server_name localhost; |
60 | 60 |
61 location / { | 61 location / { |
62 if ($arg_s) { | |
63 limit_rate 50k; | |
64 } | |
62 } | 65 } |
63 } | 66 } |
64 } | 67 } |
65 | 68 |
66 EOF | 69 EOF |
67 | 70 |
68 $t->write_file('t.html', 'SEE-THIS'); | 71 $t->write_file('t.html', 'SEE-THIS'); |
72 | |
73 # should not fit in a single proxy buffer | |
74 | |
75 $t->write_file('tbig.html', | |
76 join('', map { sprintf "XX%06dXX", $_ } (1 .. 7000))); | |
77 | |
69 $t->run(); | 78 $t->run(); |
70 | 79 |
71 ############################################################################### | 80 ############################################################################### |
72 | 81 |
73 like(http_get_range('/t.html?1', 'Range: bytes=4-'), qr/^THIS/m, | 82 like(http_get_range('/t.html?1', 'Range: bytes=4-'), qr/^THIS/m, |
89 qr/^THIS/m, 'range below min_uses'); | 98 qr/^THIS/m, 'range below min_uses'); |
90 | 99 |
91 like(http_get_range('/min_uses/t.html?4', 'Range: bytes=0-2,4-'), | 100 like(http_get_range('/min_uses/t.html?4', 'Range: bytes=0-2,4-'), |
92 qr/^SEE.*^THIS/ms, 'multipart range below min_uses'); | 101 qr/^SEE.*^THIS/ms, 'multipart range below min_uses'); |
93 | 102 |
103 TODO: { | |
104 local $TODO = 'not yet' if $t->read_file('nginx.conf') =~ /sendfile on/ | |
105 and $t->read_file('nginx.conf') =~ /aio threads/ and $^O eq 'linux'; | |
106 | |
107 like(http_get_range('/tbig.html?s=1', 'Range: bytes=0-19'), | |
108 qr/^XX000001XXXX000002XX$/ms, 'range of response received in parts'); | |
109 | |
110 } | |
111 | |
94 ############################################################################### | 112 ############################################################################### |
95 | 113 |
96 sub http_get_range { | 114 sub http_get_range { |
97 my ($url, $extra) = @_; | 115 my ($url, $extra) = @_; |
98 return http(<<EOF); | 116 return http(<<EOF); |