Mercurial > hg > nginx-tests
annotate charset_gzip_static.t @ 1752:ba6e24e38f03
Tests: improved stop_daemons() to send signal again.
As was observed, it's possible that a signal to complete a uwsgi daemon
can be ignored while it is starting up, which results in tests hang due
to eternal waiting on child processes termination. Notably, it is seen
when running tests with a high number of prove jobs on a low-profile VM
against nginx with broken modules and/or configuration. To reproduce:
$ TEST_NGINX_GLOBALS=ERROR prove -j16 uwsgi*.t
Inspecting uwsgi under ktrace on FreeBSD confirms that a SIGTERM signal
is ignored at the very beginning of uwsgi startup. It is then replaced
with a default action after listen(), thus waiting until uwsgi is ready
to accept new TCP connections doesn't completely solve the hang window.
The fix is to retry sending a signal some time after waitpid(WNOHANG)
continuously demonstrated no progress with reaping a signaled process.
It is modelled after f13ead27f89c that improved stop() for nginx.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 29 Dec 2021 22:29:23 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
399 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for charset filter. | |
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 qw/ :DEFAULT :gzip /; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
914
3ac4036b139d
Tests: fixed proxy prerequisites.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy charset gzip_static/)->plan(13) |
399 | 26 ->write_file_expand('nginx.conf', <<'EOF')->run(); |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 daemon off; | |
31 | |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 types { | |
39 text/html html; | |
40 } | |
41 | |
42 charset_map B A { | |
43 58 59; # X -> Y | |
44 } | |
45 | |
46 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
47 listen 127.0.0.1:8080; |
399 | 48 server_name localhost; |
49 | |
50 location /t1 { | |
51 charset utf-8; | |
52 gzip_static on; | |
53 } | |
54 | |
55 location /t2 { | |
56 gzip_static on; | |
57 charset A; | |
58 source_charset B; | |
59 } | |
60 | |
61 location /t { | |
62 gzip_static on; | |
63 } | |
64 | |
65 location /p/ { | |
66 charset utf-8; | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
67 proxy_pass http://127.0.0.1:8080/; |
399 | 68 proxy_http_version 1.1; |
69 } | |
70 | |
71 location /p.ab/ { | |
72 charset A; | |
73 source_charset B; | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
74 proxy_pass http://127.0.0.1:8080/; |
399 | 75 proxy_http_version 1.1; |
76 } | |
77 | |
78 location /p.aa/ { | |
79 charset A; | |
80 source_charset A; | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
81 proxy_pass http://127.0.0.1:8080/; |
399 | 82 proxy_http_version 1.1; |
83 } | |
84 } | |
85 } | |
86 | |
87 EOF | |
88 | |
89 $t->write_file('t1.html', ''); | |
90 $t->write_file('t1.html.gz', ''); | |
91 | |
92 my $in = 'X' x 99; | |
942
8582afc64efa
Tests: avoid uninitialized warnings in charset_gzip_static.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
914
diff
changeset
|
93 my $out = ''; |
399 | 94 |
95 eval { | |
405
a8bfad2a3f84
Tests: whitespace fix.
Sergey Kandaurov <pluknet@nginx.com>
parents:
403
diff
changeset
|
96 require IO::Compress::Gzip; |
399 | 97 IO::Compress::Gzip::gzip(\$in => \$out); |
98 }; | |
99 | |
100 $t->write_file('t2.html', $in); | |
101 $t->write_file('t2.html.gz', $out); | |
102 | |
103 $t->write_file('t.html', ''); | |
104 $t->write_file('t.html.gz', ''); | |
105 | |
106 ############################################################################### | |
107 | |
108 # charset filter currently ignores responses with Content-Encoding set | |
109 # (except ones with r->ignore_content_encoding used by gzip_static) | |
110 # as it can't convert such content; there are two problems though: | |
111 # | |
112 # - it make sense to indicate charset | |
113 # if conversion isn't needed | |
114 # | |
115 # - gzip_static may need conversion, too | |
116 # | |
117 # proper solution seems to be to always allow charset indication, but | |
118 # don't try to do anything if recoding is needed | |
119 | |
120 like(http_get('/t1.html'), qr!text/html; charset=!, 'plain'); | |
121 like(http_gzip_request('/t1.html'), qr!text/html; charset=.*gzip!ms, 'gzip'); | |
122 | |
123 like(http_get('/t2.html'), qr!text/html; charset=A.*Y{99}!ms, 'recode plain'); | |
124 like(http_gzip_request('/t2.html'), qr!text/html\x0d.*gzip!ms, 'recode gzip'); | |
125 http_gzip_like(http_gzip_request('/t2.html'), qr!X{99}!, 'recode content'); | |
126 | |
127 like(http_get('/t.html'), qr!text/html\x0d!, 'nocharset plain'); | |
128 like(http_gzip_request('/t.html'), qr!text/html\x0d.*gzip!ms, 'nocharset gzip'); | |
129 | |
130 like(http_get('/p/t.html'), qr!text/html; charset=!, 'proxy plain'); | |
131 like(http_gzip_request('/p/t.html'), qr!text/html; charset=.*gzip!ms, | |
132 'proxy gzip'); | |
133 | |
134 like(http_get('/p.ab/t.html'), qr!text/html; charset=A!ms, | |
135 'proxy recode plain'); | |
401
2961a6a83809
Tests: fixed charset_gzip_static.t tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
399
diff
changeset
|
136 like(http_gzip_request('/p.ab/t.html'), qr!text/html\x0d.*gzip!ms, |
399 | 137 'proxy recode gzip'); |
138 | |
401
2961a6a83809
Tests: fixed charset_gzip_static.t tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
399
diff
changeset
|
139 like(http_get('/p.aa/t.html'), qr!text/html; charset=A!ms, |
399 | 140 'proxy nullrecode plain'); |
401
2961a6a83809
Tests: fixed charset_gzip_static.t tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
399
diff
changeset
|
141 like(http_gzip_request('/p.aa/t.html'), qr!text/html; charset=A.*gzip!ms, |
399 | 142 'proxy nullrecode gzip'); |
143 | |
144 ############################################################################### |