comparison proxy.t @ 952:e9064d691790

Tests: converted tests to run in parallel.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 21 Jun 2016 16:39:13 +0300
parents 54680c434afa
children 882267679006
comparison
equal deleted inserted replaced
951:9361c7eddfc1 952:e9064d691790
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:8081; 41 server 127.0.0.1:%%PORT_1%%;
42 } 42 }
43 43
44 server { 44 server {
45 listen 127.0.0.1:8080; 45 listen 127.0.0.1:%%PORT_0%%;
46 server_name localhost; 46 server_name localhost;
47 47
48 location / { 48 location / {
49 proxy_pass http://127.0.0.1:8081; 49 proxy_pass http://127.0.0.1:%%PORT_1%%;
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:8081'); 64 $t->run()->waitforsocket('127.0.0.1:' . port(1));
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:8081/'), qr/SEE-THIS/, 'proxy with variables'); 73 like(http_get('/var?b=127.0.0.1:' . port(1) . '/'), qr/SEE-THIS/,
74 'proxy with variables');
74 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');
75 76
76 SKIP: { 77 SKIP: {
77 skip 'no ipv6', 1 unless $t->has_module('ipv6') 78 skip 'no ipv6', 1 unless $t->has_module('ipv6')
78 and socket(my $s, &AF_INET6, &SOCK_STREAM, 0); 79 and socket(my $s, &AF_INET6, &SOCK_STREAM, 0);
96 ############################################################################### 97 ###############################################################################
97 98
98 sub http_daemon { 99 sub http_daemon {
99 my $server = IO::Socket::INET->new( 100 my $server = IO::Socket::INET->new(
100 Proto => 'tcp', 101 Proto => 'tcp',
101 LocalHost => '127.0.0.1:8081', 102 LocalHost => '127.0.0.1:' . port(1),
102 Listen => 5, 103 Listen => 5,
103 Reuse => 1 104 Reuse => 1
104 ) 105 )
105 or die "Can't create listening socket: $!\n"; 106 or die "Can't create listening socket: $!\n";
106 107