Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASCII-2461] Fix flaky TestRunProviders #31879

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions comp/core/flare/flare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package flare

import (
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -75,9 +74,7 @@ func TestFlareCreation(t *testing.T) {
}

func TestRunProviders(t *testing.T) {
var firstRan atomic.Bool
var secondRan atomic.Bool
var secondDone atomic.Bool
firstStarted := make(chan struct{}, 1)

fakeTagger := mockTagger.SetupFakeTagger(t)

Expand Down Expand Up @@ -105,7 +102,7 @@ func TestRunProviders(t *testing.T) {
fx.Provide(fx.Annotate(
func() *types.FlareFiller {
return types.NewFiller(func(_ types.FlareBuilder) error {
firstRan.Store(true)
firstStarted <- struct{}{}
return nil
})
},
Expand All @@ -114,9 +111,7 @@ func TestRunProviders(t *testing.T) {
fx.Provide(fx.Annotate(
func() *types.FlareFiller {
return types.NewFiller(func(_ types.FlareBuilder) error {
secondRan.Store(true)
time.Sleep(10 * time.Second)
secondDone.Store(true)
return nil
})
},
Expand All @@ -130,9 +125,10 @@ func TestRunProviders(t *testing.T) {
fb, err := helpers.NewFlareBuilder(false, flarebuilder.FlareArgs{})
require.NoError(t, err)

start := time.Now()
f.Comp.(*flare).runProviders(fb, cliProviderTimeout)
<-firstStarted
pgimalac marked this conversation as resolved.
Show resolved Hide resolved
elapsed := time.Since(start)

require.True(t, firstRan.Load())
require.True(t, secondRan.Load())
require.False(t, secondDone.Load())
assert.Less(t, elapsed, 5*time.Second)
}
Loading