Mercurial > hg > nginx-tests
annotate userid_flags.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 | 5ac6efbe5552 |
children |
rev | line source |
---|---|
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for the userid_flags directive. |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http userid/); |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 server { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 listen 127.0.0.1:8080; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server_name localhost; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 userid on; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 userid_name test; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 userid_path /0123456789; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 userid_domain test.domain; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 location / { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 userid_flags samesite=strict; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location /many { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 userid_flags httponly samesite=none secure; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
1596
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
54 |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
55 location /off { |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
56 userid_flags off; |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
57 } |
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 location /lax { |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 userid_flags samesite=lax; |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
1596
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
63 |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
64 location /unset { } |
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 EOF |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 $t->write_file('index.html', ''); |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $t->write_file('lax', ''); |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 $t->write_file('many', ''); |
1693
5ac6efbe5552
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1596
diff
changeset
|
73 $t->run()->plan(5); |
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 ############################################################################### |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
1596
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
77 like(http_get('/'), qr/samesite=strict/i, 'strict'); |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
78 like(http_get('/lax'), qr/samesite=lax/i, 'lax'); |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
79 like(http_get('/many'), qr/secure; httponly; samesite=none/i, 'many'); |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
80 unlike(http_get('/off'), qr/(secure|httponly|samesite)/i, 'off'); |
f42d82b114cd
Tests: added userid_flags tests with "off" and unset values.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1595
diff
changeset
|
81 unlike(http_get('/unset'), qr/(secure|httponly|samesite)/i, 'unset'); |
1595
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
a2c6b95d6591
Tests: userid_flags tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 ############################################################################### |