File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 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 ,
You can’t perform that action at this time.
0 commit comments