Mercurial > hg > nginx-tests
changeset 976:a8b8dd6e8ae1
Tests: changed startup order in mail tests for consistency.
Notably, run_daemon() is postponed until after write_file_expand().
Also added waitforsocket() to avoid startup race.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 12 Jul 2016 20:51:06 +0300 |
parents | e17ffab3febc |
children | 6abe7be6d2c1 |
files | mail_error_log.t mail_imap.t mail_imap_ssl.t mail_pop3.t mail_resolver.t mail_smtp.t mail_smtp_xclient.t |
diffstat | 7 files changed, 34 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/mail_error_log.t Tue Jul 12 20:18:07 2016 +0300 +++ b/mail_error_log.t Tue Jul 12 20:51:06 2016 +0300 @@ -27,8 +27,7 @@ plan(skip_all => 'win32') if $^O eq 'MSWin32'; -my $t = Test::Nginx->new()->has(qw/mail imap http rewrite/) - ->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon, port(8144)); +my $t = Test::Nginx->new()->has(qw/mail imap http rewrite/); plan(skip_all => 'no error_log') unless $t->has_version('1.9.0'); @@ -90,9 +89,11 @@ open my $stderr, '<', $t->testdir() . '/stderr' or die "Can't open stderr file: $!"; +$t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon); $t->run_daemon(\&syslog_daemon, port(8081), $t, 's_glob.log'); $t->run_daemon(\&syslog_daemon, port(8082), $t, 's_info.log'); +$t->waitforsocket('127.0.0.1:' . port(8144)); $t->waitforfile($t->testdir . '/s_glob.log'); $t->waitforfile($t->testdir . '/s_info.log');
--- a/mail_imap.t Tue Jul 12 20:18:07 2016 +0300 +++ b/mail_imap.t Tue Jul 12 20:51:06 2016 +0300 @@ -26,10 +26,8 @@ local $SIG{PIPE} = 'IGNORE'; -my $t = Test::Nginx->new() - ->has(qw/mail imap http rewrite/)->plan(9) - ->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon, port(8144)) - ->write_file_expand('nginx.conf', <<'EOF')->run(); +my $t = Test::Nginx->new()->has(qw/mail imap http rewrite/)->plan(9) + ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -78,6 +76,9 @@ EOF +$t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon); +$t->run()->waitforsocket('127.0.0.1:' . port(8144)); + ############################################################################### my $s = Test::Nginx::IMAP->new();
--- a/mail_imap_ssl.t Tue Jul 12 20:18:07 2016 +0300 +++ b/mail_imap_ssl.t Tue Jul 12 20:51:06 2016 +0300 @@ -33,12 +33,9 @@ local $SIG{PIPE} = 'IGNORE'; -my $t = Test::Nginx->new() - ->has(qw/mail mail_ssl imap http rewrite/)->has_daemon('openssl') - ->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon, port(8144)) - ->plan(12); - -$t->write_file_expand('nginx.conf', <<'EOF'); +my $t = Test::Nginx->new()->has(qw/mail mail_ssl imap http rewrite/) + ->has_daemon('openssl')->plan(12) + ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -138,7 +135,8 @@ or die "Can't create certificate for $name: $!\n"; } -$t->run(); +$t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon); +$t->run()->waitforsocket('127.0.0.1:' . port(8144)); ###############################################################################
--- a/mail_pop3.t Tue Jul 12 20:18:07 2016 +0300 +++ b/mail_pop3.t Tue Jul 12 20:51:06 2016 +0300 @@ -26,10 +26,8 @@ local $SIG{PIPE} = 'IGNORE'; -my $t = Test::Nginx->new() - ->has(qw/mail pop3 http rewrite/)->plan(8) - ->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon, port(8111)) - ->write_file_expand('nginx.conf', <<'EOF')->run(); +my $t = Test::Nginx->new()->has(qw/mail pop3 http rewrite/)->plan(8) + ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -78,6 +76,9 @@ EOF +$t->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon); +$t->run()->waitforsocket('127.0.0.1:' . port(8111)); + ############################################################################### my $s = Test::Nginx::POP3->new();
--- a/mail_resolver.t Tue Jul 12 20:18:07 2016 +0300 +++ b/mail_resolver.t Tue Jul 12 20:51:06 2016 +0300 @@ -25,10 +25,8 @@ local $SIG{PIPE} = 'IGNORE'; -my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/) - ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon, port(8026)); - -$t->write_file_expand('nginx.conf', <<'EOF'); +my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(8) + ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -116,16 +114,13 @@ EOF -for (8081 .. 8087) { - $t->run_daemon(\&dns_daemon, port($_), $t); -} +$t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); +$t->run_daemon(\&dns_daemon, port($_), $t) foreach (8081 .. 8087); + $t->run(); -for (8081 .. 8087) { - $t->waitforfile($t->testdir . '/' . port($_)); -} - -$t->plan(8); +$t->waitforsocket('127.0.0.1:' . port(8026)); +$t->waitforfile($t->testdir . '/' . port($_)) foreach (8081 .. 8087); ###############################################################################
--- a/mail_smtp.t Tue Jul 12 20:18:07 2016 +0300 +++ b/mail_smtp.t Tue Jul 12 20:51:06 2016 +0300 @@ -27,10 +27,8 @@ local $SIG{PIPE} = 'IGNORE'; -my $t = Test::Nginx->new() - ->has(qw/mail smtp http rewrite/)->plan(25) - ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon, port(8026)) - ->write_file_expand('nginx.conf', <<'EOF')->run(); +my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(25) + ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -81,6 +79,9 @@ EOF +$t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); +$t->run()->waitforsocket('127.0.0.1:' . port(8026)); + ############################################################################### my $s = Test::Nginx::SMTP->new();
--- a/mail_smtp_xclient.t Tue Jul 12 20:18:07 2016 +0300 +++ b/mail_smtp_xclient.t Tue Jul 12 20:51:06 2016 +0300 @@ -25,8 +25,7 @@ local $SIG{PIPE} = 'IGNORE'; my $t = Test::Nginx->new()->has(qw/mail smtp http rewrite/)->plan(6) - ->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon, port(8026)) - ->write_file_expand('nginx.conf', <<'EOF')->run(); + ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -66,6 +65,9 @@ EOF +$t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); +$t->run()->waitforsocket('127.0.0.1:' . port(8026)); + ############################################################################### # When XCLIENT's HELO= argument isn't used, the following combinations may be