comparison stream_udp_upstream_least_conn.t @ 1237:e4974af3fb12

Tests: adjusted udp ports to match allocated ports range.
author Andrey Zelenkov <zelenkov@nginx.com>
date Wed, 13 Sep 2017 19:04:25 +0300
parents 3fc6817cd84a
children f3ba4c74de31
comparison
equal deleted inserted replaced
1236:93f749c1d5c5 1237:e4974af3fb12
37 proxy_responses 1; 37 proxy_responses 1;
38 proxy_timeout 1s; 38 proxy_timeout 1s;
39 39
40 upstream u { 40 upstream u {
41 least_conn; 41 least_conn;
42 server 127.0.0.1:%%PORT_8081_UDP%%; 42 server 127.0.0.1:%%PORT_8981_UDP%%;
43 server 127.0.0.1:%%PORT_8082_UDP%%; 43 server 127.0.0.1:%%PORT_8982_UDP%%;
44 } 44 }
45 45
46 server { 46 server {
47 listen 127.0.0.1:%%PORT_8080_UDP%% udp; 47 listen 127.0.0.1:%%PORT_8980_UDP%% udp;
48 proxy_pass u; 48 proxy_pass u;
49 } 49 }
50 } 50 }
51 51
52 EOF 52 EOF
53 53
54 $t->run_daemon(\&udp_daemon, port(8081), $t); 54 $t->run_daemon(\&udp_daemon, port(8981), $t);
55 $t->run_daemon(\&udp_daemon, port(8082), $t); 55 $t->run_daemon(\&udp_daemon, port(8982), $t);
56 $t->run(); 56 $t->run();
57 57
58 $t->waitforfile($t->testdir . '/' . port(8081)); 58 $t->waitforfile($t->testdir . '/' . port(8981));
59 $t->waitforfile($t->testdir . '/' . port(8082)); 59 $t->waitforfile($t->testdir . '/' . port(8982));
60 60
61 ############################################################################### 61 ###############################################################################
62 62
63 my @ports = my ($port1, $port2) = (port(8081), port(8082)); 63 my @ports = my ($port1, $port2) = (port(8981), port(8982));
64 64
65 is(many(10), "$port1: 5, $port2: 5", 'balanced'); 65 is(many(10), "$port1: 5, $port2: 5", 'balanced');
66 66
67 my @sockets; 67 my @sockets;
68 for (1 .. 2) { 68 for (1 .. 2) {
69 my $s = dgram('127.0.0.1:' . port(8080)); 69 my $s = dgram('127.0.0.1:' . port(8980));
70 $s->write('w'); 70 $s->write('w');
71 push @sockets, $s; 71 push @sockets, $s;
72 } 72 }
73 73
74 select undef, undef, undef, 0.2; 74 select undef, undef, undef, 0.2;
80 sub many { 80 sub many {
81 my ($count) = @_; 81 my ($count) = @_;
82 my (%ports); 82 my (%ports);
83 83
84 for (1 .. $count) { 84 for (1 .. $count) {
85 if (dgram('127.0.0.1:' . port(8080))->io('.') =~ /(\d+)/) { 85 if (dgram('127.0.0.1:' . port(8980))->io('.') =~ /(\d+)/) {
86 $ports{$1} = 0 unless defined $ports{$1}; 86 $ports{$1} = 0 unless defined $ports{$1};
87 $ports{$1}++; 87 $ports{$1}++;
88 } 88 }
89 } 89 }
90 90
112 while (1) { 112 while (1) {
113 $server->recv(my $buffer, 65536); 113 $server->recv(my $buffer, 65536);
114 114
115 my $port = $server->sockport(); 115 my $port = $server->sockport();
116 116
117 if ($buffer =~ /w/ && $port == port(8081)) { 117 if ($buffer =~ /w/ && $port == port(8981)) {
118 select undef, undef, undef, 2.5; 118 select undef, undef, undef, 2.5;
119 } 119 }
120 120
121 $buffer = $port; 121 $buffer = $port;
122 122