user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 0/5] tiny test overhead reductions
@ 2019-11-04  3:01  6% Eric Wong
  2019-11-04  3:01  7% ` [PATCH 5/5] t/*.t: disable nntpd/httpd worker processes in most tests Eric Wong
  0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2019-11-04  3:01 UTC (permalink / raw)
  To: meta

Getting rid of IPC::Run for running 3rd party programs is a tiny
stope towards improving ease-of-testing for new contributors.

Next step might be be enabling mod_perl-like functionality for
our own short-lived scripts to speed up startup time...

Finally, we can eliminate daemon worker processes from most
tests (and explicitly test it in one place) since we don't
need to repeat ourselves.

Eric Wong (5):
  t/*.t: remove IPC::Run dependency for git commands
  t/httpd-corner.t: drop unnecessary bytes:: for length()
  t/httpd-corner.t: get rid of IPC::Run for running curl
  t/hl_mod.t: remove IPC::Run (and File::Temp) dependency
  t/*.t: disable nntpd/httpd worker processes in most tests

 t/git.t             | 12 ++++++------
 t/hl_mod.t          | 24 ++++++++++++++++--------
 t/httpd-corner.psgi |  3 +++
 t/httpd-corner.t    | 44 +++++++++++++++++++++++++++++---------------
 t/httpd.t           |  2 +-
 t/v2mirror.t        |  3 ++-
 t/v2writable.t      |  2 +-
 t/www_listing.t     | 13 +++++++------
 8 files changed, 65 insertions(+), 38 deletions(-)


^ permalink raw reply	[relevance 6%]

* [PATCH 5/5] t/*.t: disable nntpd/httpd worker processes in most tests
  2019-11-04  3:01  6% [PATCH 0/5] tiny test overhead reductions Eric Wong
@ 2019-11-04  3:01  7% ` Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2019-11-04  3:01 UTC (permalink / raw)
  To: meta

And explicitly test for respawning in t/httpd-corner.t

There's no need to have an extra entries in the process table
for most tests we run, since that's not what we're testing.
---
 t/httpd-corner.psgi |  3 +++
 t/httpd-corner.t    | 21 +++++++++++++++++----
 t/httpd.t           |  2 +-
 t/v2mirror.t        |  3 ++-
 t/v2writable.t      |  2 +-
 t/www_listing.t     |  2 +-
 6 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/t/httpd-corner.psgi b/t/httpd-corner.psgi
index 5628f4ab..bf38d1ff 100644
--- a/t/httpd-corner.psgi
+++ b/t/httpd-corner.psgi
@@ -85,6 +85,9 @@ my $app = sub {
 			close $null;
 			[ 200, [ qw(Content-Type application/octet-stream) ]];
 		});
+	} elsif ($path eq '/pid') {
+		$code = 200;
+		push @$body, $$;
 	}
 
 	[ $code, $h, $body ]
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index 13c0c2db..75573c3e 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -28,7 +28,7 @@ my $err = "$tmpdir/stderr.log";
 my $out = "$tmpdir/stdout.log";
 my $httpd = 'blib/script/public-inbox-httpd';
 my $psgi = "./t/httpd-corner.psgi";
-my $sock = tcp_server();
+my $sock = tcp_server() or die;
 
 # make sure stdin is not a pipe for lsof test to check for leaking pipes
 open(STDIN, '<', '/dev/null') or die 'no /dev/null: $!';
@@ -63,9 +63,22 @@ my $spawn_httpd = sub {
 	ok(defined $pid, 'forked httpd process successfully');
 };
 
