Merge branch 'test/cache-reduce-goroutines-stability' into 'main'
test(cache): reduce goroutines for race detector stability See merge request unboundsoftware/schemas!633
This commit was merged in pull request #637.
This commit is contained in:
Vendored
+7
-6
@@ -337,9 +337,9 @@ func TestCache_ConcurrentReads(t *testing.T) {
|
|||||||
Key: hashedKey,
|
Key: hashedKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run concurrent reads
|
// Run concurrent reads (reduced for race detector)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
numGoroutines := 100
|
numGoroutines := 20
|
||||||
|
|
||||||
for i := 0; i < numGoroutines; i++ {
|
for i := 0; i < numGoroutines; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@@ -359,7 +359,7 @@ func TestCache_ConcurrentWrites(t *testing.T) {
|
|||||||
c := New(logger)
|
c := New(logger)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
numGoroutines := 50
|
numGoroutines := 10 // Reduced for race detector
|
||||||
|
|
||||||
// Concurrent organization additions
|
// Concurrent organization additions
|
||||||
for i := 0; i < numGoroutines; i++ {
|
for i := 0; i < numGoroutines; i++ {
|
||||||
@@ -406,15 +406,16 @@ func TestCache_ConcurrentReadsAndWrites(t *testing.T) {
|
|||||||
c.users["user-initial"] = []string{orgID}
|
c.users["user-initial"] = []string{orgID}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
numReaders := 50
|
numReaders := 10 // Reduced for race detector
|
||||||
numWriters := 20
|
numWriters := 5 // Reduced for race detector
|
||||||
|
iterations := 3 // Reduced for race detector
|
||||||
|
|
||||||
// Concurrent readers
|
// Concurrent readers
|
||||||
for i := 0; i < numReaders; i++ {
|
for i := 0; i < numReaders; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
for j := 0; j < 10; j++ {
|
for j := 0; j < iterations; j++ {
|
||||||
org := c.OrganizationByAPIKey(apiKey)
|
org := c.OrganizationByAPIKey(apiKey)
|
||||||
assert.NotNil(t, org)
|
assert.NotNil(t, org)
|
||||||
orgs := c.OrganizationsByUser("user-initial")
|
orgs := c.OrganizationsByUser("user-initial")
|
||||||
|
|||||||
Reference in New Issue
Block a user