Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb0bc897

Browse files
committed
chore: add log statements to detect a slow test check
If a test is running slow, the workspace deadline check can beslow. Since we use 'now' as a reference point, any time driftwill affect the results.
1 parent9acf6ac commitb0bc897

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

‎coderd/activitybump_test.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ func TestWorkspaceActivityBump(t *testing.T) {
125125
}
126126

127127
varupdatedAfter time.Time
128+
// waitedFor is purely for debugging failed tests. If a test fails,
129+
// it helps to know how long it took for the deadline bump to be
130+
// detected. The longer this takes, the more likely time drift will
131+
// affect the results.
132+
waitedFor:=time.Now()
133+
// lastChecked is for logging within the Eventually loop.
134+
// Debouncing log lines to every second to prevent spam.
135+
lastChecked:=time.Now()
136+
128137
// The Deadline bump occurs asynchronously.
129138
require.Eventuallyf(t,
130139
func()bool {
@@ -133,14 +142,25 @@ func TestWorkspaceActivityBump(t *testing.T) {
133142
updatedAfter=dbtime.Now()
134143
ifworkspace.LatestBuild.Deadline.Time.Equal(firstDeadline) {
135144
updatedAfter=time.Now()
145+
iftime.Since(lastChecked)>time.Second {
146+
t.Logf("deadline still not updated, will continue to check: deadline=%v",workspace.LatestBuild.Deadline.Time)
147+
lastChecked=time.Now()
148+
}
136149
returnfalse
137150
}
138151
returntrue
139152
},
140-
testutil.WaitLong,testutil.IntervalFast,
153+
testutil.WaitMedium,testutil.IntervalFast,
141154
"deadline %v never updated",firstDeadline,
142155
)
143156

157+
// This log line helps establish how long it took for the deadline
158+
// to be detected as bumped.
159+
t.Logf("deadline bump detected: %v, waited for %s",
160+
workspace.LatestBuild.Deadline.Time,
161+
time.Since(waitedFor),
162+
)
163+
144164
require.Greater(t,workspace.LatestBuild.Deadline.Time,updatedAfter)
145165

146166
// If the workspace has a max deadline, the deadline must not exceed
@@ -156,7 +176,7 @@ func TestWorkspaceActivityBump(t *testing.T) {
156176
firstDeadline,workspace.LatestBuild.Deadline.Time,now,
157177
now.Sub(workspace.LatestBuild.Deadline.Time),
158178
)
159-
require.WithinDuration(t,dbtime.Now().Add(ttl),workspace.LatestBuild.Deadline.Time,testutil.WaitShort)
179+
require.WithinDuration(t,now.Add(ttl),workspace.LatestBuild.Deadline.Time,testutil.WaitShort)
160180
}
161181
}
162182

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp