user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
From: Eric Wong <>
Subject: [PATCH 1/2] t/httpd-corner: improve reliability and diagnostics
Date: Thu, 16 Apr 2020 01:48:37 +0000
Message-ID: <> (raw)
In-Reply-To: <>

The graceful-shutdown-on-PUT test is unreliable because we can't
rely on a FIFO as we do with the GET tests.  So increase the
delay to 100ms since that seems enough on my system even with

Add a timeout and backtrace to the $check_self sub to help with
further diagnostics while we're at it, too.

It would be nice if there were a portable syscall tracing
mechanism we could attach to the -httpd process to make the test
more determistic...
 t/httpd-corner.t | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index 21b5c560..f25a9a9c 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -16,6 +16,7 @@ use IO::Socket::UNIX;
 use Fcntl qw(:seek);
 use POSIX qw(mkfifo);
+use Carp ();
 my ($tmpdir, $for_destroy) = tmpdir();
 my $fifo = "$tmpdir/fifo";
 ok(defined mkfifo($fifo, 0777), 'created FIFO');
@@ -298,6 +299,8 @@ my $len = length $str;
 is($len, 26, 'got the alphabet');
 my $check_self = sub {
 	my ($conn) = @_;
+	vec(my $rbits, fileno($conn), 1) = 1;
+	select($rbits, undef, undef, 30) or Carp::confess('timed out');
 	$conn->read(my $buf, 4096);
 	my ($head, $body) = split(/\r\n\r\n/, $buf, 2);
 	like($head, qr/\r\nContent-Length: 40\r\n/s, 'got expected length');
@@ -391,17 +394,20 @@ SKIP: {
 	my $conn = conn_for($sock, 'graceful termination during slow request');
-	$conn->write("PUT /sha1 HTTP/1.0\r\n");
-	delay();
-	$conn->write("Content-Length: $len\r\n");
-	delay();
-	$conn->write("\r\n");
-	is($td->kill, 1, 'started graceful shutdown');
-	delay();
+	$conn->write("PUT /sha1 HTTP/1.0\r\nContent-Length: $len\r\n\r\n");
+	# XXX ugh, want a reliable and non-intrusive way to detect
+	# that the server has started buffering our partial request so we
+	# can reliably test graceful termination.  Maybe making this and
+	# similar tests dependent on Linux strace is a possibility?
+	delay(0.1);
+	is($td->kill, 1, 'start graceful shutdown');
 	my $n = 0;
 	foreach my $c ('a'..'z') {
 		$n += $conn->write($c);
+	ok(kill(0, $td->{pid}), 'graceful shutdown did not kill httpd');
 	is($n, $len, 'wrote alphabet');

  reply	other threads:[~2020-04-16  1:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16  1:48 [PATCH 0/2] more test fixes Eric Wong
2020-04-16  1:48 ` Eric Wong [this message]
2020-04-16  1:48 ` [PATCH 2/2] t/httpd-unix: reliability for non-signalfd/EVFILT_SIGNAL Eric Wong
2020-04-17  5:22   ` [PATCHv2 2/2] t/httpd-unix: skip some tests w/o signalfd|EVFILT_SIGNAL Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ \
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
 note: .onion URLs require Tor:

code repositories for the project(s) associated with this inbox:

AGPL code for this site: git clone