Mercurial > hg > nginx-tests
comparison proxy_variables.t @ 974:882267679006
Tests: simplified parallel modifications in tests.
Mail tests were simplified in c227348453db.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 12 Jul 2016 17:39:03 +0300 |
parents | e9064d691790 |
children | 196d33c2bb45 |
comparison
equal
deleted
inserted
replaced
973:7d7aef8b9f3a | 974:882267679006 |
---|---|
34 | 34 |
35 http { | 35 http { |
36 %%TEST_GLOBALS_HTTP%% | 36 %%TEST_GLOBALS_HTTP%% |
37 | 37 |
38 upstream u { | 38 upstream u { |
39 server 127.0.0.1:%%PORT_1%%; | 39 server 127.0.0.1:8081; |
40 server 127.0.0.1:%%PORT_1%%; | 40 server 127.0.0.1:8081; |
41 } | 41 } |
42 | 42 |
43 log_format time '$upstream_connect_time:$upstream_header_time:' | 43 log_format time '$upstream_connect_time:$upstream_header_time:' |
44 '$upstream_response_time'; | 44 '$upstream_response_time'; |
45 | 45 |
46 server { | 46 server { |
47 listen 127.0.0.1:%%PORT_0%%; | 47 listen 127.0.0.1:8080; |
48 server_name localhost; | 48 server_name localhost; |
49 | 49 |
50 add_header X-Connect $upstream_connect_time; | 50 add_header X-Connect $upstream_connect_time; |
51 add_header X-Header $upstream_header_time; | 51 add_header X-Header $upstream_header_time; |
52 add_header X-Response $upstream_response_time; | 52 add_header X-Response $upstream_response_time; |
53 | 53 |
54 location / { | 54 location / { |
55 proxy_pass http://127.0.0.1:%%PORT_1%%; | 55 proxy_pass http://127.0.0.1:8081; |
56 access_log %%TESTDIR%%/time.log time; | 56 access_log %%TESTDIR%%/time.log time; |
57 } | 57 } |
58 | 58 |
59 location /pnu { | 59 location /pnu { |
60 proxy_pass http://u/bad; | 60 proxy_pass http://u/bad; |
61 } | 61 } |
62 | 62 |
63 location /vars { | 63 location /vars { |
64 proxy_pass http://127.0.0.1:%%PORT_0%%/stub; | 64 proxy_pass http://127.0.0.1:8080/stub; |
65 | 65 |
66 add_header X-Proxy-Host $proxy_host; | 66 add_header X-Proxy-Host $proxy_host; |
67 add_header X-Proxy-Port $proxy_port; | 67 add_header X-Proxy-Port $proxy_port; |
68 add_header X-Proxy-Forwarded $proxy_add_x_forwarded_for; | 68 add_header X-Proxy-Forwarded $proxy_add_x_forwarded_for; |
69 } | 69 } |
73 } | 73 } |
74 | 74 |
75 EOF | 75 EOF |
76 | 76 |
77 $t->write_file('stub', ''); | 77 $t->write_file('stub', ''); |
78 $t->run_daemon(\&http_daemon, port(1)); | 78 $t->run_daemon(\&http_daemon, port(8081)); |
79 $t->try_run('no upstream_connect_time')->plan(18); | 79 $t->try_run('no upstream_connect_time')->plan(18); |
80 | 80 |
81 $t->waitforsocket('127.0.0.1:' . port(1)); | 81 $t->waitforsocket('127.0.0.1:' . port(8081)); |
82 | 82 |
83 ############################################################################### | 83 ############################################################################### |
84 | 84 |
85 my $re = qr/(\d\.\d{3})/; | 85 my $re = qr/(\d\.\d{3})/; |
86 my $p0 = port(0); | 86 my $p0 = port(8080); |
87 my ($ct, $ht, $rt, $ct2, $ht2, $rt2); | 87 my ($ct, $ht, $rt, $ct2, $ht2, $rt2); |
88 | 88 |
89 like(http_get('/vars'), qr/X-Proxy-Host:\s127\.0\.0\.1:$p0/, 'proxy_host'); | 89 like(http_get('/vars'), qr/X-Proxy-Host:\s127\.0\.0\.1:$p0/, 'proxy_host'); |
90 like(http_get('/vars'), qr/X-Proxy-Port:\s$p0/, 'proxy_port'); | 90 like(http_get('/vars'), qr/X-Proxy-Port:\s$p0/, 'proxy_port'); |
91 like(http_xff('/vars', '192.0.2.1'), qr/X-Proxy-Forwarded:.*192\.0\.2\.1/, | 91 like(http_xff('/vars', '192.0.2.1'), qr/X-Proxy-Forwarded:.*192\.0\.2\.1/, |