@@ -125,6 +125,15 @@ func TestWorkspaceActivityBump(t *testing.T) {
125
125
}
126
126
127
127
var updatedAfter 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
+
128
137
// The Deadline bump occurs asynchronously.
129
138
require .Eventuallyf (t ,
130
139
func () bool {
@@ -133,14 +142,25 @@ func TestWorkspaceActivityBump(t *testing.T) {
133
142
updatedAfter = dbtime .Now ()
134
143
if workspace .LatestBuild .Deadline .Time .Equal (firstDeadline ) {
135
144
updatedAfter = time .Now ()
145
+ if time .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
+ }
136
149
return false
137
150
}
138
151
return true
139
152
},
140
- testutil .WaitLong , testutil .IntervalFast ,
153
+ testutil .WaitMedium , testutil .IntervalFast ,
141
154
"deadline %v never updated" , firstDeadline ,
142
155
)
143
156
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
+
144
164
require .Greater (t , workspace .LatestBuild .Deadline .Time , updatedAfter )
145
165
146
166
// If the workspace has a max deadline, the deadline must not exceed
@@ -156,7 +176,7 @@ func TestWorkspaceActivityBump(t *testing.T) {
156
176
firstDeadline , workspace .LatestBuild .Deadline .Time , now ,
157
177
now .Sub (workspace .LatestBuild .Deadline .Time ),
158
178
)
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 )
160
180
}
161
181
}
162
182
0 commit comments