From 3678185f8a652e52864c44049a9ea96b7bcc066a Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 19 Mar 2024 13:42:48 -0700 Subject: [PATCH] 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 LUCI-TryBot-Result: Go LUCI --- http2/server_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/http2/server_test.go b/http2/server_test.go index 1fdd191ef..afccd9ecd 100644 --- a/http2/server_test.go +++ b/http2/server_test.go @@ -4578,13 +4578,16 @@ func TestCanonicalHeaderCacheGrowth(t *testing.T) { 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 {