http2: make TestCanonicalHeaderCacheGrowth faster
Lower the number of iterations that this test runs for.
Reduces runtime with -race from 27s on my M1 Mac to 0.06s.
Change-Id: Ibd4b225277c79d9030c0a21b3077173a787cc4c1
Reviewed-on: https://go-review.googlesource.com/c/net/+/572656
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/http2/server_test.go b/http2/server_test.go
index 1fdd191..afccd9e 100644
--- a/http2/server_test.go
+++ b/http2/server_test.go
@@ -4578,13 +4578,16 @@
sc := &serverConn{
serveG: newGoroutineLock(),
}
- const count = 1000
- for i := 0; i < count; i++ {
- h := fmt.Sprintf("%v-%v", base, i)
+ count := 0
+ added := 0
+ for added < 10*maxCachedCanonicalHeadersKeysSize {
+ h := fmt.Sprintf("%v-%v", base, count)
c := sc.canonicalHeader(h)
if len(h) != len(c) {
t.Errorf("sc.canonicalHeader(%q) = %q, want same length", h, c)
}
+ count++
+ added += len(h)
}
total := 0
for k, v := range sc.canonHeader {