Skip to content

Commit

Permalink
Attempt to make TestClient_DialHost more reliable (#38882)
Browse files Browse the repository at this point in the history
Takes inspiration from gravitational/teleport.e#1944
which addressed similar EOF error showing up when driving streams
in tests.

From https://pkg.go.dev/google.golang.org/grpc#ClientStream.SendMsg:

> // SendMsg is generally called by generated code. On error, SendMsg aborts
> // the stream. If the error was generated by the client, the status is
> // returned directly; otherwise, io.EOF is returned and the status of
> // the stream may be discovered using RecvMsg.
  • Loading branch information
rosstimothy authored Mar 7, 2024
1 parent a992bd2 commit 0a97d40
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions api/client/proxy/transport/transportv1/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestClient_DialHost(t *testing.T) {
return trail.ToGRPC(trace.NotImplemented("not implemented"))
case req.DialTarget.Cluster == "payload-too-large":
// send the initial cluster details
if err := server.Send(&transportv1pb.ProxySSHResponse{Details: &transportv1pb.ClusterDetails{FipsEnabled: true}}); err != nil {
if err := server.Send(&transportv1pb.ProxySSHResponse{Details: &transportv1pb.ClusterDetails{FipsEnabled: true}}); err != nil && !errors.Is(err, io.EOF) {
return trail.ToGRPC(trace.Wrap(err))
}

Expand All @@ -255,7 +255,7 @@ func TestClient_DialHost(t *testing.T) {
if err := server.Send(&transportv1pb.ProxySSHResponse{
Details: nil,
Frame: &transportv1pb.ProxySSHResponse_Ssh{Ssh: &transportv1pb.Frame{Payload: bytes.Repeat([]byte{0}, 1001)}},
}); err != nil {
}); err != nil && !errors.Is(err, io.EOF) {
return trail.ToGRPC(trace.Wrap(err))
}
case *transportv1pb.ProxySSHRequest_Agent:
Expand All @@ -265,7 +265,7 @@ func TestClient_DialHost(t *testing.T) {
return nil
case req.DialTarget.Cluster == "echo":
// send the initial cluster details
if err := server.Send(&transportv1pb.ProxySSHResponse{Details: &transportv1pb.ClusterDetails{FipsEnabled: true}}); err != nil {
if err := server.Send(&transportv1pb.ProxySSHResponse{Details: &transportv1pb.ClusterDetails{FipsEnabled: true}}); err != nil && !errors.Is(err, io.EOF) {
return trail.ToGRPC(trace.Wrap(err))
}

Expand All @@ -281,7 +281,7 @@ func TestClient_DialHost(t *testing.T) {
if err := server.Send(&transportv1pb.ProxySSHResponse{
Details: nil,
Frame: &transportv1pb.ProxySSHResponse_Ssh{Ssh: &transportv1pb.Frame{Payload: f.Ssh.Payload}},
}); err != nil {
}); err != nil && !errors.Is(err, io.EOF) {
return trail.ToGRPC(trace.Wrap(err))
}
case *transportv1pb.ProxySSHRequest_Agent:
Expand All @@ -290,7 +290,7 @@ func TestClient_DialHost(t *testing.T) {
return nil
case req.DialTarget.Cluster == "forward":
// send the initial cluster details
if err := server.Send(&transportv1pb.ProxySSHResponse{Details: &transportv1pb.ClusterDetails{FipsEnabled: true}}); err != nil {
if err := server.Send(&transportv1pb.ProxySSHResponse{Details: &transportv1pb.ClusterDetails{FipsEnabled: true}}); err != nil && !errors.Is(err, io.EOF) {
return trail.ToGRPC(trace.Wrap(err))
}

Expand All @@ -306,7 +306,7 @@ func TestClient_DialHost(t *testing.T) {
if err := server.Send(&transportv1pb.ProxySSHResponse{
Details: nil,
Frame: &transportv1pb.ProxySSHResponse_Ssh{Ssh: &transportv1pb.Frame{Payload: f.Ssh.Payload}},
}); err != nil {
}); err != nil && !errors.Is(err, io.EOF) {
return trail.ToGRPC(trace.Wrap(err))
}
case *transportv1pb.ProxySSHRequest_Agent:
Expand Down Expand Up @@ -360,7 +360,7 @@ func TestClient_DialHost(t *testing.T) {
if err := server.Send(&transportv1pb.ProxySSHResponse{
Details: nil,
Frame: &transportv1pb.ProxySSHResponse_Ssh{Ssh: &transportv1pb.Frame{Payload: keys[0].Blob}},
}); err != nil {
}); err != nil && !errors.Is(err, io.EOF) {
return trail.ToGRPC(trace.Wrap(err))
}
return nil
Expand Down

0 comments on commit 0a97d40

Please sign in to comment.