Mercurial > hg > nginx-tests
comparison proxy.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 | e4d5e7afb6e0 |
comparison
equal
deleted
inserted
replaced
973:7d7aef8b9f3a | 974:882267679006 |
---|---|
36 | 36 |
37 http { | 37 http { |
38 %%TEST_GLOBALS_HTTP%% | 38 %%TEST_GLOBALS_HTTP%% |
39 | 39 |
40 upstream u { | 40 upstream u { |
41 server 127.0.0.1:%%PORT_1%%; | 41 server 127.0.0.1:8081; |
42 } | 42 } |
43 | 43 |
44 server { | 44 server { |
45 listen 127.0.0.1:%%PORT_0%%; | 45 listen 127.0.0.1:8080; |
46 server_name localhost; | 46 server_name localhost; |
47 | 47 |
48 location / { | 48 location / { |
49 proxy_pass http://127.0.0.1:%%PORT_1%%; | 49 proxy_pass http://127.0.0.1:8081; |
50 proxy_read_timeout 1s; | 50 proxy_read_timeout 1s; |
51 proxy_connect_timeout 2s; | 51 proxy_connect_timeout 2s; |
52 } | 52 } |
53 | 53 |
54 location /var { | 54 location /var { |
59 } | 59 } |
60 | 60 |
61 EOF | 61 EOF |
62 | 62 |
63 $t->run_daemon(\&http_daemon); | 63 $t->run_daemon(\&http_daemon); |
64 $t->run()->waitforsocket('127.0.0.1:' . port(1)); | 64 $t->run()->waitforsocket('127.0.0.1:' . port(8081)); |
65 | 65 |
66 ############################################################################### | 66 ############################################################################### |
67 | 67 |
68 like(http_get('/'), qr/SEE-THIS/, 'proxy request'); | 68 like(http_get('/'), qr/SEE-THIS/, 'proxy request'); |
69 like(http_get('/multi'), qr/AND-THIS/, 'proxy request with multiple packets'); | 69 like(http_get('/multi'), qr/AND-THIS/, 'proxy request with multiple packets'); |
70 | 70 |
71 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request'); | 71 unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request'); |
72 | 72 |
73 like(http_get('/var?b=127.0.0.1:' . port(1) . '/'), qr/SEE-THIS/, | 73 like(http_get('/var?b=127.0.0.1:' . port(8081) . '/'), qr/SEE-THIS/, |
74 'proxy with variables'); | 74 'proxy with variables'); |
75 like(http_get('/var?b=u/'), qr/SEE-THIS/, 'proxy with variables to upstream'); | 75 like(http_get('/var?b=u/'), qr/SEE-THIS/, 'proxy with variables to upstream'); |
76 | 76 |
77 SKIP: { | 77 SKIP: { |
78 skip 'no ipv6', 1 unless $t->has_module('ipv6') | 78 skip 'no ipv6', 1 unless $t->has_module('ipv6') |
97 ############################################################################### | 97 ############################################################################### |
98 | 98 |
99 sub http_daemon { | 99 sub http_daemon { |
100 my $server = IO::Socket::INET->new( | 100 my $server = IO::Socket::INET->new( |
101 Proto => 'tcp', | 101 Proto => 'tcp', |
102 LocalHost => '127.0.0.1:' . port(1), | 102 LocalHost => '127.0.0.1:' . port(8081), |
103 Listen => 5, | 103 Listen => 5, |
104 Reuse => 1 | 104 Reuse => 1 |
105 ) | 105 ) |
106 or die "Can't create listening socket: $!\n"; | 106 or die "Can't create listening socket: $!\n"; |
107 | 107 |