Mercurial > hg > nginx-tests
comparison h2.t @ 758:70c486d09663
Tests: HTTP/2 circular stream dependency with exclusive dependency.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 28 Oct 2015 00:11:44 +0300 |
parents | 9187c6902b30 |
children | 6406eee6366c |
comparison
equal
deleted
inserted
replaced
757:9187c6902b30 | 758:70c486d09663 |
---|---|
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; | 30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; |
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; | 31 plan(skip_all => 'IO::Socket::SSL too old') if $@; |
32 | 32 |
33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) | 33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) |
34 ->has(qw/limit_conn rewrite realip shmem/) | 34 ->has(qw/limit_conn rewrite realip shmem/) |
35 ->has_daemon('openssl')->plan(240); | 35 ->has_daemon('openssl')->plan(243); |
36 | 36 |
37 # Some systems may have also a bug in not treating zero writev iovcnt as EINVAL | 37 # Some systems may have also a bug in not treating zero writev iovcnt as EINVAL |
38 | 38 |
39 $t->todo_alerts(); | 39 $t->todo_alerts(); |
40 | 40 |
2087 ($frame) = grep { $_->{type} eq "DATA" && $_->{sid} == $sid3 } @$frames; | 2087 ($frame) = grep { $_->{type} eq "DATA" && $_->{sid} == $sid3 } @$frames; |
2088 is($frame->{length}, 81, 'removed dependency - last stream'); | 2088 is($frame->{length}, 81, 'removed dependency - last stream'); |
2089 | 2089 |
2090 } | 2090 } |
2091 | 2091 |
2092 # PRIORITY - reprioritization with circular dependency - exclusive [5] | |
2093 # 1 <- [5] <- 3 | |
2094 | |
2095 SKIP: { | |
2096 skip 'leaves coredump', 3 unless $ENV{TEST_NGINX_UNSAFE}; | |
2097 | |
2098 $sess = new_session(); | |
2099 | |
2100 h2_window($sess, 2**18); | |
2101 | |
2102 h2_priority($sess, 16, 1, 0); | |
2103 h2_priority($sess, 16, 3, 1); | |
2104 h2_priority($sess, 16, 5, 1, excl => 1); | |
2105 | |
2106 $sid = new_stream($sess, { path => '/t1.html' }); | |
2107 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
2108 | |
2109 $sid2 = new_stream($sess, { path => '/t1.html' }); | |
2110 h2_read($sess, all => [{ sid => $sid2, length => 2**16 - 1 }]); | |
2111 | |
2112 $sid3 = new_stream($sess, { path => '/t1.html' }); | |
2113 h2_read($sess, all => [{ sid => $sid3, length => 2**16 - 1 }]); | |
2114 | |
2115 h2_window($sess, 2**16, $sid); | |
2116 | |
2117 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); | |
2118 $sids = join ' ', map { $_->{sid} } grep { $_->{type} eq "DATA" } @$frames; | |
2119 is($sids, $sid, 'exclusive dependency - parent removed'); | |
2120 | |
2121 # make circular dependency | |
2122 # 5 <- 3 -- current dependency tree before reprioritization | |
2123 # 3 <- 5 | |
2124 | |
2125 h2_priority($sess, 16, 5, 3); | |
2126 | |
2127 h2_window($sess, 2**16, $sid2); | |
2128 h2_window($sess, 2**16, $sid3); | |
2129 | |
2130 $frames = h2_read($sess, all => [ | |
2131 { sid => $sid2, fin => 1 }, | |
2132 { sid => $sid3, fin => 1 }, | |
2133 ]); | |
2134 | |
2135 ($frame) = grep { $_->{type} eq "DATA" && $_->{sid} == $sid2 } @$frames; | |
2136 is($frame->{length}, 81, 'exclusive dependency - first stream'); | |
2137 | |
2138 ($frame) = grep { $_->{type} eq "DATA" && $_->{sid} == $sid3 } @$frames; | |
2139 is($frame->{length}, 81, 'exclusive dependency - last stream'); | |
2140 | |
2141 } | |
2142 | |
2092 # limit_conn | 2143 # limit_conn |
2093 | 2144 |
2094 $sess = new_session(); | 2145 $sess = new_session(); |
2095 h2_settings($sess, 0, 0x4 => 1); | 2146 h2_settings($sess, 0, 0x4 => 1); |
2096 | 2147 |
2399 | 2450 |
2400 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x3, $stream, $error)); | 2451 raw_write($sess->{socket}, pack("x2C2xNN", 4, 0x3, $stream, $error)); |
2401 } | 2452 } |
2402 | 2453 |
2403 sub h2_priority { | 2454 sub h2_priority { |
2404 my ($sess, $w, $stream, $dep) = @_; | 2455 my ($sess, $w, $stream, $dep, %extra) = @_; |
2405 | 2456 |
2406 $stream = 0 unless defined $stream; | 2457 $stream = 0 unless defined $stream; |
2407 $dep = 0 unless defined $dep; | 2458 $dep = 0 unless defined $dep; |
2459 $dep |= $extra{excl} << 31 if exists $extra{excl}; | |
2408 raw_write($sess->{socket}, pack("x2C2xNNC", 5, 0x2, $stream, $dep, $w)); | 2460 raw_write($sess->{socket}, pack("x2C2xNNC", 5, 0x2, $stream, $dep, $w)); |
2409 } | 2461 } |
2410 | 2462 |
2411 sub h2_window { | 2463 sub h2_window { |
2412 my ($sess, $win, $stream) = @_; | 2464 my ($sess, $win, $stream) = @_; |