Mercurial > hg > nginx-tests
annotate range_if_range.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 |
---|---|
173 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for range filter module with If-Range header. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
24 my $t = Test::Nginx->new()->has(qw/http/)->plan(8); | |
25 | |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
242
diff
changeset
|
30 daemon off; |
173 | 31 |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 listen 127.0.0.1:8080; |
173 | 40 server_name localhost; |
41 | |
42 location /t2.html { | |
43 add_header Last-Modified ""; | |
44 } | |
45 | |
46 location /t3.html { | |
47 add_header Last-Modified "Mon, 28 Sep 1970 06:00:00 GMT"; | |
48 } | |
49 } | |
50 } | |
51 | |
52 EOF | |
53 | |
54 $t->write_file('t1.html', | |
55 join('', map { sprintf "X%03dXXXXXX", $_ } (0 .. 99))); | |
56 $t->write_file('t2.html', | |
57 join('', map { sprintf "X%03dXXXXXX", $_ } (0 .. 99))); | |
58 $t->write_file('t3.html', | |
59 join('', map { sprintf "X%03dXXXXXX", $_ } (0 .. 99))); | |
60 $t->run(); | |
61 | |
62 ############################################################################### | |
63 | |
64 my $t1; | |
65 | |
66 # If-Range | |
67 | |
68 $t1 = http_get_range('/t1.html', "Range: bytes=0-9\nIf-Range: wrong"); | |
69 like($t1, qr/200 OK/, 'if-range wrong'); | |
70 like($t1, qr/Last-Modified: /, 'if-range wrong - last modified'); | |
71 | |
72 $t1 =~ m/Last-Modified: (.*)/m; | |
73 my $last = $1; | |
74 | |
75 $t1 = http_get_range('/t1.html', "Range: bytes=0-9\nIf-Range: $last"); | |
491
d5bf5942a8b2
Tests: disambiguated parsing of the status code.
Sergey Kandaurov <pluknet@nginx.com>
parents:
317
diff
changeset
|
76 like($t1, qr/ 206 /, 'if-range'); |
173 | 77 |
78 # If-Range + add_header Last-Modified "" | |
79 | |
80 $t1 = http_get_range('/t2.html', "Range: bytes=0-9\nIf-Range: wrong"); | |
81 like($t1, qr/200 OK/, 'if-range notime'); | |
82 unlike($t1, qr/Last-Modified: /, 'if-range notime - no last modified'); | |
83 | |
84 # If-Range + add_header Last-Modified "Mon, 28 Sep 1970 06:00:00 GMT" | |
85 | |
86 $t1 = http_get_range('/t3.html', "Range: bytes=0-9\nIf-Range: wrong"); | |
87 like($t1, qr/200 OK/, 'if-range time wrong'); | |
88 like($t1, qr/Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT/, | |
89 'if-range time wrong - last modified'); | |
90 | |
91 $t1 = http_get_range('/t3.html', | |
92 "Range: bytes=0-9\nIf-Range: Mon, 28 Sep 1970 06:00:00 GMT"); | |
491
d5bf5942a8b2
Tests: disambiguated parsing of the status code.
Sergey Kandaurov <pluknet@nginx.com>
parents:
317
diff
changeset
|
93 like($t1, qr/ 206 /, 'if-range time'); |
173 | 94 |
95 ############################################################################### | |
96 | |
97 sub http_get_range { | |
98 my ($url, $extra) = @_; | |
99 return http(<<EOF); | |
100 GET $url HTTP/1.1 | |
101 Host: localhost | |
102 Connection: close | |
103 $extra | |
104 | |
105 EOF | |
106 } | |
107 | |
108 ############################################################################### |