Skip to content

Commit 17cee86

Browse files
committed
Fix flaky gRPC client tests in sidecar
Add grpc.WaitForReady(true) option to test client connections to handle race conditions where the gRPC server starts slower than client calls. This eliminates timing-based test failures in sidecar/internal/reconciler tests. The WaitForReady option ensures the client waits for the server to be ready before sending RPCs, rather than failing immediately if the connection is not yet established.
1 parent 8988265 commit 17cee86

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sidecar/internal/test/rpc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,9 @@ func ClientConn(tmpSockUri string) (*grpc.ClientConn, error) {
8989
return grpc.NewClient(tmpSockUri,
9090
// nothing fancy for unit tests
9191
grpc.WithTransportCredentials(insecure.NewCredentials()),
92+
grpc.WithDefaultCallOptions(
93+
// Handle server starting slower than client calls in tests
94+
grpc.WaitForReady(true),
95+
),
9296
)
9397
}

0 commit comments

Comments
 (0)