Skip to content

Commit 404f78a

Browse files
committed
Do a connect-retry loop during deamon integration test
1 parent be1085c commit 404f78a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Diff for: internal/integrationtest/arduino-cli.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,22 @@ func (cli *ArduinoCLI) StartDaemon(verbose bool) string {
408408
}
409409
go _copy(os.Stdout, stdout)
410410
go _copy(os.Stderr, stderr)
411-
conn, err := grpc.NewClient(cli.daemonAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
412-
cli.t.NoError(err)
413-
cli.daemonConn = conn
414-
cli.daemonClient = commands.NewArduinoCoreServiceClient(conn)
411+
412+
// Await the CLI daemon to be ready
413+
var connErr error
414+
for retries := 5; retries > 0; retries-- {
415+
time.Sleep(time.Second)
416+
417+
conn, err := grpc.NewClient(cli.daemonAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
418+
if err != nil {
419+
connErr = err
420+
continue
421+
}
422+
cli.daemonConn = conn
423+
cli.daemonClient = commands.NewArduinoCoreServiceClient(conn)
424+
break
425+
}
426+
cli.t.NoError(connErr)
415427
return cli.daemonAddr
416428
}
417429

0 commit comments

Comments
 (0)