Skip to content

Commit

Permalink
server: with TLS, set TCP user timeout on the underlying raw connecti…
Browse files Browse the repository at this point in the history
…on (grpc#5646). fix tests
  • Loading branch information
tobotg committed May 27, 2023
1 parent 602b9c4 commit d6fc3c6
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions internal/transport/keepalive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,16 +699,19 @@ func (s) TestTCPUserTimeout(t *testing.T) {
}
client.CloseStream(stream, io.EOF)

cltOpt, err := syscall.GetTCPUserTimeout(client.conn)
if err != nil {
t.Fatalf("syscall.GetTCPUserTimeout() failed: %v", err)
}
if cltOpt < 0 {
t.Skipf("skipping test on unsupported environment")
}

if gotTimeout := time.Duration(cltOpt) * time.Millisecond; gotTimeout != tt.clientWantTimeout {
t.Fatalf("syscall.GetTCPUserTimeout() = %d, want %d", gotTimeout, tt.clientWantTimeout)
// check client TCP user timeout only when non TLS
// TODO : find a way to get the underlying conn for client when TLS
if !tt.tls {
cltOpt, err := syscall.GetTCPUserTimeout(client.conn)
if err != nil {
t.Fatalf("syscall.GetTCPUserTimeout() failed: %v", err)
}
if cltOpt < 0 {
t.Skipf("skipping test on unsupported environment")
}
if gotTimeout := time.Duration(cltOpt) * time.Millisecond; gotTimeout != tt.clientWantTimeout {
t.Fatalf("syscall.GetTCPUserTimeout() = %d, want %d", gotTimeout, tt.clientWantTimeout)
}
}
scConn := sc.conn
if tt.tls {
Expand Down

0 comments on commit d6fc3c6

Please sign in to comment.