annotate proxy_ssl.t @ 1427:eb1d883305ea

Tests: avoid edge cases in upstream random two test. Unavailable servers contribute to the number of attempts, if selected, before the balancer would fall back to the default round-robin method. This means that it's quite possible to get server with more connections. To facilitate with selecting two alive servers, down server was removed from the upstream configuration at the cost of slightly worse coverage.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 10 Jan 2019 17:42:34 +0300
parents eb727c5ccef6
children dbce8fb5f5f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Nginx, Inc.
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5 # Tests for proxy to ssl backend.
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7 ###############################################################################
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9 use warnings;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use strict;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12 use Test::More;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16 use lib 'lib';
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use Test::Nginx;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 ###############################################################################
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 select STDERR; $| = 1;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDOUT; $| = 1;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
24 eval { require IO::Socket::SSL; };
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
25 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
26
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 my $t = Test::Nginx->new()->has(qw/http proxy http_ssl/)->has_daemon('openssl')
1197
155573499f20 Tests: more ssl session tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1196
diff changeset
28 ->plan(7)->write_file_expand('nginx.conf', <<'EOF');
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 %%TEST_GLOBALS%%
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 daemon off;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 events {
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 http {
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS_HTTP%%
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
41 listen 127.0.0.1:8081 ssl;
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 ssl_certificate_key localhost.key;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 ssl_certificate localhost.crt;
437
8b4a6b8691eb Tests: set ssl_session_cache.
Sergey Kandaurov <pluknet@nginx.com>
parents: 435
diff changeset
45 ssl_session_cache builtin;
435
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
46
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
47 location / {
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
48 add_header X-Session $ssl_session_reused;
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
49 }
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
ad164c14058a Tests: basic proxy tests to ssl backend.
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;
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 server_name localhost;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 location /ssl_reuse {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
57 proxy_pass https://127.0.0.1:8081/;
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 proxy_ssl_session_reuse on;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 location /ssl {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
62 proxy_pass https://127.0.0.1:8081/;
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 proxy_ssl_session_reuse off;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 }
732
984bfe661cce Tests: stream and http proxy_connect_timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 437
diff changeset
65
984bfe661cce Tests: stream and http proxy_connect_timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 437
diff changeset
66 location /timeout {
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
67 proxy_pass https://127.0.0.1:8082;
1264
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
68 proxy_connect_timeout 3s;
732
984bfe661cce Tests: stream and http proxy_connect_timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 437
diff changeset
69 }
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
70
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
71 location /timeout_h {
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
72 proxy_pass https://127.0.0.1:8083;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
73 proxy_connect_timeout 1s;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
74 }
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 EOF
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 $t->write_file('openssl.conf', <<EOF);
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 [ req ]
1116
8ef51dbb5d69 Tests: reduced OpenSSL default key length to 1024.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1084
diff changeset
82 default_bits = 1024
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 encrypt_key = no
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 distinguished_name = req_distinguished_name
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 [ req_distinguished_name ]
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 EOF
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 $t->write_file('index.html', '');
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 my $d = $t->testdir();
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 foreach my $name ('localhost') {
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1197
diff changeset
94 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1197
diff changeset
95 . "-out $d/$name.crt -keyout $d/$name.key "
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 . ">>$d/openssl.out 2>&1") == 0
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97 or die "Can't create certificate for $name: $!\n";
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
100 $t->run_daemon(\&http_daemon, port(8082));
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
101 $t->run_daemon(\&http_daemon, port(8083));
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 $t->run();
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
103 $t->waitforsocket('127.0.0.1:' . port(8082));
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
104 $t->waitforsocket('127.0.0.1:' . port(8083));
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106 ###############################################################################
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107
435
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
108 like(http_get('/ssl'), qr/200 OK.*X-Session: \./s, 'ssl');
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
109 like(http_get('/ssl'), qr/200 OK.*X-Session: \./s, 'ssl 2');
1196
68c8f2778c50 Tests: consistent proxy ssl test names.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
110 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: \./s, 'ssl session new');
68c8f2778c50 Tests: consistent proxy ssl test names.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
111 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: r/s, 'ssl session reused');
1197
155573499f20 Tests: more ssl session tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1196
diff changeset
112 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: r/s, 'ssl session reused 2');
1264
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
113
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
114 SKIP: {
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
115 skip 'long test', 1 unless $ENV{TEST_NGINX_UNSAFE};
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
116
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
117 like(http_get('/timeout'), qr/200 OK/, 'proxy connect timeout');
1264
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
118
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
119 }
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
120
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
121 like(http_get('/timeout_h'), qr/504 Gateway/, 'proxy handshake timeout');
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
122
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123 ###############################################################################
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
124
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
125 sub http_daemon {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
126 my ($port) = @_;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
127 my $server = IO::Socket::INET->new(
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
128 Proto => 'tcp',
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
129 LocalHost => '127.0.0.1:' . $port,
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
130 Listen => 5,
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
131 Reuse => 1
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
132 )
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
133 or die "Can't create listening socket: $!\n";
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
134
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
135 local $SIG{PIPE} = 'IGNORE';
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
136
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
137 while (my $client = $server->accept()) {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
138 $client->autoflush(1);
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
139
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
140 if ($port == port(8083)) {
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
141 sleep 3;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
142
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
143 close $client;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
144 next;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
145 }
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
146
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
147 my $headers = '';
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
148 my $uri = '';
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
149
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
150 # would fail on waitforsocket
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
151
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
152 eval {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
153 IO::Socket::SSL->start_SSL($client,
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
154 SSL_server => 1,
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
155 SSL_cert_file => "$d/localhost.crt",
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
156 SSL_key_file => "$d/localhost.key",
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
157 SSL_error_trap => sub { die $_[1] }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
158 );
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
159 };
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
160 next if $@;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
161
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
162 while (<$client>) {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
163 $headers .= $_;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
164 last if (/^\x0d?\x0a?$/);
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
165 }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
166
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
167 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
168 next if $uri eq '';
1084
ce3d15edbf05 Tests: whitespace fix.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1080
diff changeset
169
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
170 if ($uri eq '/timeout') {
1264
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
171 sleep 4;
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
172
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
173 print $client <<EOF;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
174 HTTP/1.1 200 OK
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
175 Connection: close
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
176
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
177 EOF
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
178 }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
179
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
180 close $client;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
181 }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
182 }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
183
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
184 ###############################################################################