Mercurial > hg > nginx-tests
annotate ssi_include_big.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for nginx ssi bug with big includes. |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
28
8f1519472ece
Tests: unbreak and extend has() functionality.
Maxim Dounin <mdounin@mdounin.ru>
parents:
19
diff
changeset
|
12 use Test::More; |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
9
f772e2a1a13f
Tests: change directory to allow runing from outside.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
f772e2a1a13f
Tests: change directory to allow runing from outside.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6
diff
changeset
|
15 |
14
d4b74207a627
Tests: refactor common functions.
Maxim Dounin <mdounin@mdounin.ru>
parents:
12
diff
changeset
|
16 use lib 'lib'; |
93
5276d85d5040
Tests: add basic gzip tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
64
diff
changeset
|
17 use Test::Nginx qw/ :DEFAULT :gzip /; |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
121
8ac1faaddd2c
Tests: better handle various configure arguments.
Maxim Dounin <mdounin@mdounin.ru>
parents:
107
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http ssi rewrite gzip proxy/)->plan(8); |
15
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
25 |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
26 $t->write_file_expand('nginx.conf', <<'EOF'); |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
27 |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
104
diff
changeset
|
28 %%TEST_GLOBALS%% |
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
104
diff
changeset
|
29 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
166
diff
changeset
|
30 daemon off; |
15
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
31 |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
32 events { |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
33 } |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
34 |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
35 http { |
107
1c0ec30614c6
Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
104
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
35
7bf0e8a1d66c
Tests: always define temp paths.
Maxim Dounin <mdounin@mdounin.ru>
parents:
32
diff
changeset
|
37 |
15
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
38 output_buffers 2 512; |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
39 ssi on; |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
40 gzip on; |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
41 |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
42 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
43 listen 127.0.0.1:8080; |
15
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
44 server_name localhost; |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
45 |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
46 location /proxy/ { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
47 proxy_pass http://127.0.0.1:8080/local/; |
15
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
48 } |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
49 location = /local/blah { |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
50 return 204; |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
51 } |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
52 } |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
53 } |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
54 |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
55 EOF |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 |
14
d4b74207a627
Tests: refactor common functions.
Maxim Dounin <mdounin@mdounin.ru>
parents:
12
diff
changeset
|
57 $t->write_file('c1.html', 'X' x 1023); |
d4b74207a627
Tests: refactor common functions.
Maxim Dounin <mdounin@mdounin.ru>
parents:
12
diff
changeset
|
58 $t->write_file('c2.html', 'X' x 1024); |
d4b74207a627
Tests: refactor common functions.
Maxim Dounin <mdounin@mdounin.ru>
parents:
12
diff
changeset
|
59 $t->write_file('c3.html', 'X' x 1025); |
39
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
60 $t->write_file('test1.html', '<!--#include virtual="/proxy/blah" -->' |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 . '<!--#include virtual="/c1.html" -->'); |
39
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
62 $t->write_file('test2.html', '<!--#include virtual="/proxy/blah" -->' |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 . '<!--#include virtual="/c2.html" -->'); |
39
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
64 $t->write_file('test3.html', '<!--#include virtual="/proxy/blah" -->' |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 . '<!--#include virtual="/c3.html" -->'); |
39
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
66 $t->write_file('test4.html', '<!--#include virtual="/proxy/blah" -->' |
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
67 . ('X' x 1025)); |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
15
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
69 $t->run(); |
c6c36d7a4d90
Tests: support config embedded in test itself.
Maxim Dounin <mdounin@mdounin.ru>
parents:
14
diff
changeset
|
70 |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 ############################################################################### |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 my $t1 = http_gzip_request('/test1.html'); |
6
8813a78ab8b5
Tests: drop LWP dependency.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5
diff
changeset
|
74 ok(defined $t1, 'small included file (less than output_buffers)'); |
39
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
75 http_gzip_like($t1, qr/^X{1023}\Z/, 'small included file content'); |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 my $t2 = http_gzip_request('/test2.html'); |
6
8813a78ab8b5
Tests: drop LWP dependency.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5
diff
changeset
|
78 ok(defined $t2, 'small included file (equal to output_buffers)'); |
39
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
79 http_gzip_like($t2, qr/^X{1024}\Z/, 'small included file content'); |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 |
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 my $t3 = http_gzip_request('/test3.html'); |
6
8813a78ab8b5
Tests: drop LWP dependency.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5
diff
changeset
|
82 ok(defined $t3, 'big included file (more than output_buffers)'); |
39
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
83 http_gzip_like($t3, qr/^X{1025}\Z/, 'big included file content'); |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 |
39
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
85 my $t4 = http_gzip_request('/test4.html'); |
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
86 ok(defined $t4, 'big ssi main file'); |
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
87 http_gzip_like($t4, qr/^X{1025}\Z/, 'big ssi main file content'); |
fc205d0e052d
Tests: check content returned from ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
35
diff
changeset
|
88 |
5
4d75bdb05ecf
Tests: some generic code and ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 ############################################################################### |