Mercurial > hg > nginx-tests
comparison h2.t @ 662:07de3d202eb7
Tests: more HTTP/2 tests for streams priority.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 24 Aug 2015 20:14:41 +0300 |
parents | c99c30afc1c9 |
children | 0247e314e991 |
comparison
equal
deleted
inserted
replaced
661:c99c30afc1c9 | 662:07de3d202eb7 |
---|---|
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(153); | 35 ->has_daemon('openssl')->plan(155); |
36 | 36 |
37 $t->write_file_expand('nginx.conf', <<'EOF'); | 37 $t->write_file_expand('nginx.conf', <<'EOF'); |
38 | 38 |
39 %%TEST_GLOBALS%% | 39 %%TEST_GLOBALS%% |
40 | 40 |
1267 ]); | 1267 ]); |
1268 | 1268 |
1269 @data = grep { $_->{type} eq "DATA" } @$frames; | 1269 @data = grep { $_->{type} eq "DATA" } @$frames; |
1270 $sids = join ' ', map { $_->{sid} } @data; | 1270 $sids = join ' ', map { $_->{sid} } @data; |
1271 is($sids, "$sid $sid2", 'dependency - HEADERS PRIORITY 2'); | 1271 is($sids, "$sid $sid2", 'dependency - HEADERS PRIORITY 2'); |
1272 | |
1273 # PRIORITY frame, weighted dependencies | |
1274 | |
1275 $sess = new_session(); | |
1276 | |
1277 h2_priority($sess, 16, 5, 0); | |
1278 h2_priority($sess, 255, 1, 5); | |
1279 h2_priority($sess, 0, 3, 5); | |
1280 | |
1281 $sid = new_stream($sess, { path => '/t1.html' }); | |
1282 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1283 | |
1284 $sid2 = new_stream($sess, { path => '/t2.html' }); | |
1285 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1286 | |
1287 my $sid3 = new_stream($sess, { path => '/t2.html' }); | |
1288 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1289 | |
1290 h2_window($sess, 2**16, 1); | |
1291 h2_window($sess, 2**16, 3); | |
1292 h2_window($sess, 2**16, 5); | |
1293 h2_window($sess, 2**16); | |
1294 | |
1295 $frames = h2_read($sess, all => [ | |
1296 { sid => $sid, fin => 1 }, | |
1297 { sid => $sid2, fin => 1 }, | |
1298 { sid => $sid3, fin => 1 }, | |
1299 ]); | |
1300 | |
1301 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1302 $sids = join ' ', map { $_->{sid} } @data; | |
1303 is($sids, "$sid3 $sid $sid2", 'weighted dependency - PRIORITY 1'); | |
1304 | |
1305 # and vice versa | |
1306 | |
1307 $sess = new_session(); | |
1308 | |
1309 h2_priority($sess, 16, 5, 0); | |
1310 h2_priority($sess, 0, 1, 5); | |
1311 h2_priority($sess, 255, 3, 5); | |
1312 | |
1313 $sid = new_stream($sess, { path => '/t1.html' }); | |
1314 h2_read($sess, all => [{ sid => $sid, length => 2**16 - 1 }]); | |
1315 | |
1316 $sid2 = new_stream($sess, { path => '/t2.html' }); | |
1317 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1318 | |
1319 $sid3 = new_stream($sess, { path => '/t2.html' }); | |
1320 h2_read($sess, all => [{ sid => $sid2, fin => 0x4 }]); | |
1321 | |
1322 h2_window($sess, 2**16, 1); | |
1323 h2_window($sess, 2**16, 3); | |
1324 h2_window($sess, 2**16, 5); | |
1325 h2_window($sess, 2**16); | |
1326 | |
1327 $frames = h2_read($sess, all => [ | |
1328 { sid => $sid, fin => 1 }, | |
1329 { sid => $sid2, fin => 1 }, | |
1330 { sid => $sid3, fin => 1 }, | |
1331 ]); | |
1332 | |
1333 @data = grep { $_->{type} eq "DATA" } @$frames; | |
1334 $sids = join ' ', map { $_->{sid} } @data; | |
1335 is($sids, "$sid3 $sid2 $sid", 'weighted dependency - PRIORITY 2'); | |
1272 | 1336 |
1273 # limit_conn | 1337 # limit_conn |
1274 | 1338 |
1275 $sess = new_session(); | 1339 $sess = new_session(); |
1276 h2_settings($sess, 0, 0x4 => 1); | 1340 h2_settings($sess, 0, 0x4 => 1); |