]> git.proxmox.com Git - pmg-api.git/commitdiff
tests: greylist: retry connecting 3 times
authorStoiko Ivanov <s.ivanov@proxmox.com>
Fri, 11 Jun 2021 15:54:47 +0000 (17:54 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 16 Jun 2021 12:20:49 +0000 (14:20 +0200)
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@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
Tested-By: Dominik Csapak <d.csapak@proxmox.com>
src/tests/test_greylist.pl

index 3aa613f3789427e4b1affcd1542d2a1bc87e8a3b..6a5a11a8a91fdd1e413fc751b81c373173e38c6f 100755 (executable)
@@ -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";