# HG changeset patch # User Sergey Kandaurov # Date 1497543647 -10800 # Node ID 1c703303feee27d10badff6ec11056a2e3965b97 # Parent 074e05b33b1ace4accf13d430cc9d017d81922d5 Tests: basic open_log_file_cache log module tests. diff --git a/access_log.t b/access_log.t --- a/access_log.t +++ b/access_log.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http rewrite gzip/)->plan(11) +my $t = Test::Nginx->new()->has(qw/http rewrite gzip/)->plan(15) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -90,6 +90,12 @@ http { return 200 OK; } + location /cache { + open_log_file_cache max=3 inactive=20s valid=1m min_uses=2; + access_log %%TESTDIR%%/dir/cache_${arg_logname} test; + return 200 OK; + } + location /binary { access_log %%TESTDIR%%/binary.log binary; } @@ -98,6 +104,7 @@ http { EOF +mkdir $t->testdir() . '/dir'; $t->run(); ############################################################################### @@ -136,6 +143,21 @@ http_get('/varlog?logname=filename'); http_get('/binary'); +http_get('/cache?logname=lru'); +http_get('/cache?logname=lru'); +http_get('/cache?logname=once'); +http_get('/cache?logname=first'); +http_get('/cache?logname=first'); +http_get('/cache?logname=second'); +http_get('/cache?logname=second'); + +chmod 0000, $t->testdir() . '/dir'; + +http_get('/cache?logname=lru'); +http_get('/cache?logname=once'); +http_get('/cache?logname=first'); +http_get('/cache?logname=second'); + # wait for file to appear with nonzero size thanks to the flush parameter for (1 .. 10) { @@ -216,4 +238,16 @@ my $expected = join '', map { sprintf "\ is($t->read_file('binary.log'), "$expected\n", 'binary'); +chmod 0755, $t->testdir() . '/dir'; + +SKIP: { +skip 'win32', 4 if $^O eq 'MSWin32'; + +is(@{[$t->read_file('/dir/cache_lru') =~ /\//g]}, 2, 'cache - closed lru'); +is(@{[$t->read_file('/dir/cache_once') =~ /\//g]}, 1, 'cache - min_uses'); +is(@{[$t->read_file('/dir/cache_first') =~ /\//g]}, 3, 'cache - cached 1'); +is(@{[$t->read_file('/dir/cache_second') =~ /\//g]}, 3, 'cache - cached 2'); + +} + ###############################################################################