Mercurial > hg > nginx-tests
annotate stream_upstream_hash.t @ 1046:a04323ab0622
Tests: use try_run() in debug_connection_syslog.t.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Wed, 05 Oct 2016 14:48:19 +0300 |
parents | 882267679006 |
children | 06fbf6269f38 |
rev | line source |
---|---|
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Stream tests for upstream hash balancer module. |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use IO::Select; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
816
77359b849cd5
Tests: stream package.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
711
diff
changeset
|
21 use Test::Nginx::Stream qw/ stream /; |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 ############################################################################### |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/stream stream_upstream_hash/)->plan(2); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 $t->write_file_expand('nginx.conf', <<'EOF'); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 %%TEST_GLOBALS%% |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 daemon off; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 events { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 stream { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 upstream hash { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 hash $remote_addr; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
42 server 127.0.0.1:8082; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
43 server 127.0.0.1:8083; |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 upstream cons { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 hash $remote_addr consistent; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 server 127.0.0.1:8082; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
49 server 127.0.0.1:8083; |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
53 listen 127.0.0.1:8080; |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 proxy_pass hash; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
58 listen 127.0.0.1:8081; |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 proxy_pass cons; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 EOF |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
65 $t->run_daemon(\&stream_daemon, port(8082)); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
66 $t->run_daemon(\&stream_daemon, port(8083)); |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 $t->run(); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
69 $t->waitforsocket('127.0.0.1:' . port(8082)); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
70 $t->waitforsocket('127.0.0.1:' . port(8083)); |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 ############################################################################### |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
74 my @ports = my ($port2, $port3) = (port(8082), port(8083)); |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
816
diff
changeset
|
75 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
76 is(many(10, port(8080)), "$port3: 10", 'hash'); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
77 like(many(10, port(8081)), qr/($port2|$port3): 10/, 'hash consistent'); |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 ############################################################################### |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 sub many { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
816
diff
changeset
|
82 my ($count, $port) = @_; |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
816
diff
changeset
|
83 my (%ports); |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 for (1 .. $count) { |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
816
diff
changeset
|
86 if (stream("127.0.0.1:$port")->io('.') =~ /(\d+)/) { |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 $ports{$1} = 0 unless defined $ports{$1}; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 $ports{$1}++; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
816
diff
changeset
|
92 my @keys = map { my $p = $_; grep { $p == $_ } keys %ports } @ports; |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
816
diff
changeset
|
93 return join ', ', map { $_ . ": " . $ports{$_} } @keys; |
571
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 ############################################################################### |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 sub stream_daemon { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 my ($port) = @_; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 my $server = IO::Socket::INET->new( |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 Proto => 'tcp', |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 LocalAddr => '127.0.0.1', |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 LocalPort => $port, |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 Listen => 5, |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 Reuse => 1 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 ) |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 or die "Can't create listening socket: $!\n"; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 my $sel = IO::Select->new($server); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 local $SIG{PIPE} = 'IGNORE'; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 while (my @ready = $sel->can_read) { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 foreach my $fh (@ready) { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 if ($server == $fh) { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 my $new = $fh->accept; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 $new->autoflush(1); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 $sel->add($new); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 } elsif (stream_handle_client($fh)) { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 $sel->remove($fh); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 $fh->close; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 sub stream_handle_client { |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 my ($client) = @_; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 log2c("(new connection $client)"); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 $client->sysread(my $buffer, 65536) or return 1; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 log2i("$client $buffer"); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 $buffer = $client->sockport(); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 log2o("$client $buffer"); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 $client->syswrite($buffer); |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 return 1; |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 sub log2i { Test::Nginx::log_core('|| <<', @_); } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 sub log2o { Test::Nginx::log_core('|| >>', @_); } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 sub log2c { Test::Nginx::log_core('||', @_); } |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 |
5c3946ebd867
Tests: basic stream tests for upstream hash.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 ############################################################################### |