Mercurial > hg > nginx-tests
annotate proxy-noclose.t @ 21:a2144333aa8f
Tests: todo test for buggy backends not closing connections.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 26 Sep 2008 18:28:02 +0400 |
parents | |
children | 5e65db715827 |
rev | line source |
---|---|
21
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Test for http backend not closing connection properly after sending full |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 # reply. This is in fact backend bug, but it seems common, and anyway |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 # correct handling is required to support persistent connections. |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 ############################################################################### |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 use warnings; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use strict; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 use Test::More tests => 1; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use lib 'lib'; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 use Test::Nginx; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 ############################################################################### |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new(); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 master_process off; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 daemon off; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 events { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 worker_connections 1024; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 http { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 access_log off; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 root %%TESTDIR%%; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 server { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 listen localhost:8080; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 server_name localhost; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 location / { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 proxy_pass http://localhost:8081; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 proxy_read_timeout 1s; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 EOF |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 $t->run_daemon(\&http_noclose_daemon); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 $t->run(); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 ############################################################################### |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 TODO: { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 local $TODO = 'not fixed yet, submit patches'; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 my $t1 = http_request('/'); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 like($t1, qr/TEST-OK-IF-YOU-SEE-THIS/, 'request to bad backend'); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 ############################################################################### |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 sub http_request { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 my ($url) = @_; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 my $r = http(<<EOF); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 GET $url HTTP/1.1 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 Host: localhost |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 Connection: close |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 EOF |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 sub http_noclose_daemon { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 my $server = IO::Socket::INET->new( |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 Proto => 'tcp', |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 LocalPort => 8081, |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 Listen => 5, |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 Reuse => 1 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 ) |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 or die "Can't create listening socket: $!\n"; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 while (my $client = $server->accept()) { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 $client->autoflush(1); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 while (<$client>) { |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 last if (/^\x0d?\x0a?$/); |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 print $client <<'EOF'; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 HTTP/1.1 200 OK |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 Content-Length: 23 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 Connection: close |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 TEST-OK-IF-YOU-SEE-THIS |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 EOF |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 sleep 2; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 close $client; |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 } |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
a2144333aa8f
Tests: todo test for buggy backends not closing connections.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 ############################################################################### |