Skip to content

test: add logging to TestWorkspaceActivityBump/Dial #15089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
always log timing information
  • Loading branch information
Emyrk committed Oct 15, 2024
commit 2bf1898c0713be787ab0cf3bd3cee47674dc7033
25 changes: 14 additions & 11 deletions coderd/activitybump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
// be increased. Since it could have been bumped at the intial
maxTimeDrift := testutil.WaitMedium

var updatedAfter time.Time
updatedAfter := dbtime.Now()
// waitedFor is purely for debugging failed tests. If a test fails,
// it helps to know how long it took for the deadline bump to be
// detected. The longer this takes, the more likely time drift will
Expand All @@ -148,20 +148,23 @@
checks++
workspace, err = client.Workspace(ctx, workspace.ID)
require.NoError(t, err)
updatedAfter = dbtime.Now()

if workspace.LatestBuild.Deadline.Time.Equal(firstDeadline) {
updatedAfter = time.Now()
if time.Since(lastChecked) > time.Second {
avgCheckTime := time.Since(waitedFor) / time.Duration(checks)
t.Logf("deadline still not updated, will continue to check: avg_check_dur=%s checks=%d deadline=%v", avgCheckTime, checks, workspace.LatestBuild.Deadline.Time)
lastChecked = time.Now()
}
return false
hasBumped := !workspace.LatestBuild.Deadline.Time.Equal(firstDeadline)

// Always make sure to log this information, even on the last check.
// The last check is the most important, as if this loop is acting
// slow, the last check could be the cause of the failure.
if time.Since(lastChecked) > time.Second || hasBumped {
avgCheckTime := time.Since(waitedFor) / time.Duration(checks)
t.Logf("deadline detect: bumped=%t since_last_check=%s avg_check_dur=%s checks=%d deadline=%v",
hasBumped, time.Since(updatedAfter), avgCheckTime, checks, workspace.LatestBuild.Deadline.Time)
lastChecked = time.Now()
}
return true

updatedAfter = dbtime.Now()
return hasBumped
},
maxTimeDrift, testutil.IntervalFast,

Check failure on line 167 in coderd/activitybump_test.go

View workflow job for this annotation

GitHub Actions / lint

ruleguard: Do not use magic numbers in test timeouts and delays. Use the standard testutil.Wait* or testutil.Interval* constants instead. (gocritic)
"deadline %v never updated", firstDeadline,
)

Expand Down
Loading