Mercurial > hg > nginx-tests
annotate debug_connection.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | fcd65708672d |
children |
rev | line source |
---|---|
301
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
303
ad51e58c2d7a
Tests: fixed typo in copyright.
Sergey Kandaurov <pluknet@nginx.com>
parents:
301
diff
changeset
|
3 # (C) Nginx, Inc. |
301
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 # Tests for debug_connection. |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 ############################################################################### |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 use warnings; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use strict; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use Test::More; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 use lib 'lib'; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use Test::Nginx; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 ############################################################################### |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
1170
cf14cfe9ec8c
Tests: dropped obsolete ipv6 prerequisite.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http --with-debug proxy/); |
301
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 $t->write_file_expand('nginx.conf', <<'EOF'); |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 debug_connection ::1; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 error_log %%TESTDIR%%/debug1.log alert; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 error_log %%TESTDIR%%/debug2.log alert; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
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; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
44 listen [::1]:%%PORT_8080%%; |
301
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server_name localhost; |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location /debug { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 proxy_pass http://[::1]:%%PORT_8080%%/; |
301
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 EOF |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
1190
fcd65708672d
Tests: let tests pass on travis-ci VMs with disabled IPv6 loopback.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1171
diff
changeset
|
55 $t->try_run('no inet6 support')->plan(5); |
301
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 ############################################################################### |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 http_get('/'); |
519
089c4174e269
Tests: reduced race in debug_connection tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
467
diff
changeset
|
60 |
089c4174e269
Tests: reduced race in debug_connection tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
467
diff
changeset
|
61 select undef, undef, undef, 0.1; |
467
43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
62 is($t->read_file('debug1.log'), '', 'no debug_connection file 1'); |
827 | 63 is($t->read_file('debug2.log'), '', 'no debug_connection file 2'); |
301
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 http_get('/debug'); |
519
089c4174e269
Tests: reduced race in debug_connection tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
467
diff
changeset
|
66 |
089c4174e269
Tests: reduced race in debug_connection tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
467
diff
changeset
|
67 select undef, undef, undef, 0.1; |
467
43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
68 like($t->read_file('debug1.log'), qr/\[debug\]/, 'debug_connection file 1'); |
43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
69 like($t->read_file('debug2.log'), qr/\[debug\]/, 'debug_connection file 2'); |
43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
397
diff
changeset
|
70 is($t->read_file('debug1.log'), $t->read_file('debug2.log'), |
301
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 'debug_connection file1 file2 match'); |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
a107552ac714
Tests: added tests for debug_connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 ############################################################################### |