comparison h2_limit_conn.t @ 948:4dc302d8e04f

Tests: changed HTTP2 package to act as a class. Stopped exporting any subroutines. A subset of them now act as class methods.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 17 Jun 2016 11:36:33 +0300
parents d73bef563aea
children e9064d691790
comparison
equal deleted inserted replaced
947:b9e42c554ba7 948:4dc302d8e04f
14 14
15 BEGIN { use FindBin; chdir($FindBin::Bin); } 15 BEGIN { use FindBin; chdir($FindBin::Bin); }
16 16
17 use lib 'lib'; 17 use lib 'lib';
18 use Test::Nginx; 18 use Test::Nginx;
19 use Test::Nginx::HTTP2 qw/ :DEFAULT :frame /; 19 use Test::Nginx::HTTP2;
20 20
21 ############################################################################### 21 ###############################################################################
22 22
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
53 $t->write_file('t.html', 'SEE-THIS'); 53 $t->write_file('t.html', 'SEE-THIS');
54 $t->run(); 54 $t->run();
55 55
56 ############################################################################### 56 ###############################################################################
57 57
58 my $sess = new_session(); 58 my $s = Test::Nginx::HTTP2->new();
59 h2_settings($sess, 0, 0x4 => 1); 59 $s->h2_settings(0, 0x4 => 1);
60 60
61 my $sid = new_stream($sess, { path => '/t.html' }); 61 my $sid = $s->new_stream({ path => '/t.html' });
62 my $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]); 62 my $frames = $s->read(all => [{ sid => $sid, length => 1 }]);
63 63
64 my ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; 64 my ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
65 is($frame->{headers}->{':status'}, 200, 'limit_conn first stream'); 65 is($frame->{headers}->{':status'}, 200, 'limit_conn first stream');
66 66
67 my $sid2 = new_stream($sess, { path => '/t.html' }); 67 my $sid2 = $s->new_stream({ path => '/t.html' });
68 $frames = h2_read($sess, all => [{ sid => $sid2, length => 1 }]); 68 $frames = $s->read(all => [{ sid => $sid2, length => 1 }]);
69 69
70 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames; 70 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames;
71 is($frame->{headers}->{':status'}, 503, 'limit_conn rejected'); 71 is($frame->{headers}->{':status'}, 503, 'limit_conn rejected');
72 72
73 h2_settings($sess, 0, 0x4 => 2**16); 73 $s->h2_settings(0, 0x4 => 2**16);
74 74
75 h2_read($sess, all => [ 75 $s->read(all => [
76 { sid => $sid, fin => 1 }, 76 { sid => $sid, fin => 1 },
77 { sid => $sid2, fin => 1 } 77 { sid => $sid2, fin => 1 }
78 ]); 78 ]);
79 79
80 # limit_conn + client's RST_STREAM 80 # limit_conn + client's RST_STREAM
81 81
82 $sess = new_session(); 82 $s = Test::Nginx::HTTP2->new();
83 h2_settings($sess, 0, 0x4 => 1); 83 $s->h2_settings(0, 0x4 => 1);
84 84
85 $sid = new_stream($sess, { path => '/t.html' }); 85 $sid = $s->new_stream({ path => '/t.html' });
86 $frames = h2_read($sess, all => [{ sid => $sid, length => 1 }]); 86 $frames = $s->read(all => [{ sid => $sid, length => 1 }]);
87 h2_rst($sess, $sid, 5); 87 $s->h2_rst($sid, 5);
88 88
89 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames; 89 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid } @$frames;
90 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1'); 90 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 1');
91 91
92 $sid2 = new_stream($sess, { path => '/t.html' }); 92 $sid2 = $s->new_stream({ path => '/t.html' });
93 $frames = h2_read($sess, all => [{ sid => $sid2, length => 1 }]); 93 $frames = $s->read(all => [{ sid => $sid2, length => 1 }]);
94 94
95 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames; 95 ($frame) = grep { $_->{type} eq "HEADERS" && $_->{sid} == $sid2 } @$frames;
96 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2'); 96 is($frame->{headers}->{':status'}, 200, 'RST_STREAM 2');
97 97
98 ############################################################################### 98 ###############################################################################