Mercurial > hg > nginx-tests
annotate proxy_cache_lock_age.t @ 1993:6b1222de8286
Tests: fixed prerequisites for regular expressions in maps.
Regular expressions in maps are only recognized when nginx is compiled
with the PCRE library. The simplest way to make sure it is the case
is to require the rewrite module, which cannot be compiled in without
the PCRE library.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 01 Aug 2024 10:37:20 +0300 |
parents | 196d33c2bb45 |
children |
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'; |
576
239ade56c015
Tests: more proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
574
diff
changeset
|
20 use Test::Nginx qw/ :DEFAULT http_end /; |
501
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 |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http proxy cache/)->plan(4) |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
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 daemon off; |
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 events { |
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 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 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
|
41 keys_zone=NAME:1m; |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
44 listen 127.0.0.1:8080; |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server_name localhost; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 proxy_pass http://127.0.0.1:8081; |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 proxy_cache NAME; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 proxy_cache_lock on; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 proxy_cache_lock_age 100ms; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 } |
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 EOF |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
59 $t->run_daemon(\&http_daemon, port(8081)); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
60 $t->run()->waitforsocket('127.0.0.1:' . port(8081)); |
501
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 ############################################################################### |
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 my $s = http_get('/', start => 1); |
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 like(http_get('/'), qr/request 2/, 'request'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 like(http_get('/'), qr/request 2/, 'request cached'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 http_get('/close'); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
576
239ade56c015
Tests: more proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
574
diff
changeset
|
71 like(http_end($s), qr/request 1/, 'request aged'); |
239ade56c015
Tests: more proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
574
diff
changeset
|
72 like(http_get('/'), qr/request 1/, 'request aged cached'); |
239ade56c015
Tests: more proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
574
diff
changeset
|
73 |
501
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 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 sub http_daemon { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 my (@ports) = @_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 my @socks; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 for my $port (@ports) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 my $server = IO::Socket::INET->new( |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 Proto => 'tcp', |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 LocalHost => "127.0.0.1:$port", |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 Listen => 5, |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 Reuse => 1 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 ) |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 or die "Can't create listening socket: $!\n"; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 push @socks, $server; |
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 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 my $sel = IO::Select->new(@socks); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 my $num = 0; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 my $s; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 local $SIG{PIPE} = 'IGNORE'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 while (my @ready = $sel->can_read) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 foreach my $fh (@ready) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 if (grep $_ == $fh, @socks) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 my $new = $fh->accept; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 $new->autoflush(1); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 $sel->add($new); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 } elsif (process_socket($fh, \$num, \$s)) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 $sel->remove($fh); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 $fh->close; |
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 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 # Returns true to close connection |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 sub process_socket { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 my ($client, $num, $s) = @_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 my $headers = ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 my $uri = ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 while (<$client>) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 $headers .= $_; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 last if (/^\x0d?\x0a?$/); |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 } |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 return 1 if $headers eq ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 return 1 if $uri eq ''; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 # finish a previously saved socket |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 close $$s if $uri eq '/close'; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 $$num++; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 print $client <<EOF; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 HTTP/1.1 200 OK |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 Cache-Control: max-age=300 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 Connection: close |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 request $$num |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 EOF |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 # save socket and wait |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 if ($$num == 1) { |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 $$s = $client; |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 return 0; |
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 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 return 1; |
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 |
0ee2899fbe3e
Tests: proxy_cache_lock_age tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 ############################################################################### |