Mercurial > hg > nginx-tests
comparison proxy_store.t @ 148:b714d6df958c
Tests: rename some tests for better sorting.
Use underscore instead of dash. Addtionally, rename some tests to better
match "module" + "details" scheme used: use "http_" prefix for http core
module tests, use "mail_" prefix for mail module tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 04 Mar 2011 16:07:15 +0300 |
parents | proxy-store.t@8ac1faaddd2c |
children | c0ae29632905 |
comparison
equal
deleted
inserted
replaced
147:fd865ada95c8 | 148:b714d6df958c |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for proxy_store functionality. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 my $t = Test::Nginx->new(); | |
25 | |
26 $t->write_file_expand('nginx.conf', <<'EOF')->has(qw/http proxy ssi/)->plan(7); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 master_process off; | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 server { | |
40 listen 127.0.0.1:8080; | |
41 server_name localhost; | |
42 | |
43 location /store- { | |
44 proxy_pass http://127.0.0.1:8080/; | |
45 proxy_store on; | |
46 } | |
47 location /ssi.html { | |
48 ssi on; | |
49 } | |
50 location /index-nostore.html { | |
51 add_header X-Accel-Expires 0; | |
52 } | |
53 location /index-big.html { | |
54 limit_rate 200k; | |
55 } | |
56 } | |
57 } | |
58 | |
59 EOF | |
60 | |
61 $t->write_file('index.html', 'SEE-THIS'); | |
62 $t->write_file('index-nostore.html', 'SEE-THIS'); | |
63 $t->write_file('index-big.html', 'x' x (100 << 10)); | |
64 $t->write_file('ssi.html', | |
65 '<!--#include virtual="/store-index-big.html?1" -->' . | |
66 '<!--#include virtual="/store-index-big.html?2" -->' | |
67 ); | |
68 $t->run(); | |
69 | |
70 ############################################################################### | |
71 | |
72 like(http_get('/store-index.html'), qr/SEE-THIS/, 'proxy request'); | |
73 ok(-e $t->testdir() . '/store-index.html', 'result stored'); | |
74 | |
75 like(http_get('/store-index-nostore.html'), qr/SEE-THIS/, | |
76 'proxy request with x-accel-expires'); | |
77 | |
78 TODO: { | |
79 local $TODO = 'patch under review'; | |
80 | |
81 ok(!-e $t->testdir() . '/store-index-nostore.html', 'result not stored'); | |
82 } | |
83 | |
84 ok(scalar @{[ glob $t->testdir() . '/proxy_temp/*' ]} == 0, 'no temp files'); | |
85 | |
86 http_get('/store-index-big.html', aborted => 1, sleep => 0.1); | |
87 sleep(1); | |
88 | |
89 ok(scalar @{[ glob $t->testdir() . '/proxy_temp/*' ]} == 0, | |
90 'no temp files after aborted request'); | |
91 | |
92 TODO: { | |
93 local $TODO = 'not fixed yet'; | |
94 | |
95 http_get('/ssi.html', aborted => 1, sleep => 0.1); | |
96 sleep(1); | |
97 | |
98 ok(scalar @{[ glob $t->testdir() . '/proxy_temp/*' ]} == 0, | |
99 'no temp files after aborted ssi'); | |
100 | |
101 } | |
102 | |
103 ############################################################################### |