-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTTP/SMTP: Waiting for port to become connectable before continuing t…
…est run
- Loading branch information
Lucas Hinderberger
committed
Jul 4, 2024
1 parent
359c088
commit 822e78f
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package util | ||
|
||
import ( | ||
"net" | ||
"time" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// WaitForTCP polls indefinitely until it can connect to the given TCP address. | ||
func WaitForTCP(addr string) { | ||
logrus.Infof("Waiting for TCP address %q to become connectable...", addr) | ||
|
||
for { | ||
c, err := net.Dial("tcp", addr) | ||
if err == nil { | ||
c.Close() | ||
break | ||
} | ||
|
||
time.Sleep(10 * time.Millisecond) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters