# HG changeset patch # User Sergey Kandaurov # Date 1568650398 -10800 # Node ID 1603f2bad385d7a8efe7d87d7cb7e15d57692d83 # Parent 1a409a166420aee398a5e954776d95738028c482 Tests: $sent_http_connection tests. diff --git a/http_keepalive.t b/http_keepalive.t --- a/http_keepalive.t +++ b/http_keepalive.t @@ -24,7 +24,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http/)->plan(13) +my $t = Test::Nginx->new()->has(qw/http/)->plan(14) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -37,6 +37,9 @@ events { http { %%TEST_GLOBALS_HTTP%% + log_format test $sent_http_connection; + access_log %%TESTDIR%%/test.log test if=$arg_l; + server { listen 127.0.0.1:8080; server_name localhost; @@ -77,7 +80,7 @@ EOF # keepalive_requests like(http_keepalive('/'), qr/Connection: keep-alive/, 'keepalive request'); -is(count_keepalive(http_keepalive('/', req => 2)), 1, 'keepalive limit'); +is(count_keepalive(http_keepalive('/?l=ok', req => 2)), 1, 'keepalive limit'); is(count_keepalive(http_keepalive('/r', req => 3)), 3, 'keepalive merge'); is(count_keepalive(http_keepalive('/r', req => 5)), 3, 'keepalive merge limit'); @@ -104,6 +107,15 @@ like($r, qr/Keep-Alive: timeout=9/, 'kee like(http_keepalive('/zero'), qr/Connection: close/, 'keepalive timeout 0'); +$t->stop(); + +TODO: { +local $TODO = 'not yet'; + +is($t->read_file('test.log'), "keep-alive\nclose\n", 'sent_http_connection'); + +} + ############################################################################### sub http_keepalive { diff --git a/proxy_upgrade.t b/proxy_upgrade.t --- a/proxy_upgrade.t +++ b/proxy_upgrade.t @@ -40,7 +40,7 @@ events { http { %%TEST_GLOBALS_HTTP%% - log_format test "$bytes_sent $body_bytes_sent"; + log_format test "$bytes_sent $body_bytes_sent $sent_http_connection"; access_log %%TESTDIR%%/cc.log test; server { @@ -147,9 +147,9 @@ ok(!$s, "handshake in subrequests"); open my $f, '<', "$d/cc.log" or die "Can't open cc.log: $!"; -is($f->getline(), shift (@r) . " 540793\n", 'log - bytes'); -is($f->getline(), shift (@r) . " 22\n", 'log - bytes pipelined'); -like($f->getline(), qr/\d+ 0\n/, 'log - bytes noupgrade'); +is($f->getline(), shift (@r) . " 540793 upgrade\n", 'log - bytes'); +is($f->getline(), shift (@r) . " 22 upgrade\n", 'log - bytes pipelined'); +like($f->getline(), qr/\d+ 0 /, 'log - bytes noupgrade'); ###############################################################################