Mercurial > hg > nginx-tests
annotate proxy_cache_lock.t @ 440:13ffba66f4e3
Tests: removed leftover in proxy_cache_lock.t after 60888e2c3f5a.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 18 Jul 2014 13:55:32 +0400 |
parents | 60888e2c3f5a |
children | b86c05516e65 |
rev | line source |
---|---|
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for http proxy cache lock. |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 use Socket qw/ CRLF /; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
438
60888e2c3f5a
Tests: new http_start() and http_end() functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
18 use Test::Nginx qw/ :DEFAULT http_end /; |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 ############################################################################### |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 |
223
f9325406df0b
Tests: skip tests not appropriate for win32.
Maxim Dounin <mdounin@mdounin.ru>
parents:
213
diff
changeset
|
25 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
f9325406df0b
Tests: skip tests not appropriate for win32.
Maxim Dounin <mdounin@mdounin.ru>
parents:
213
diff
changeset
|
26 |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http proxy cache/) |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
233
diff
changeset
|
32 daemon off; |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 events { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 http { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 proxy_cache_path %%TESTDIR%%/cache levels=1:2 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 keys_zone=NAME:10m; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 server { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 listen 127.0.0.1:8080; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 server_name localhost; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 location / { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 proxy_pass http://127.0.0.1:8081; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 proxy_cache NAME; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 proxy_cache_lock on; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 location /timeout { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 proxy_pass http://127.0.0.1:8081; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 proxy_cache NAME; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 proxy_cache_lock on; |
233
1a5574d84917
Tests: tweak various timeouts and replace sleep() with select().
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
59 proxy_cache_lock_timeout 200ms; |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 location /nolock { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 proxy_pass http://127.0.0.1:8081; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 proxy_cache NAME; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 EOF |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 $t->run_daemon(\&http_fake_daemon); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 |
397
847ea345becb
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
392
diff
changeset
|
73 $t->run()->plan(19); |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 |
213
4ac0807cc3cf
Tests: eliminate race in proxy_cache_lock.t startup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
212
diff
changeset
|
75 $t->waitforsocket('127.0.0.1:8081'); |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 ############################################################################### |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 # sequentional requests |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 for my $i (1 .. 5) { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 like(http_get('/seq'), qr/request 1/, 'sequentional request ' . $i); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 # parallel requests |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 my @sockets; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 for my $i (1 .. 5) { |
438
60888e2c3f5a
Tests: new http_start() and http_end() functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
90 $sockets[$i] = http_get('/par1', start => 1); |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 for my $i (1 .. 5) { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 like(http_end($sockets[$i]), qr/request 1/, 'parallel request ' . $i); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 like(http_get('/par1'), qr/request 1/, 'first request cached'); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 # parallel requests with cache lock timeout |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 for my $i (1 .. 3) { |
438
60888e2c3f5a
Tests: new http_start() and http_end() functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
102 $sockets[$i] = http_get('/timeout', start => 1); |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 for my $i (1 .. 3) { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 like(http_end($sockets[$i]), qr/request $i/, 'lock timeout ' . $i); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 like(http_get('/timeout'), qr/request 3/, 'lock timeout - last cached'); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 # no lock |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 for my $i (1 .. 3) { |
438
60888e2c3f5a
Tests: new http_start() and http_end() functions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
114 $sockets[$i] = http_get('/nolock', start => 1); |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 for my $i (1 .. 3) { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 like(http_end($sockets[$i]), qr/request $i/, 'nolock ' . $i); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 like(http_get('/nolock'), qr/request 3/, 'nolock - last cached'); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 ############################################################################### |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 sub http_fake_daemon { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 my $server = IO::Socket::INET->new( |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 Proto => 'tcp', |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 LocalAddr => '127.0.0.1:8081', |
191
bc6ecf23cc9c
Tests: enlarge listen queue for cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
184
diff
changeset
|
129 Listen => 5, |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 Reuse => 1 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 ) |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 or die "Can't create listening socket: $!\n"; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 my $num = 0; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 my $uri = ''; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 while (my $client = $server->accept()) { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 $client->autoflush(1); |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 while (<$client>) { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 if (/GET (.*) HTTP/ && $1 ne $uri) { |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 $uri = $1; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 $num = 0; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 } |
212 | 145 |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 $uri = $1 if /GET (.*) HTTP/; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 last if /^\x0d?\x0a?$/; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 |
213
4ac0807cc3cf
Tests: eliminate race in proxy_cache_lock.t startup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
212
diff
changeset
|
150 next unless $uri; |
4ac0807cc3cf
Tests: eliminate race in proxy_cache_lock.t startup.
Maxim Dounin <mdounin@mdounin.ru>
parents:
212
diff
changeset
|
151 |
233
1a5574d84917
Tests: tweak various timeouts and replace sleep() with select().
Maxim Dounin <mdounin@mdounin.ru>
parents:
223
diff
changeset
|
152 select(undef, undef, undef, 0.5); |
184
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 $num++; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 print $client <<"EOF"; |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 HTTP/1.1 200 OK |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 Cache-Control: max-age=300 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 Connection: close |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 request $num |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 EOF |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 } |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 |
f432f11a3b12
Tests: proxy cache lock tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 ############################################################################### |