Mercurial > hg > nginx-tests
annotate h2_proxy_max_temp_file_size.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 11463d379570 |
children |
rev | line source |
---|---|
1730
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for http proxy module, proxy_max_temp_file_size directive. |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(4); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF'); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
41 listen 127.0.0.1:8080; |
1730
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 server_name localhost; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
44 http2 on; |
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
45 |
1730
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 proxy_buffer_size 4k; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 proxy_buffers 8 4k; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 location / { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 proxy_max_temp_file_size 4k; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 proxy_pass http://127.0.0.1:8081/; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 location /off/ { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 proxy_max_temp_file_size 0; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 proxy_pass http://127.0.0.1:8081/; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 server { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 listen 127.0.0.1:8081; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 server_name localhost; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 location / { } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 EOF |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 $t->write_file('1', 'X' x (1024 * 1024)); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $t->run(); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 ############################################################################### |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 # test that the response is wholly proxied when all event pipe buffers are full |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 my $s = Test::Nginx::HTTP2->new(); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 my $sid = $s->new_stream({ path => '/1' }); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 select undef, undef, undef, 0.4; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 $s->h2_window(1024 * 1024, $sid); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 $s->h2_window(1024 * 1024); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 my $body = join '', map { $_->{data} } grep { $_->{type} eq "DATA" } @$frames; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 like($body, qr/^X+$/m, 'no pipe bufs - body'); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 is(length($body), 1024 * 1024, 'no pipe bufs - body length'); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 # also with disabled proxy temp file |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 $s = Test::Nginx::HTTP2->new(); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 $sid = $s->new_stream({ path => '/off/1' }); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 select undef, undef, undef, 0.4; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 $s->h2_window(1024 * 1024, $sid); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 $s->h2_window(1024 * 1024); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 $body = join '', map { $_->{data} } grep { $_->{type} eq "DATA" } @$frames; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 like($body, qr/^X+$/m, 'no temp file - body'); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 is(length($body), 1024 * 1024, 'no temp file - body length'); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 ############################################################################### |