From f70dc57ad3b63211cdc348bb3346139519aefced Mon Sep 17 00:00:00 2001 From: xeji <36407913+xeji@users.noreply.github.com> Date: Wed, 5 Sep 2018 22:36:17 +0200 Subject: [PATCH] nixos/tests/opensmtpd: prevent non-deterministic failure (#46071) A sporadic failure occured on Hydra because a request was sent to smtpd after the systemd unit was started, but before the daemon was actually listening. Fix by checking for open ports first. --- nixos/tests/opensmtpd.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nixos/tests/opensmtpd.nix b/nixos/tests/opensmtpd.nix index 5079779f35b..4c0cbca2101 100644 --- a/nixos/tests/opensmtpd.nix +++ b/nixos/tests/opensmtpd.nix @@ -102,11 +102,17 @@ import ./make-test.nix { testScript = '' startAll; - $client->waitForUnit("network.target"); + $client->waitForUnit("network-online.target"); $smtp1->waitForUnit('opensmtpd'); $smtp2->waitForUnit('opensmtpd'); $smtp2->waitForUnit('dovecot2'); + # To prevent sporadic failures during daemon startup, make sure + # services are listening on their ports before sending requests + $smtp1->waitForOpenPort(25); + $smtp2->waitForOpenPort(25); + $smtp2->waitForOpenPort(143); + $client->succeed('send-a-test-mail'); $smtp1->waitUntilFails('smtpctl show queue | egrep .'); $smtp2->waitUntilFails('smtpctl show queue | egrep .');