changeset 1509:1603f2bad385

Tests: $sent_http_connection tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 16 Sep 2019 19:13:18 +0300
parents 1a409a166420
children 48306d8a2811
files http_keepalive.t proxy_upgrade.t
diffstat 2 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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 {
--- 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');
 
 ###############################################################################