Mercurial > hg > nginx-tests
comparison h2_max_requests.t @ 1077:13247bbc1f7d
Tests: HTTP/2 tests for max requests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 31 Oct 2016 19:09:36 +0300 |
parents | |
children | 766bcbb632ee |
comparison
equal
deleted
inserted
replaced
1076:4240cca68d1d | 1077:13247bbc1f7d |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for HTTP/2 protocol, http2_max_requests directive. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::HTTP2; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
26 my $t = Test::Nginx->new()->has(qw/http http_v2/) | |
27 ->write_file_expand('nginx.conf', <<'EOF'); | |
28 | |
29 %%TEST_GLOBALS%% | |
30 | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 server { | |
40 listen 127.0.0.1:8080 http2; | |
41 server_name localhost; | |
42 | |
43 http2_max_requests 2; | |
44 | |
45 location / { } | |
46 } | |
47 } | |
48 | |
49 EOF | |
50 | |
51 $t->write_file('index.html', ''); | |
52 $t->try_run('no http2_max_requests')->plan(5); | |
53 | |
54 ############################################################################### | |
55 | |
56 my $s = Test::Nginx::HTTP2->new(); | |
57 my $frames = $s->read(all => [{ sid => $s->new_stream(), fin => 1 }]); | |
58 | |
59 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
60 is($frame->{headers}->{':status'}, 200, 'max requests'); | |
61 | |
62 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5) | |
63 unless grep { $_->{type} eq "GOAWAY" } @$frames; | |
64 | |
65 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
66 is($frame, undef, 'max requests - GOAWAY'); | |
67 | |
68 # max requests limited | |
69 | |
70 my $sid = $s->new_stream(); | |
71 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); | |
72 | |
73 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
74 is($frame->{headers}->{':status'}, 200, 'max requests limited'); | |
75 | |
76 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
77 ok($frame, 'max requests limited - GOAWAY'); | |
78 is($frame->{last_sid}, $sid, 'max requests limited - GOAWAY last stream'); | |
79 | |
80 ############################################################################### |