Mercurial > hg > nginx-tests
annotate 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 | 696322b7e2c3 |
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 qw/ :DEFAULT http_content /; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
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 select STDERR; $| = 1; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(4); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
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 http { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 server { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 listen 127.0.0.1:8080 sndbuf=32k; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server_name localhost; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 proxy_buffer_size 4k; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 proxy_buffers 8 4k; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 location / { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 proxy_max_temp_file_size 4k; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 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
|
49 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location /off/ { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 proxy_max_temp_file_size 0; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 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
|
54 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 server { |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 listen 127.0.0.1:8081; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 server_name localhost; |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 location / { } |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
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 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 EOF |
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 $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
|
68 $t->run(); |
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 ############################################################################### |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 # 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
|
73 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 my $body = http_content(http_get('/1', sleep => 0.4)); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 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
|
76 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
|
77 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 # also with disabled proxy temp file |
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 $body = http_content(http_get('/off/1', sleep => 0.4)); |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 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
|
82 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
|
83 |
696322b7e2c3
Tests: added proxy_max_temp_file_size tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 ############################################################################### |