Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
123130: util/log: add more information when log call exceeds deadline r=xinhaoz a=xinhaoz

For tests like `TestHTTSinkTimeout`, we want to verify that calls to hanging servers don't last much longer than the timeout configured for the http logging sink. Although this deadline is given a small bit of slack time, we've seen this test seemingly flake a couple of times. We should add more logging for when the log time exceeds the expected deadline to gather more information on if this is an actual bug.

Epic: none
Fixes: cockroachdb#122527

Co-authored-by: Xin Hao Zhang <xzhang@cockroachlabs.com>
  • Loading branch information
craig[bot] and xinhaoz committed Apr 26, 2024
2 parents 69e1fce + 1851143 commit 507b66b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/util/log/http_sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ func testBase(
// to accommodate for the overhead of the logging call compared to
// the timeout in the HTTP request.
if deadline > 0 && logDuration > deadline {
t.Error("Log call exceeded timeout")
require.LessOrEqualf(t, logDuration, deadline,
"Log call exceeded timeout, expected to be less than %s, got %s", deadline.String(), logDuration.String())
}

if hangServer {
Expand Down Expand Up @@ -234,7 +235,7 @@ func TestHTTPSinkTimeout(t *testing.T) {
},
}

testBase(t, defaults, nil /* testFn */, true /* hangServer */, 500*time.Millisecond, time.Duration(0))
testBase(t, defaults, nil /* testFn */, true /* hangServer */, 1*time.Second, time.Duration(0))
}

// TestHTTPSinkContentTypeJSON verifies that the HTTP sink content type
Expand Down

0 comments on commit 507b66b

Please sign in to comment.