Mercurial > hg > nginx-tests
annotate addition.t @ 572:ca54b445d982
Tests: masked nginx bug in proxy next upstream.
When iterating through several next upstreams per a worker cycle,
a previously reported event about upstream connection error may
be improperly applied to the next upstream, thus leading to the
invalid connection error. E.g., in kqueue, where the problem is
visible, this is caused by "ev->instance" that does not tolerate
more than one next upstream at once, and kevents placed on the
kqueue separately for read and write events.
The change is to limit test case to the only one next upstream.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 14 May 2015 11:54:24 +0300 |
parents | 9920a522a2de |
children | e9064d691790 |
rev | line source |
---|---|
340
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for addition module. |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http rewrite addition/)->plan(9); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 server { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 listen 127.0.0.1:8080; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server_name localhost; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 location /regular { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 return 200 "body"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location /b.html { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 add_before_body /add_before; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 return 200 "body"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 location /a.html { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 add_after_body /add_after; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 return 200 "body"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 location /ba.html { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 add_before_body /add_before; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 add_after_body /add_after; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 return 200 "body"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 location /notype { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 add_before_body /add_before; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 add_after_body /add_after; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 return 200 "body"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 location /notype2 { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 addition_types text/plain; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 add_after_body /add_after; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 return 200 "body"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 location /notype.html { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 types {} |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 add_before_body /add_before; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 return 200 "body"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 location /add_before { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 return 200 "before"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 location /add_after { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 return 200 "after"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 location /self.html { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 add_after_body /self.html; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 return 200 "self"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 location /return202.html { |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 add_after_body /add_after; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 return 202 "body"; |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 } |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 EOF |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 $t->run(); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 ############################################################################### |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 like(http_get('/regular'), qr/^body$/ms, 'no addition'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 like(http_get('/b.html'), qr/^beforebody$/ms, 'add_before'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 like(http_get('/a.html'), qr/^bodyafter$/ms, 'add_after'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 like(http_get('/ba.html'), qr/^beforebodyafter$/ms, 'both'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 like(http_get('/notype'), qr/^body$/ms, 'no content type'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 like(http_get('/notype2'), qr/^bodyafter$/ms, 'addition_types'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 like(http_get('/notype.html'), qr/^body$/ms, 'empty content type'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 like(http_get('/self.html'), qr/^selfself$/ms, 'self'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 like(http_get('/return202.html'), qr/HTTP\/1.. 202.*^body$/ms, 'not 200'); |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
9920a522a2de
Tests: added tests for addition module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 ############################################################################### |