measurexlite: fix flaky tls_test.go (#839)
Bug reported by @DecFox and subsequently observed in several CI builds. No need to create an issue.
This commit is contained in:
parent
086ae43b15
commit
5b27df1a37
|
@ -76,8 +76,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
|
||||||
trace := NewTrace(0, zeroTime)
|
trace := NewTrace(0, zeroTime)
|
||||||
trace.TimeNowFn = td.Now // deterministic timing
|
trace.TimeNowFn = td.Now // deterministic timing
|
||||||
thx := trace.NewTLSHandshakerStdlib(model.DiscardLogger)
|
thx := trace.NewTLSHandshakerStdlib(model.DiscardLogger)
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx := context.Background()
|
||||||
cancel() // we cancel immediately so connect is ~instantaneous
|
|
||||||
tcpConn := &mocks.Conn{
|
tcpConn := &mocks.Conn{
|
||||||
MockSetDeadline: func(t time.Time) error {
|
MockSetDeadline: func(t time.Time) error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -104,7 +103,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
|
||||||
ServerName: "dns.cloudflare.com",
|
ServerName: "dns.cloudflare.com",
|
||||||
}
|
}
|
||||||
conn, state, err := thx.Handshake(ctx, tcpConn, tlsConfig)
|
conn, state, err := thx.Handshake(ctx, tcpConn, tlsConfig)
|
||||||
if err == nil || err.Error() != netxlite.FailureInterrupted {
|
if !errors.Is(err, mockedErr) {
|
||||||
t.Fatal("unexpected err", err)
|
t.Fatal("unexpected err", err)
|
||||||
}
|
}
|
||||||
if !reflect.ValueOf(state).IsZero() {
|
if !reflect.ValueOf(state).IsZero() {
|
||||||
|
@ -119,7 +118,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
|
||||||
if len(events) != 1 {
|
if len(events) != 1 {
|
||||||
t.Fatal("expected to see single TLSHandshake event")
|
t.Fatal("expected to see single TLSHandshake event")
|
||||||
}
|
}
|
||||||
expectedFailure := netxlite.FailureInterrupted
|
expectedFailure := "unknown_failure: mocked"
|
||||||
expect := &model.ArchivalTLSOrQUICHandshakeResult{
|
expect := &model.ArchivalTLSOrQUICHandshakeResult{
|
||||||
Address: "1.1.1.1:443",
|
Address: "1.1.1.1:443",
|
||||||
CipherSuite: "",
|
CipherSuite: "",
|
||||||
|
@ -185,8 +184,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
|
||||||
trace.NetworkEvent = make(chan *model.ArchivalNetworkEvent) // no buffer
|
trace.NetworkEvent = make(chan *model.ArchivalNetworkEvent) // no buffer
|
||||||
trace.TLSHandshake = make(chan *model.ArchivalTLSOrQUICHandshakeResult) // no buffer
|
trace.TLSHandshake = make(chan *model.ArchivalTLSOrQUICHandshakeResult) // no buffer
|
||||||
thx := trace.NewTLSHandshakerStdlib(model.DiscardLogger)
|
thx := trace.NewTLSHandshakerStdlib(model.DiscardLogger)
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx := context.Background()
|
||||||
cancel() // we cancel immediately so connect is ~instantaneous
|
|
||||||
tcpConn := &mocks.Conn{
|
tcpConn := &mocks.Conn{
|
||||||
MockSetDeadline: func(t time.Time) error {
|
MockSetDeadline: func(t time.Time) error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -213,7 +211,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
|
||||||
ServerName: "dns.cloudflare.com",
|
ServerName: "dns.cloudflare.com",
|
||||||
}
|
}
|
||||||
conn, state, err := thx.Handshake(ctx, tcpConn, tlsConfig)
|
conn, state, err := thx.Handshake(ctx, tcpConn, tlsConfig)
|
||||||
if err == nil || err.Error() != netxlite.FailureInterrupted {
|
if !errors.Is(err, mockedErr) {
|
||||||
t.Fatal("unexpected err", err)
|
t.Fatal("unexpected err", err)
|
||||||
}
|
}
|
||||||
if !reflect.ValueOf(state).IsZero() {
|
if !reflect.ValueOf(state).IsZero() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user