diff --git a/nixos/tests/opensmtpd.nix b/nixos/tests/opensmtpd.nix index 5079779f35b4..4c0cbca21010 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 .');