comparison stream_proxy_next_upstream.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 77359b849cd5
children 882267679006
comparison
equal deleted inserted replaced
951:9361c7eddfc1 952:e9064d691790
34 events { 34 events {
35 } 35 }
36 36
37 stream { 37 stream {
38 upstream u { 38 upstream u {
39 server 127.0.0.1:8087 max_fails=0; 39 server 127.0.0.1:%%PORT_3%% max_fails=0;
40 server 127.0.0.1:8088 max_fails=0; 40 server 127.0.0.1:%%PORT_4%% max_fails=0;
41 server 127.0.0.1:8089 backup; 41 server 127.0.0.1:%%PORT_5%% backup;
42 } 42 }
43 43
44 upstream u2 { 44 upstream u2 {
45 server 127.0.0.1:8087; 45 server 127.0.0.1:%%PORT_3%%;
46 server 127.0.0.1:8089 backup; 46 server 127.0.0.1:%%PORT_5%% backup;
47 } 47 }
48 48
49 proxy_connect_timeout 1s; 49 proxy_connect_timeout 1s;
50 50
51 server { 51 server {
52 listen 127.0.0.1:8081; 52 listen 127.0.0.1:%%PORT_0%%;
53 proxy_pass u; 53 proxy_pass u;
54 proxy_next_upstream off; 54 proxy_next_upstream off;
55 } 55 }
56 56
57 server { 57 server {
58 listen 127.0.0.1:8082; 58 listen 127.0.0.1:%%PORT_1%%;
59 proxy_pass u2; 59 proxy_pass u2;
60 proxy_next_upstream on; 60 proxy_next_upstream on;
61 } 61 }
62 62
63 server { 63 server {
64 listen 127.0.0.1:8083; 64 listen 127.0.0.1:%%PORT_2%%;
65 proxy_pass u; 65 proxy_pass u;
66 proxy_next_upstream on; 66 proxy_next_upstream on;
67 proxy_next_upstream_tries 2; 67 proxy_next_upstream_tries 2;
68 } 68 }
69 } 69 }
70 70
71 EOF 71 EOF
72 72
73 $t->run_daemon(\&stream_daemon); 73 $t->run_daemon(\&stream_daemon);
74 $t->run()->waitforsocket('127.0.0.1:8089'); 74 $t->run()->waitforsocket('127.0.0.1:' . port(5));
75 75
76 ############################################################################### 76 ###############################################################################
77 77
78 is(stream('127.0.0.1:8081')->io('.'), '', 'next off'); 78 is(stream('127.0.0.1:' . port(0))->io('.'), '', 'next off');
79 is(stream('127.0.0.1:8082')->io('.'), 'SEE-THIS', 'next on'); 79 is(stream('127.0.0.1:' . port(1))->io('.'), 'SEE-THIS', 'next on');
80 80
81 # make sure backup is not tried 81 # make sure backup is not tried
82 82
83 is(stream('127.0.0.1:8083')->io('.'), '', 'next tries'); 83 is(stream('127.0.0.1:' . port(2))->io('.'), '', 'next tries');
84 84
85 ############################################################################### 85 ###############################################################################
86 86
87 sub stream_daemon { 87 sub stream_daemon {
88 my $server = IO::Socket::INET->new( 88 my $server = IO::Socket::INET->new(
89 Proto => 'tcp', 89 Proto => 'tcp',
90 LocalHost => '127.0.0.1:8089', 90 LocalHost => '127.0.0.1:' . port(5),
91 Listen => 5, 91 Listen => 5,
92 Reuse => 1 92 Reuse => 1
93 ) 93 )
94 or die "Can't create listening socket: $!\n"; 94 or die "Can't create listening socket: $!\n";
95 95