diff options
author | Eric Wong <e@80x24.org> | 2019-11-24 00:22:31 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-11-24 21:46:49 +0000 |
commit | e05912ae3899a0f50a6baf3b6c1892789d24f6b1 (patch) | |
tree | 3b031d7478b78b77ae66eaa57360e21f2286f6c1 /t/perf-nntpd.t | |
parent | 8576a48b2344905229737fde45498c80a1171ca5 (diff) | |
download | public-inbox-e05912ae3899a0f50a6baf3b6c1892789d24f6b1.tar.gz |
We can shave several hundred milliseconds off tests which spawn daemons by preloading and avoiding startup time for common modules which are already loaded in the parent process. This also gives ENV{TAIL} support to all tests which support daemons which log to stdout/stderr.
Diffstat (limited to 't/perf-nntpd.t')
-rw-r--r-- | t/perf-nntpd.t | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/t/perf-nntpd.t b/t/perf-nntpd.t index 7abf2249..c7d2eaff 100644 --- a/t/perf-nntpd.t +++ b/t/perf-nntpd.t @@ -10,18 +10,9 @@ use Net::NNTP; my $pi_dir = $ENV{GIANT_PI_DIR}; plan skip_all => "GIANT_PI_DIR not defined for $0" unless $pi_dir; eval { require PublicInbox::Search }; -my ($host_port, $group, %opts, $s, $pid); +my ($host_port, $group, %opts, $s, $td); require './t/common.perl'; -END { - if ($s) { - $s->print("QUIT\r\n"); - $s->getline; - $s = undef; - } - kill 'TERM', $pid if defined $pid; -}; - if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) { ($host_port, $group) = ($1, $2); $host_port .= ":119" unless index($host_port, ':') > 0; @@ -29,7 +20,6 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) { $group = 'inbox.test.perf.nntpd'; my $ibx = { inboxdir => $pi_dir, newsgroup => $group }; $ibx = PublicInbox::Inbox->new($ibx); - my $nntpd = 'blib/script/public-inbox-nntpd'; my $tmpdir = tempdir('perf-nntpd-XXXXXX', TMPDIR => 1, CLEANUP => 1); my $pi_config = "$tmpdir/config"; @@ -46,8 +36,8 @@ if (($ENV{NNTP_TEST_URL} || '') =~ m!\Anntp://([^/]+)/([^/]+)\z!) { my $sock = tcp_server(); ok($sock, 'sock created'); - my $cmd = [ $nntpd, '-W0' ]; - $pid = spawn_listener({ PI_CONFIG => $pi_config }, $cmd, [$sock]); + my $cmd = [ '-nntpd', '-W0' ]; + $td = start_script($cmd, { PI_CONFIG => $pi_config }, { 3 => $sock }); $host_port = $sock->sockhost . ':' . $sock->sockport; } %opts = ( @@ -110,6 +100,12 @@ $t = timeit(1, sub { }); diag 'newnews took: ' . timestr($t) . " for $n"; +if ($s) { + $s->print("QUIT\r\n"); + $s->getline; +} + + done_testing(); 1; |