Skip to content

Commit a2a95e7

Browse files
committed
itest: speed up node startup
1 parent 2ca94d7 commit a2a95e7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

itest/tapd_harness.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/hex"
77
"flag"
88
"fmt"
9+
"net"
910
"os"
1011
"path/filepath"
1112
"sync"
@@ -305,10 +306,18 @@ func (hs *tapdHarness) start(expectErrExit bool) error {
305306
}
306307
}()
307308

308-
time.Sleep(1 * time.Second)
309+
// Let's wait until the RPC server is actually listening before we
310+
// connect our client to it.
311+
listenerAddr := hs.clientCfg.RpcConf.RawRPCListeners[0]
312+
err = wait.NoError(func() error {
313+
_, err := net.Dial("tcp", listenerAddr)
314+
return err
315+
}, defaultTimeout)
316+
if err != nil {
317+
return fmt.Errorf("error waiting for server to start: %v", err)
318+
}
309319

310320
// Create our client to interact with the tapd RPC server directly.
311-
listenerAddr := hs.clientCfg.RpcConf.RawRPCListeners[0]
312321
rpcConn, err := dialServer(
313322
listenerAddr, hs.clientCfg.RpcConf.TLSCertPath,
314323
hs.clientCfg.RpcConf.MacaroonPath,

0 commit comments

Comments
 (0)