annotate h2_ssl.t @ 1752:ba6e24e38f03

Tests: improved stop_daemons() to send signal again. As was observed, it's possible that a signal to complete a uwsgi daemon can be ignored while it is starting up, which results in tests hang due to eternal waiting on child processes termination. Notably, it is seen when running tests with a high number of prove jobs on a low-profile VM against nginx with broken modules and/or configuration. To reproduce: $ TEST_NGINX_GLOBALS=ERROR prove -j16 uwsgi*.t Inspecting uwsgi under ktrace on FreeBSD confirms that a SIGTERM signal is ignored at the very beginning of uwsgi startup. It is then replaced with a default action after listen(), thus waiting until uwsgi is ready to accept new TCP connections doesn't completely solve the hang window. The fix is to retry sending a signal some time after waitpid(WNOHANG) continuously demonstrated no progress with reaping a signaled process. It is modelled after f13ead27f89c that improved stop() for nginx.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 29 Dec 2021 22:29:23 +0300
parents 38bd7e75fe69
children 78fe648d54a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for HTTP/2 protocol with ssl.
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 use Test::Nginx::HTTP2;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 ###############################################################################
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2/)
1033
45c80276d691 Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 997
diff changeset
27 ->has_daemon('openssl');
45c80276d691 Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 997
diff changeset
28
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 $t->write_file_expand('nginx.conf', <<'EOF');
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 %%TEST_GLOBALS%%
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 daemon off;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 events {
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 }
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 http {
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 %%TEST_GLOBALS_HTTP%%
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 server {
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 listen 127.0.0.1:8080 http2 ssl;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 server_name localhost;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 ssl_certificate_key localhost.key;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 ssl_certificate localhost.crt;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47
1654
341506267e16 Tests: HTTP/2 tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1488
diff changeset
48 lingering_close off;
341506267e16 Tests: HTTP/2 tests speedup.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1488
diff changeset
49
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 location / { }
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 }
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 }
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 EOF
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
56 eval { require IO::Socket::SSL; die if $IO::Socket::SSL::VERSION < 1.56; };
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
57 plan(skip_all => 'IO::Socket::SSL version >= 1.56 required') if $@;
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
58
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
59 eval { IO::Socket::SSL->can_alpn() or die; };
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
60 plan(skip_all => 'IO::Socket::SSL with OpenSSL ALPN support required') if $@;
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
61
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
62 eval { exists &Net::SSLeay::P_alpn_selected or die; };
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
63 plan(skip_all => 'Net::SSLeay with OpenSSL ALPN support required') if $@;
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
64
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 $t->write_file('openssl.conf', <<EOF);
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 [ req ]
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1220
diff changeset
67 default_bits = 2048
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 encrypt_key = no
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 distinguished_name = req_distinguished_name
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 [ req_distinguished_name ]
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 EOF
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 my $d = $t->testdir();
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 foreach my $name ('localhost') {
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
77 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
78 . "-out $d/$name.crt -keyout $d/$name.key "
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 . ">>$d/openssl.out 2>&1") == 0
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 or die "Can't create certificate for $name: $!\n";
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 }
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
83 $t->write_file('index.html', '');
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 $t->write_file('tbig.html',
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 join('', map { sprintf "XX%06dXX", $_ } (1 .. 500000)));
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 open OLDERR, ">&", \*STDERR; close STDERR;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 $t->run();
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 open STDERR, ">&", \*OLDERR;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
91 plan(skip_all => 'no ALPN negotiation') unless defined getconn();
1741
3408029c09f5 Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1740
diff changeset
92 $t->plan(3);
1033
45c80276d691 Tests: unbreak for nginx built with OpenSSL without NPN/ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 997
diff changeset
93
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 ###############################################################################
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95
1743
2318ed01ce53 Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1741
diff changeset
96 SKIP: {
2318ed01ce53 Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1741
diff changeset
97 $t->{_configure_args} =~ /LibreSSL ([\d\.]+)/;
2318ed01ce53 Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1741
diff changeset
98 skip 'LibreSSL too old', 1 if defined $1 and $1 lt '3.4.0';
1744
38bd7e75fe69 Tests: skip ALPN rejection tests with OpenSSL < 1.1.0.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1743
diff changeset
99 $t->{_configure_args} =~ /OpenSSL ([\d\.]+)/;
38bd7e75fe69 Tests: skip ALPN rejection tests with OpenSSL < 1.1.0.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1743
diff changeset
100 skip 'OpenSSL too old', 1 if defined $1 and $1 lt '1.1.0';
1743
2318ed01ce53 Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1741
diff changeset
101
1741
3408029c09f5 Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1740
diff changeset
102 TODO: {
3408029c09f5 Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1740
diff changeset
103 local $TODO = 'not yet' unless $t->has_version('1.21.4');
3408029c09f5 Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1740
diff changeset
104
3408029c09f5 Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1740
diff changeset
105 ok(!get_ssl_socket(['unknown']), 'alpn rejected');
3408029c09f5 Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1740
diff changeset
106
3408029c09f5 Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1740
diff changeset
107 }
3408029c09f5 Tests: added HTTP/2 test with rejected ALPN.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1740
diff changeset
108
1743
2318ed01ce53 Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1741
diff changeset
109 }
2318ed01ce53 Tests: skip ALPN rejection tests with too old LibreSSL.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1741
diff changeset
110
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
111 like(http_get('/', socket => get_ssl_socket(['http/1.1'])),
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
112 qr/200 OK/, 'alpn to HTTP/1.1 fallback');
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
113
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
114 my $s = getconn(['http/1.1', 'h2']);
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
115 my $sid = $s->new_stream();
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
116 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
117 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
118 is($frame->{headers}->{':status'}, 200, 'alpn to HTTP/2');
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
119
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
120 # client cancels last stream after HEADERS has been created,
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121 # while some unsent data was left in the SSL buffer
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122 # HEADERS frame may stuck in SSL buffer and won't be sent producing alert
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
124 $sid = $s->new_stream({ path => '/tbig.html' });
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 select undef, undef, undef, 0.2;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 $s->h2_rst($sid, 8);
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129 $sid = $s->new_stream({ path => '/tbig.html' });
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 select undef, undef, undef, 0.2;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 $s->h2_rst($sid, 8);
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 $t->stop();
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136 ###############################################################################
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 sub getconn {
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
139 my ($alpn) = @_;
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
140 $alpn = ['h2'] if !defined $alpn;
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
141
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
142 my $sock = get_ssl_socket($alpn);
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
143 my $s = Test::Nginx::HTTP2->new(undef, socket => $sock)
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
144 if $sock->alpn_selected();
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
145 }
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
146
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
147 sub get_ssl_socket {
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
148 my ($alpn) = @_;
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149 my $s;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 eval {
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
152 local $SIG{ALRM} = sub { die "timeout\n" };
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
153 local $SIG{PIPE} = sub { die "sigpipe\n" };
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
154 alarm(8);
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
155 $s = IO::Socket::SSL->new(
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
156 Proto => 'tcp',
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
157 PeerAddr => '127.0.0.1',
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
158 PeerPort => port(8080),
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
159 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
160 SSL_alpn_protocols => $alpn,
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
161 SSL_error_trap => sub { die $_[1] }
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
162 );
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
163 alarm(0);
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
164 };
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
165 alarm(0);
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166
1740
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
167 if ($@) {
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
168 log_in("died: $@");
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
169 return undef;
f7e667a4898d Tests: added HTTP/2 test for ALPN fallback to HTTP/1.1.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1654
diff changeset
170 }
986
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
171
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172 return $s;
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173 }
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174
99f93be57416 Tests: various HTTP/2 tests with canceled stream.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 ###############################################################################