Mercurial > hg > nginx-tests
annotate proxy_cache_lock_age.t @ 570:f7bc1f74970a
Tests: avoid send errors in syslog tests with mail error_log.
Use a separate mail server block for syslog parsing tests to make sure
that syslog messages are always read by the receiver on the remote side.
Otherwise, syslog message might not be sent due to a pending socket error.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 07 May 2015 14:28:44 +0300 |
parents | 907e89fba9c3 |
children | 2cd00179f4b2 |
rev | line source |
---|---|
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for http proxy cache lock aged. |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use IO::Select; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
29 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(2) |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 ->write_file_expand('nginx.conf', <<'EOF'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 %%TEST_GLOBALS%% |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 daemon off; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 events { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 http { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 %%TEST_GLOBALS_HTTP%% |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 proxy_cache_path %%TESTDIR%%/cache levels=1:2 |
503
071e8941e3bf
Tests: reduce shared memory zone sizes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
501
diff
changeset
|
43 keys_zone=NAME:1m; |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 listen 127.0.0.1:8080; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 server_name localhost; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 location / { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 proxy_pass http://127.0.0.1:8081; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 proxy_cache NAME; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 proxy_cache_lock on; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 proxy_cache_lock_age 100ms; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 EOF |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 $t->run_daemon(\&http_daemon, 8081); |
568
907e89fba9c3
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
503
diff
changeset
|
62 $t->run()->waitforsocket('127.0.0.1:8081'); |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 ############################################################################### |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 my $s = http_get('/', start => 1); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 like(http_get('/'), qr/request 2/, 'request'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 like(http_get('/'), qr/request 2/, 'request cached'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 http_get('/close'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 ############################################################################### |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 sub http_daemon { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 my (@ports) = @_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 my @socks; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 for my $port (@ports) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 my $server = IO::Socket::INET->new( |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 Proto => 'tcp', |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 LocalHost => "127.0.0.1:$port", |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 Listen => 5, |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 Reuse => 1 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 ) |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 or die "Can't create listening socket: $!\n"; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 push @socks, $server; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 my $sel = IO::Select->new(@socks); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 my $num = 0; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 my $s; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 local $SIG{PIPE} = 'IGNORE'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 while (my @ready = $sel->can_read) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 foreach my $fh (@ready) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 if (grep $_ == $fh, @socks) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 my $new = $fh->accept; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 $new->autoflush(1); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 $sel->add($new); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 } elsif (process_socket($fh, \$num, \$s)) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 $sel->remove($fh); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 $fh->close; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 # Returns true to close connection |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 sub process_socket { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 my ($client, $num, $s) = @_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 my $headers = ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 my $uri = ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 while (<$client>) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 $headers .= $_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 last if (/^\x0d?\x0a?$/); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 return 1 if $headers eq ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 return 1 if $uri eq ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 # finish a previously saved socket |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 close $$s if $uri eq '/close'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 $$num++; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 print $client <<EOF; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 HTTP/1.1 200 OK |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 Cache-Control: max-age=300 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 Connection: close |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 request $$num |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 EOF |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 # save socket and wait |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 if ($$num == 1) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 $$s = $client; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 return 0; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 return 1; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 ############################################################################### |