Mercurial > hg > nginx-tests
comparison debug_connection_unix.t @ 835:650465c099e1
Tests: added unix tests for debug_connection directive.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Thu, 28 Jan 2016 20:38:41 +0300 |
parents | |
children | e9064d691790 |
comparison
equal
deleted
inserted
replaced
834:37747a4ff78e | 835:650465c099e1 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Nginx, Inc. | |
4 | |
5 # Tests for debug_connection with unix socket. | |
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 --with-debug unix proxy/); | |
25 | |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 daemon off; | |
31 | |
32 events { | |
33 debug_connection unix:; | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 error_log %%TESTDIR%%/debug1.log alert; | |
40 error_log %%TESTDIR%%/debug2.log alert; | |
41 | |
42 server { | |
43 listen 127.0.0.1:8080; | |
44 listen unix:%%TESTDIR%%/unix.sock; | |
45 server_name localhost; | |
46 | |
47 location /debug { | |
48 proxy_pass http://unix:%%TESTDIR%%/unix.sock:/; | |
49 } | |
50 } | |
51 } | |
52 | |
53 EOF | |
54 | |
55 $t->try_run('no unix support')->plan(5); | |
56 | |
57 ############################################################################### | |
58 | |
59 http_get('/'); | |
60 | |
61 select undef, undef, undef, 0.1; | |
62 is($t->read_file('debug1.log'), '', 'no debug_connection file 1'); | |
63 is($t->read_file('debug2.log'), '', 'no debug_connection file 2'); | |
64 | |
65 http_get('/debug'); | |
66 | |
67 select undef, undef, undef, 0.1; | |
68 like($t->read_file('debug1.log'), qr/\[debug\]/, 'debug_connection file 1'); | |
69 like($t->read_file('debug2.log'), qr/\[debug\]/, 'debug_connection file 2'); | |
70 is($t->read_file('debug1.log'), $t->read_file('debug2.log'), | |
71 'debug_connection file1 file2 match'); | |
72 | |
73 ############################################################################### |