Skip to content

Commit

Permalink
util/log: add more information when log call exceeds deadline
Browse files Browse the repository at this point in the history
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.

This commit also doubles the deadline for `TestHTTPSinkTimeout` from
500ms to 1s, as we've seen some flakes for this test recently.

Epic: none
Fixes: cockroachdb#122527
  • Loading branch information
xinhaoz committed Apr 26, 2024
1 parent 4634d3f commit 1851143
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 1851143

Please sign in to comment.