Bug 879260
| Summary: | RFE: add function to to wait till a port is opened | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Jan Vcelak <jvcelak> |
| Component: | beakerlib | Assignee: | Petr Muller <pmuller> |
| Status: | CLOSED DUPLICATE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | rawhide | CC: | dspurek, ohudlick, pmuller, psplicha, qa-errata-list, tsmetana |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2013-06-07 11:06:46 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
*** This bug has been marked as a duplicate of bug 970143 *** |
Description of problem: Beakerlib should provide some function to repeat a given command periodically till executed successfully or till some timeout expires. For example: we run OpenLDAP server via valgrind on the background and need to wait till the initialization is finished (tcp/389 port is available). "sleep" is a dummy solution, because it slows down the test on fast machines and can cause the test to fail on slow machines. Here is a simple proposal, how it could work: function rlTryRepeat() { command=$1 retries=${2:-30} for (( retry=0; retry < $retries; retry++ )); do $command && return 0 || sleep 1 done return 1 } function rlWaitTcpPort() { port=$1 host=${2:-localhost} retries=$3 rlTryRepeat "nc -z $host $port" $retries } Usage: rlRun "valgrind ... slapd ... &" rlWaitTcpPort 389 rlRun "ldapsearch ..." Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info: