Skip to content

Commit

Permalink
The go func was bogging down tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdurham committed Oct 29, 2024
1 parent d4bd469 commit f48a56b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions internal/component/prometheus/write/queue/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func runTest(t *testing.T, add func(index int, appendable storage.Appender) (flo
require.NoError(t, err)
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)

go func() {
runErr := c.Run(ctx)
require.NoError(t, runErr)
Expand All @@ -168,16 +169,15 @@ func runTest(t *testing.T, add func(index int, appendable storage.Appender) (flo
}

for i := 0; i < iterations; i++ {
go func() {
app := exp.Receiver.Appender(ctx)
for j := 0; j < items; j++ {
val := index.Add(1)
v, lbl := add(int(val), app)
results.Add(v, lbl)
}
require.NoError(t, app.Commit())
}()
app := exp.Receiver.Appender(ctx)
for j := 0; j < items; j++ {
val := index.Add(1)
v, lbl := add(int(val), app)
results.Add(v, lbl)
}
require.NoError(t, app.Commit())
}

// This is a weird use case to handle eventually.
// With race turned on this can take a long time.
tm := time.NewTimer(20 * time.Second)
Expand All @@ -186,6 +186,7 @@ func runTest(t *testing.T, add func(index int, appendable storage.Appender) (flo
case <-tm.C:
require.Truef(t, false, "failed to collect signals in the appropriate time")
}

cancel()

for i := 0; i < samples.Len(); i++ {
Expand Down

0 comments on commit f48a56b

Please sign in to comment.