@@ -52,9 +52,6 @@ func Test_Runner(t *testing.T) {
52
52
t .Run ("OK" ,func (t * testing.T ) {
53
53
t .Parallel ()
54
54
55
- ctx ,cancel := context .WithTimeout (context .Background (),testutil .WaitLong )
56
- defer cancel ()
57
-
58
55
client := coderdtest .New (t ,& coderdtest.Options {
59
56
IncludeProvisionerDaemon :true ,
60
57
})
@@ -109,6 +106,8 @@ func Test_Runner(t *testing.T) {
109
106
version = coderdtest .AwaitTemplateVersionJobCompleted (t ,client ,version .ID )
110
107
template := coderdtest .CreateTemplate (t ,client ,user .OrganizationID ,version .ID )
111
108
109
+ ctx := testutil .Context (t ,testutil .WaitLong )
110
+
112
111
closerCh := goEventuallyStartFakeAgent (ctx ,t ,client ,authToken )
113
112
114
113
const (
@@ -199,9 +198,6 @@ func Test_Runner(t *testing.T) {
199
198
t .Run ("CleanupPendingBuild" ,func (t * testing.T ) {
200
199
t .Parallel ()
201
200
202
- ctx ,cancel := context .WithTimeout (context .Background (),testutil .WaitLong )
203
- defer cancel ()
204
-
205
201
// need to include our own logger because the provisioner (rightly) drops error logs when we shut down the
206
202
// test with a build in progress.
207
203
logger := slogtest .Make (t ,& slogtest.Options {IgnoreErrors :true }).Leveled (slog .LevelDebug )
@@ -253,7 +249,9 @@ func Test_Runner(t *testing.T) {
253
249
},
254
250
})
255
251
252
+ ctx := testutil .Context (t ,testutil .WaitLong )
256
253
cancelCtx ,cancelFunc := context .WithCancel (ctx )
254
+
257
255
done := make (chan struct {})
258
256
logs := bytes .NewBuffer (nil )
259
257
go func () {
@@ -287,6 +285,8 @@ func Test_Runner(t *testing.T) {
287
285
cancelFunc ()
288
286
<- done
289
287
288
+ ctx = testutil .Context (t ,testutil .WaitLong )// Reset ctx to avoid timeouts.
289
+
290
290
// When we run the cleanup, it should be canceled
291
291
cleanupLogs := bytes .NewBuffer (nil )
292
292
cancelCtx ,cancelFunc = context .WithCancel (ctx )
@@ -340,9 +340,6 @@ func Test_Runner(t *testing.T) {
340
340
t .Run ("NoCleanup" ,func (t * testing.T ) {
341
341
t .Parallel ()
342
342
343
- ctx ,cancel := context .WithTimeout (context .Background (),testutil .WaitLong )
344
- defer cancel ()
345
-
346
343
client := coderdtest .New (t ,& coderdtest.Options {
347
344
IncludeProvisionerDaemon :true ,
348
345
})
@@ -397,6 +394,7 @@ func Test_Runner(t *testing.T) {
397
394
version = coderdtest .AwaitTemplateVersionJobCompleted (t ,client ,version .ID )
398
395
template := coderdtest .CreateTemplate (t ,client ,user .OrganizationID ,version .ID )
399
396
397
+ ctx := testutil .Context (t ,testutil .WaitLong )
400
398
closeCh := goEventuallyStartFakeAgent (ctx ,t ,client ,authToken )
401
399
402
400
const (
@@ -484,9 +482,6 @@ func Test_Runner(t *testing.T) {
484
482
t .Run ("FailedBuild" ,func (t * testing.T ) {
485
483
t .Parallel ()
486
484
487
- ctx ,cancel := context .WithTimeout (context .Background (),testutil .WaitLong )
488
- defer cancel ()
489
-
490
485
logger := slogtest .Make (t ,& slogtest.Options {IgnoreErrors :true })
491
486
client := coderdtest .New (t ,& coderdtest.Options {
492
487
IncludeProvisionerDaemon :true ,
@@ -534,6 +529,8 @@ func Test_Runner(t *testing.T) {
534
529
},
535
530
})
536
531
532
+ ctx := testutil .Context (t ,testutil .WaitLong )
533
+
537
534
logs := bytes .NewBuffer (nil )
538
535
err := runner .Run (ctx ,"1" ,logs )
539
536
logsStr := logs .String ()