Mercurial > hg > nginx-tests
annotate proxy_method.t @ 1240:f7eb2875ed45
Tests: avoid interleaved output in Upgrade handling tests.
When the testing script is run in verbose mode by prove that redirects stdout,
a garbled verbose mode line from backend can be produced that incorporates TAP
output of an individual test result, which eventually breaks the testing plan.
Notably, this happens when testing sending multiple frames if backend started
to respond before all frames were received. This is possible due to the line
boundary used as an indicator of last bytes to receive before starting to send.
The fix is to amend the only last frame of many specially, for that purpose.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 15 Nov 2017 20:16:09 +0300 |
parents | 4240cca68d1d |
children | 766bcbb632ee |
rev | line source |
---|---|
1071
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
2 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
3 # (C) Dmitry Lazurkin |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
4 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
5 # Tests for proxy_method. |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
6 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
7 ############################################################################### |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
8 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
9 use warnings; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
10 use strict; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
11 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
12 use Test::More; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
13 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
15 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
16 use lib 'lib'; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
17 use Test::Nginx; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
18 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
19 ############################################################################### |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
20 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
23 |
1075
5513b68493e7
Tests: added rewrite prerequisite in proxy_method.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1071
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(4) |
1076
4240cca68d1d
Tests: whitespace fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1075
diff
changeset
|
25 ->write_file_expand('nginx.conf', <<'EOF'); |
1071
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
26 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
27 %%TEST_GLOBALS%% |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
28 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
29 daemon off; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
30 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
31 events { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
32 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
33 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
34 http { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
35 %%TEST_GLOBALS_HTTP%% |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
36 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
37 server { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
38 listen 127.0.0.1:8080; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
39 server_name localhost; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
40 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
41 location /preserve { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
42 proxy_pass http://127.0.0.1:8080/get-method; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
43 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
44 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
45 location /const { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
46 proxy_pass http://127.0.0.1:8080/get-method; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
47 proxy_method POST; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
48 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
49 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
50 location /var { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
51 proxy_pass http://127.0.0.1:8080/get-method; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
52 proxy_method $arg_method; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
53 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
54 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
55 location /parent { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
56 proxy_method POST; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
57 location /parent/child { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
58 proxy_pass http://127.0.0.1:8080/get-method; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
59 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
60 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
61 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
62 location /get-method { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
63 return 200 "request_method=$request_method"; |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
64 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
65 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
66 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
67 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
68 EOF |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
69 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
70 $t->run(); |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
71 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
72 ############################################################################### |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
73 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
74 like(http_get('/preserve'), qr/request_method=GET/, |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
75 'proxy_method from request'); |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
76 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
77 like(http_get('/const'), qr/request_method=POST/, |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
78 'proxy_method from constant'); |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
79 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
80 TODO: { |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
81 local $TODO = 'not yet' unless $t->has_version('1.11.6'); |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
82 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
83 like(http_get('/var?method=POST'), qr/request_method=POST/, |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
84 'proxy_method from variable'); |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
85 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
86 } |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
87 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
88 like(http_get('/parent/child'), qr/request_method=POST/, |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
89 'proxy_method from parent'); |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
90 |
1dd57525de8b
Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff
changeset
|
91 ############################################################################### |