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

Commit81b08ab

Browse files
committed
chore: include avg check time in eventually loop
If the hypothesis of a 10s time drift is true, this loop might beacting slow.
1 parentb0bc897 commit81b08ab

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

‎coderd/activitybump_test.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ func TestWorkspaceActivityBump(t *testing.T) {
124124
return
125125
}
126126

127+
// maxTimeDrift is how long we are willing wait for a deadline to
128+
// be increased. Since it could have been bumped at the intial
129+
maxTimeDrift:=testutil.WaitMedium
130+
127131
varupdatedAfter time.Time
128132
// waitedFor is purely for debugging failed tests. If a test fails,
129133
// it helps to know how long it took for the deadline bump to be
@@ -132,25 +136,32 @@ func TestWorkspaceActivityBump(t *testing.T) {
132136
waitedFor:=time.Now()
133137
// lastChecked is for logging within the Eventually loop.
134138
// Debouncing log lines to every second to prevent spam.
135-
lastChecked:=time.Now()
139+
lastChecked:= time.Time{}
140+
// checks is for keeping track of the average check time.
141+
// If CI is running slow, this could be useful to know checks
142+
// are taking longer than expected.
143+
checks:=0
136144

137145
// The Deadline bump occurs asynchronously.
138146
require.Eventuallyf(t,
139147
func()bool {
148+
checks++
140149
workspace,err=client.Workspace(ctx,workspace.ID)
141150
require.NoError(t,err)
142151
updatedAfter=dbtime.Now()
152+
143153
ifworkspace.LatestBuild.Deadline.Time.Equal(firstDeadline) {
144154
updatedAfter=time.Now()
145155
iftime.Since(lastChecked)>time.Second {
146-
t.Logf("deadline still not updated, will continue to check: deadline=%v",workspace.LatestBuild.Deadline.Time)
156+
avgCheckTime:=time.Since(waitedFor)/time.Duration(checks)
157+
t.Logf("deadline still not updated, will continue to check: avg_check_dur=%s checks=%d deadline=%v",avgCheckTime,checks,workspace.LatestBuild.Deadline.Time)
147158
lastChecked=time.Now()
148159
}
149160
returnfalse
150161
}
151162
returntrue
152163
},
153-
testutil.WaitMedium,testutil.IntervalFast,
164+
maxTimeDrift,testutil.IntervalFast,
154165
"deadline %v never updated",firstDeadline,
155166
)
156167

@@ -176,7 +187,7 @@ func TestWorkspaceActivityBump(t *testing.T) {
176187
firstDeadline,workspace.LatestBuild.Deadline.Time,now,
177188
now.Sub(workspace.LatestBuild.Deadline.Time),
178189
)
179-
require.WithinDuration(t,now.Add(ttl),workspace.LatestBuild.Deadline.Time,testutil.WaitShort)
190+
require.WithinDuration(t,now.Add(ttl),workspace.LatestBuild.Deadline.Time,maxTimeDrift)
180191
}
181192
}
182193

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp