Mercurial > hg > nginx-tests
annotate upstream.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for upstream module and balancers. |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(3); |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 $t->write_file_expand('nginx.conf', <<'EOF'); |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 daemon off; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 events { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 http { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 upstream u { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 server 127.0.0.1:8081 max_fails=3 fail_timeout=10s; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
40 server 127.0.0.1:8082 max_fails=3 fail_timeout=10s; |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 upstream u2 { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
44 server 127.0.0.1:8081 max_fails=3 fail_timeout=10s; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
45 server 127.0.0.1:8082 max_fails=3 fail_timeout=10s; |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
49 listen 127.0.0.1:8080; |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 server_name localhost; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 location / { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 proxy_pass http://u; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 location /close2 { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 proxy_pass http://u2; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 EOF |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
63 $t->run_daemon(\&http_daemon, port(8081)); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
64 $t->run_daemon(\&http_daemon, port(8082)); |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 $t->run(); |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
67 $t->waitforsocket('127.0.0.1:' . port(8081)); |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
68 $t->waitforsocket('127.0.0.1:' . port(8082)); |
293
719285b89d7e
Tests: upstream.t minor fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
287
diff
changeset
|
69 |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 ############################################################################### |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
72 my @ports = my ($p1, $p2) = (port(8081), port(8082)); |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
343
diff
changeset
|
74 is(many('/', 30), "$p1: 15, $p2: 15", 'balanced'); |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
343
diff
changeset
|
75 |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
343
diff
changeset
|
76 # from 9 first requests to the first port, only 6 will be successful, |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 # 3rd, 6th, and 9th requests will fail; after this the backend |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 # will be considered down and won't be used till fail_timeout passes |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
343
diff
changeset
|
80 is(many('/close', 30), "$p1: 6, $p2: 24", 'failures'); |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 SKIP: { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 skip 'long test', 1 unless $ENV{TEST_NGINX_UNSAFE}; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 # bug: failures counter is reset if first request in a second succeeds |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 # |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 # delay added to make sure first 9 requests will take more than 1s; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 # note that the test is racy and may unexpectedly succeed |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
343
diff
changeset
|
90 is(many('/close2', 30, delay => 0.2), "$p1: 6, $p2: 24", 'failures delay'); |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 ############################################################################### |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 sub many { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 my ($uri, $count, %opts) = @_; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 my %ports; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 |
293
719285b89d7e
Tests: upstream.t minor fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
287
diff
changeset
|
100 for (1 .. $count) { |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 if (http_get($uri) =~ /X-Port: (\d+)/) { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 $ports{$1} = 0 unless defined $ports{$1}; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 $ports{$1}++; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 select undef, undef, undef, $opts{delay} if $opts{delay}; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 |
952
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
343
diff
changeset
|
109 my @keys = map { my $p = $_; grep { $p == $_ } keys %ports } @ports; |
e9064d691790
Tests: converted tests to run in parallel.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
343
diff
changeset
|
110 return join ', ', map { $_ . ": " . $ports{$_} } @keys; |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 ############################################################################### |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 sub http_daemon { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 my ($port) = @_; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 my $count = 1; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 my $server = IO::Socket::INET->new( |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 Proto => 'tcp', |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 LocalHost => '127.0.0.1', |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 LocalPort => $port, |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 Listen => 5, |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 Reuse => 1 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 ) |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 or die "Can't create listening socket: $!\n"; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 |
293
719285b89d7e
Tests: upstream.t minor fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
287
diff
changeset
|
128 local $SIG{PIPE} = 'IGNORE'; |
719285b89d7e
Tests: upstream.t minor fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
287
diff
changeset
|
129 |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 while (my $client = $server->accept()) { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 $client->autoflush(1); |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 my $headers = ''; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 my $uri = ''; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 while (<$client>) { |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 $headers .= $_; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 last if (/^\x0d?\x0a?$/); |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
143 if ($uri =~ 'close' && $port == port(8081) && $count++ % 3 == 0) |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
144 { |
287
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 next; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 print $client <<EOF; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 HTTP/1.1 200 OK |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 Connection: close |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 X-Port: $port |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 OK |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 EOF |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 close $client; |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 } |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 |
ba5b92378653
Tests: add some basic upstream tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 ############################################################################### |