@@ -10,7 +10,6 @@ import (
10
10
"testing"
11
11
"time"
12
12
13
- "github.com/cockroachdb/cockroach/pkg/testutils/skip"
14
13
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
15
14
"github.com/cockroachdb/errors"
16
15
"github.com/stretchr/testify/require"
@@ -402,11 +401,7 @@ func TestRetryWithMaxDuration(t *testing.T) {
402
401
retryFunc func (attemptNum int ) error
403
402
preRetryFunc func ()
404
403
expectedTimeSpent time.Duration
405
- // For cases where the amount of time spent is not deterministic, we can set
406
- // an upper bound instead (e.g. for context or closer).
407
- maxExpectedTimeSpent time.Duration
408
- expectedErr bool
409
- skipUnderDuress bool
404
+ expectedErr bool
410
405
}
411
406
412
407
testCases := []testcase {
@@ -474,11 +469,8 @@ func TestRetryWithMaxDuration(t *testing.T) {
474
469
preRetryFunc : func () {
475
470
cancelCtxFunc ()
476
471
},
477
- maxExpectedTimeSpent : time .Millisecond * 20 ,
478
- expectedErr : true ,
479
- // Under duress, closing a context will not necessarily stop the retry
480
- // loop immediately, so we skip this test under duress.
481
- skipUnderDuress : true ,
472
+ expectedTimeSpent : 0 ,
473
+ expectedErr : true ,
482
474
},
483
475
{
484
476
name : "errors with opt.Closer that is closed" ,
@@ -494,20 +486,13 @@ func TestRetryWithMaxDuration(t *testing.T) {
494
486
preRetryFunc : func () {
495
487
close (closeCh )
496
488
},
497
- maxExpectedTimeSpent : time .Millisecond * 20 ,
498
- expectedErr : true ,
499
- // Under duress, closing a channel will not necessarily stop the retry
500
- // loop immediately, so we skip this test under duress.
501
- skipUnderDuress : true ,
489
+ expectedTimeSpent : 0 ,
490
+ expectedErr : true ,
502
491
},
503
492
}
504
493
505
494
for _ , tc := range testCases {
506
495
t .Run (tc .name , func (t * testing.T ) {
507
- if tc .skipUnderDuress && skip .Duress () {
508
- skip .UnderDuress (t , "skipping test under duress: %s" , tc .name )
509
- }
510
-
511
496
timeSource := timeutil .NewManualTime (time .Now ())
512
497
tc .opts .Clock = timeSource
513
498
// Disable randomization for deterministic tests.
@@ -544,18 +529,9 @@ func TestRetryWithMaxDuration(t *testing.T) {
544
529
require .NoError (t , err )
545
530
}
546
531
547
- if tc .expectedTimeSpent != 0 {
548
- require .Equal (
549
- t , tc .expectedTimeSpent , timeSource .Since (start ), "expected time does not match actual spent time" ,
550
- )
551
- }
552
-
553
- if tc .maxExpectedTimeSpent != 0 {
554
- require .LessOrEqual (
555
- t , timeSource .Since (start ), tc .maxExpectedTimeSpent ,
556
- "expected time spent to be less than or equal to max expected time spent" ,
557
- )
558
- }
532
+ require .Equal (
533
+ t , tc .expectedTimeSpent , timeSource .Since (start ), "expected time does not match actual spent time" ,
534
+ )
559
535
})
560
536
}
561
537
}
0 commit comments