-{
-	ok($sock, 'sock created');
-	$spawn_httpd->('-W0');
+$spawn_httpd->();
+if ('test worker death') {
+	my $conn = conn_for($sock, 'killed worker');
+	$conn->write("GET /pid HTTP/1.0\r\n\r\n");
+	ok($conn->read(my $buf, 8192), 'read response');
+	my ($head, $body) = split(/\r\n\r\n/, $buf);
+	like($body, qr/\A[0-9]+\z/, '/pid response');
+	my $pid = $body;
+	is(kill('KILL', $pid), 1, 'killed worker');
+
+	$conn = conn_for($sock, 'respawned worker');
+	$conn->write("GET /pid HTTP/1.0\r\n\r\n");
+	ok($conn->read($buf, 8192), 'read response');
+	($head, $body) = split(/\r\n\r\n/, $buf);
+	like($body, qr/\A[0-9]+\z/, '/pid response');
+	isnt($body, $pid, 'respawned worker');
 }
 
 {
diff --git a/t/httpd.t b/t/httpd.t
index 1340a7b3..15984a78 100644
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -53,7 +53,7 @@ EOF
 		$im->done($mime);
 	}
 	ok($sock, 'sock created');
-	my $cmd = [ $httpd, "--stdout=$out", "--stderr=$err" ];
+	my $cmd = [ $httpd, '-W0', "--stdout=$out", "--stderr=$err" ];
 	$pid = spawn_listener(undef, $cmd, [$sock]);
 	my $host = $sock->sockhost;
 	my $port = $sock->sockport;
diff --git a/t/v2mirror.t b/t/v2mirror.t
index a097a7f3..f826775c 100644
--- a/t/v2mirror.t
+++ b/t/v2mirror.t
@@ -66,7 +66,8 @@ END { kill 'TERM', $pid if defined $pid };
 $! = 0;
 $sock = tcp_server();
 ok($sock, 'sock created');
-my $cmd = [ "$script-httpd", "--stdout=$tmpdir/out", "--stderr=$tmpdir/err" ];
+my $httpd = "$script-httpd";
+my $cmd = [ $httpd, '-W0', "--stdout=$tmpdir/out", "--stderr=$tmpdir/err" ];
 ok(defined($pid = spawn_listener(undef, $cmd, [ $sock ])),
 	'spawned httpd process successfully');
 my ($host, $port) = ($sock->sockhost, $sock->sockport);
diff --git a/t/v2writable.t b/t/v2writable.t
index bfe17d0a..28420bb9 100644
--- a/t/v2writable.t
+++ b/t/v2writable.t
@@ -167,7 +167,7 @@ EOF
 	my $len;
 	END { kill 'TERM', $pid if defined $pid };
 	my $nntpd = 'blib/script/public-inbox-nntpd';
-	my $cmd = [ $nntpd, "--stdout=$out", "--stderr=$err" ];
+	my $cmd = [ $nntpd, '-W0', "--stdout=$out", "--stderr=$err" ];
 	$pid = spawn_listener({ PI_CONFIG => $pi_config }, $cmd, [ $sock ]);
 	my $host_port = $sock->sockhost . ':' . $sock->sockport;
 	my $n = Net::NNTP->new($host_port);
diff --git a/t/www_listing.t b/t/www_listing.t
index 3d1b64ad..61a059e5 100644
--- a/t/www_listing.t
+++ b/t/www_listing.t
@@ -106,7 +106,7 @@ SKIP: {
 
 	close $fh or die;
 	my $env = { PI_CONFIG => $cfgfile };
-	my $cmd = [ $httpd, "--stdout=$out", "--stderr=$err" ];
+	my $cmd = [ $httpd, '-W0', "--stdout=$out", "--stderr=$err" ];
 	$pid = spawn_listener($env, $cmd, [$sock]);
 	$sock = undef;
 

^ permalink raw reply related	[relevance 7%]

* [PATCH 01/17] tests: disable daemon workers in a few more places
  @ 2019-11-24  0:22  6% ` Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2019-11-24  0:22 UTC (permalink / raw)
  To: meta

There were still a few places where we used worker processes
unnecessarily in tests, causing a small amount of unnecessary
overhead.

Followup-to: ad221e9b2852f6c5 ("t/*.t: disable nntpd/httpd worker processes in most tests")
---
 t/httpd-unix.t | 1 +
 t/nntpd.t      | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/httpd-unix.t b/t/httpd-unix.t
index d0c70a72..2c918281 100644
--- a/t/httpd-unix.t
+++ b/t/httpd-unix.t
@@ -24,6 +24,7 @@ END { kill 'TERM', $pid if defined $pid };
 
 my $spawn_httpd = sub {
 	my (@args) = @_;
+	push @args, '-W0';
 	$pid = fork;
 	if ($pid == 0) {
 		exec $httpd, @args, "--stdout=$out", "--stderr=$err", $psgi;
diff --git a/t/nntpd.t b/t/nntpd.t
index b516ffd1..4795dc00 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -90,7 +90,7 @@ EOF
 	}
 
 	ok($sock, 'sock created');
-	my $cmd = [ $nntpd, "--stdout=$out", "--stderr=$err" ];
+	my $cmd = [ $nntpd, '-W0', "--stdout=$out", "--stderr=$err" ];
 	$pid = spawn_listener(undef, $cmd, [ $sock ]);
 	ok(defined $pid, 'forked nntpd process successfully');
 	my $host_port = $sock->sockhost . ':' . $sock->sockport;

^ permalink raw reply related	[relevance 6%]

Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-11-04  3:01  6% [PATCH 0/5] tiny test overhead reductions Eric Wong
2019-11-04  3:01  7% ` [PATCH 5/5] t/*.t: disable nntpd/httpd worker processes in most tests Eric Wong
2019-11-24  0:22     [PATCH 00/17] test fixes and cleanups Eric Wong
2019-11-24  0:22  6% ` [PATCH 01/17] tests: disable daemon workers in a few more places Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).