Skip to content

Commit 30d50f9

Browse files
author
SatriaBagusNurhadianto
committed
test(dns): remove flaky wall-clock upper bounds (#206)
1 parent e5e38c3 commit 30d50f9

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

‎internal/dns/ratelimit_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func TestRateLimiterNoUnderDelivery(t *testing.T) {
4646
if elapsed < ideal*8/10 {
4747
t.Errorf("finished in %s, faster than the rate allows (ideal %s)", elapsed, ideal)
4848
}
49-
if elapsed > ideal*15/10+100*time.Millisecond {
50-
t.Errorf("finished in %s, well below the configured rate (ideal %s)", elapsed, ideal)
49+
if elapsed > ideal*5 {
50+
t.Errorf("finished in %s, far beyond a hang-only ceiling (ideal %s)", elapsed, ideal)
5151
}
5252
}
5353

‎internal/dns/resolver_test.go‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ func TestResolveDomainWithRetryContextCancellation(t *testing.T) {
7575
cancel()
7676

7777
timeout := time.Second
78-
start := time.Now()
7978
_, result := ResolveDomainWithRetry(ctx, srv.Resolver(timeout), "example.com.", timeout, nil, 5, []string{"A"})
80-
elapsed := time.Since(start)
8179

8280
if result == OutcomeFound {
8381
t.Errorf("expected cancelled context to prevent resolution")
8482
}
85-
if elapsed > 500*time.Millisecond {
86-
t.Errorf("expected near-instant return on cancelled context, took %s", elapsed)
83+
if srv.Queries() != 0 {
84+
t.Errorf("expected no query to reach the server on cancelled context, got %d", srv.Queries())
8785
}
8886
}
8987

‎internal/dnsserver/server_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestCloseWaitsForHandlers(t *testing.T) {
7171
if running.Load() != finished.Load() {
7272
t.Errorf("Close returned with %d handlers still running", running.Load()-finished.Load())
7373
}
74-
if took := time.Since(start); took > 2*time.Second {
74+
if took := time.Since(start); took > 10*time.Second {
7575
t.Errorf("Close took %s; a parked stream connection held it", took)
7676
}
7777
}

0 commit comments

Comments
 (0)