[pmg-devel] [PATCH pmg-api 2/2] tests: greylist: retry connecting 3 times

Stoiko Ivanov s.ivanov at proxmox.com
Fri Jun 11 17:54:47 CEST 2021


Sometimes pmgpolicy is not done starting up when we try connecting.
Sadly strace on test_greylist.pl makes the problem disappear.

Looping 3 times should work robustly.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 src/tests/test_greylist.pl | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/tests/test_greylist.pl b/src/tests/test_greylist.pl
index 3aa613f..6a5a11a 100755
--- a/src/tests/test_greylist.pl
+++ b/src/tests/test_greylist.pl
@@ -44,10 +44,16 @@ sub reset_gldb {
 
 reset_gldb();
 
-my $sock = IO::Socket::INET->new(
-    PeerAddr => '127.0.0.1',
-    PeerPort => $testport) ||
-    die "unable to open socket -  $!";
+
+my $sock;
+for (my $tries = 0 ; $tries < 3 ; $tries++) {
+    $sock = IO::Socket::INET->new(
+	PeerAddr => '127.0.0.1',
+	PeerPort => $testport);
+    last if $sock;
+    sleep 1;
+}
+die "unable to open socket -  $!" if !$sock;
 
 $/ = "\n\n";
 
-- 
2.20.1





More information about the pmg-devel mailing list