From 6404f7a4975767379383c222767abac487033701 Mon Sep 17 00:00:00 2001 From: Joakim Olsson Date: Fri, 21 Nov 2025 11:06:36 +0100 Subject: [PATCH] test(cache): reduce goroutines for race detector stability Decrease the number of goroutines in concurrent read and write tests to minimize race conditions during testing. This ensures more reliable test results and makes it easier to identify concurrency issues. --- cache/cache_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cache/cache_test.go b/cache/cache_test.go index f743461..b0d12f3 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -337,9 +337,9 @@ func TestCache_ConcurrentReads(t *testing.T) { Key: hashedKey, } - // Run concurrent reads + // Run concurrent reads (reduced for race detector) var wg sync.WaitGroup - numGoroutines := 100 + numGoroutines := 20 for i := 0; i < numGoroutines; i++ { wg.Add(1) @@ -359,7 +359,7 @@ func TestCache_ConcurrentWrites(t *testing.T) { c := New(logger) var wg sync.WaitGroup - numGoroutines := 50 + numGoroutines := 10 // Reduced for race detector // Concurrent organization additions for i := 0; i < numGoroutines; i++ { @@ -406,15 +406,16 @@ func TestCache_ConcurrentReadsAndWrites(t *testing.T) { c.users["user-initial"] = []string{orgID} var wg sync.WaitGroup - numReaders := 50 - numWriters := 20 + numReaders := 10 // Reduced for race detector + numWriters := 5 // Reduced for race detector + iterations := 3 // Reduced for race detector // Concurrent readers for i := 0; i < numReaders; i++ { wg.Add(1) go func() { defer wg.Done() - for j := 0; j < 10; j++ { + for j := 0; j < iterations; j++ { org := c.OrganizationByAPIKey(apiKey) assert.NotNil(t, org) orgs := c.OrganizationsByUser("user-initial")